def _send_enquiry(self, data): pstate = getMultiAdapter((self.context, self.request), name=u"plone_portal_state") portal_url = pstate.portal_url() settings = self._payment_settings() txnid = self._generate_txn_id() txn_id = self._url_quote(txnid) shop_url = settings['shop_url'] base_url = portal_url + shop_url success_url = base_url + '/@@payment-processed?oid=' + txn_id mto = settings['shop_email'] envelope_from = data['email'] fullname = safe_unicode(data['fullname']) subject = _(u'Poleworkx Shop: Anfrage von %s') % fullname options = data cart = self.cart() options['cartitems'] = cart country = data['shipping.country'] shipping = self._calculate_shipping(country) net = self._calculate_cart_net(shipping) vat = self._calculate_cart_vat(net) options['cart_shipping'] = format_price(shipping) options['cart_vat'] = format_price(vat) options['cart_net'] = format_price(net) body = ViewPageTemplateFile("enquiry_email.pt")(self, **options) # send email mailhost = getToolByName(self.context, 'MailHost') mailhost.send(body, mto=mto, mfrom=envelope_from, subject=subject, charset='utf-8') IStatusMessage(self.request).add( _(u"Your email has been forwarded."), type='info') txn_item = self._update_cart_on_checkout(txn_id) if txn_item: return self.request.response.redirect(success_url)
def update(self): context = aq_inner(self.context) self.errors = {} unwanted = ('_authenticator', 'form.button.Submit', 'form.button.Enquiry') required = self.required_fields() if ('form.button.Submit' in self.request or 'form.button.Enquiry' in self.request): form = self.request.form authenticator = getMultiAdapter((context, self.request), name=u"authenticator") if not authenticator.verify(): raise Unauthorized formdata = {} formerrors = {} errorIdx = 0 for value in form: if value not in unwanted: formdata[value] = form[value] if value in required and not form[value]: error = {} error['active'] = True error['msg'] = _(u"This field is required") formerrors[value] = error errorIdx += 1 else: error = {} error['active'] = False error['msg'] = form[value] formerrors[value] = error formdata['enquiry'] = self.request.get('form.button.Enquiry', None) if errorIdx > 0: self.errors = formerrors else: self._process_payment(formdata)
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)
def update(self): context = aq_inner(self.request) self.context_url = context.absolute_url() item = self.request.get('item.uuid', None) qty = self.request.get('quantity', None) IStatusMessage(self.request).addStatusMessage( _(u"Add item to cart executed: %s %s ") % (item, qty), type="info") redirect_url = self.context_url() + '/@@cart' return self.request.response.redirect(redirect_url)
def update(self): context = aq_inner(self.context) #self.context_url = context.absolute_url() if 'form.button.Submit' in self.request: updater = getUtility(ICartUpdaterUtility) item_uuid = self.request.get('item_uuid', None) item = updater.delete(item_uuid) if not item: IStatusMessage(self.request).addStatusMessage( _(u"Item could not be removed from the shopping cart. " u"Please try again. If the error should persist, please " u"contact the shop owner"), type="error") return self.request.response.redirect(context.absolute_url()) else: IStatusMessage(self.request).addStatusMessage( _(u"Item has been removed from the shopping cart"), type="info") return_url = context.absolute_url() + '/@@cart' return self.request.response.redirect(return_url)
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)