kapilt / getpaid

Automatically exported from code.google.com/p/getpaid
0 stars 0 forks source link

prefilled order containing a product that has been suppressed #303

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
issue related to the issue 231
1. Create a content "Payable"
2. Add it to the cart
3. Delete it in folder contents 

once the order is received, the merchant can say it doesn't provide anymore the 
product... and presents some excuses..
but if a user has already bought the product, is satisfied of it and use the 
facility offered to him to use a previous order to fill a new cart then the 
problem is bigger ..
Traceback (innermost last):
  Module ZPublisher.Publish, line 127, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 47, in call_object
  Module Products.PloneGetPaid.browser.cart, line 49, in __call__
  Module zope.viewlet.manager, line 112, in update
  Module zope.viewlet.manager, line 118, in _updateViewlets
  Module ore.viewlet.core, line 15, in update
  Module five.formlib.formbase, line 50, in update
  Module zope.formlib.form, line 763, in update
  Module zope.formlib.form, line 607, in success
  Module Products.PloneGetPaid.browser.cart, line 441, in handle_load_template
  Module zope.component._api, line 111, in getMultiAdapter
ComponentLookupError: ((<getpaid.core.cart.ShoppingCart object at 0xdbfd0ac>, 
None), <InterfaceClass getpaid.core.interfaces.ILineItemFactory

Original issue reported on code.google.com by danielle...@gmail.com on 26 Dec 2010 at 5:24

GoogleCodeExporter commented 8 years ago
we can use queryMultiAdapter instead of getMultiAdapter in handle_load_template

Index: src/Products.PloneGetPaid/Products/PloneGetPaid/browser/cart.py
===================================================================
--- 
src/Products.PloneGetPaid/Products/PloneGetPaid/browser/cart.py (révision 
158)
+++ src/Products.PloneGetPaid/Products/PloneGetPaid/browser/cart.py (copie de 
travail)
@@ -436,14 +436,20 @@
         cart = self.manager.__parent__.cart

         for v in o.shopping_cart.values():
+            miss = 0
             content = v.resolve()
-            item_factory = component.getMultiAdapter( (cart, content),
+            item_factory = component.queryMultiAdapter( (cart, content),
                                      interfaces.ILineItemFactory )
-
-            if IVariableAmountDonatableMarker.providedBy(content):
-                item_factory.create( amount=v.cost )
-            else:
-                item_factory.create( quantity=v.quantity )
-
-        self.status = _(u"Previous Order Loaded into Cart")
-
+            if item_factory:
+                if IVariableAmountDonatableMarker.providedBy(content):
+                    item_factory.create( amount=v.cost )
+                else:
+                    item_factory.create( quantity=v.quantity )
+            else :
+                miss = miss + 1
+        if miss == len(o.shopping_cart)
+            self.status = _(u"Previous Order is no more applicable")
+        elif miss == 0 :
+            self.status = _(u"Previous Order  loaded into Cart")
+        else :
+            self.status = _(u"Previous Order partially loaded into Cart : %s 
items are missing") %miss

Original comment by danielle...@gmail.com on 27 Dec 2010 at 12:41