Exemplo n.º 1
0
 def update(self):
     context = aq_inner(self.context)
     wipe_cart()
     self.context_url = context.absolute_url()
     IStatusMessage(self.request).addStatusMessage(
         _(u"Remove item from cart executed. This is not yet implemented"),
         type="info")
     redirect_url = self.context_url + '/@@cart'
     return self.request.response.redirect(redirect_url)
Exemplo n.º 2
0
 def update(self):
     context = aq_inner(self.context)
     here_url = context.absolute_url()
     cart = get_cart()
     order_id = self.request.get('oid', '')
     txn_id = cart['txn_id']
     try:
         txnid = txn_id[0]
     except KeyError:
         txnid = txn_id.keys()[0]
     if self.is_equal(order_id, txnid):
         order = txn_id[txnid]
         mto = order['billing.email']
         base_url = here_url + '/@@order-confirmation?txnid=' + txnid
         self.next_url = base_url + '&txn-mto=' + mto
         wipe_cart()
Exemplo n.º 3
0
 def update(self):
     context = aq_inner(self.context)
     self.context_url = context.absolute_url()
     pstate = getMultiAdapter((context, self.request),
                              name=u"plone_portal_state")
     self.portal_url = pstate.portal_url()
     self.uuid = IUUID(context, None)
     unwanted = ('_authenticator', 'form.button.Submit',
                 'form.button.Clear')
     if 'form.button.Clear' in self.request:
         authenticator = getMultiAdapter((context, self.request),
                                         name=u"authenticator")
         if not authenticator.verify():
             raise Unauthorized
         wipe_cart()
         IStatusMessage(self.request).addStatusMessage(
             _(u"Your shopping cart has successfully been purged"),
             type="info")
         return self.request.response.redirect(self.context_url)
     if 'form.button.Submit' in self.request:
         self.errors = {}
         item = self.request.get('item.uuid', None)
         quantity = self.request.get('item.quantity', None)
         form = self.request.form
         idx = 0
         for item in form:
             if item not in unwanted:
                 fieldname = item.split('.')
                 uuid = fieldname[0]
                 quantity = form[item]
                 if quantity is None or quantity is '':
                     self.errors[item] = _(u"Quantity must be given")
                 else:
                     updater = getUtility(ICartUpdaterUtility)
                     updater.add(uuid, quantity)
                     idx += 1
         IStatusMessage(self.request).add(
             _(u"%s cart items successfully updated") % idx,
             type="info")
         redirect_url = self.context_url + '/@@cart'
         return self.request.response.redirect(redirect_url)