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 cart_total(self): total = 0.0 for item in self.cart(): value = item['price'] value = value * int(item['quantity']) total = total + value return format_price(total)
def cart_shipping(self): shipping = 0.0 for item in self.cart(): value = item['shipping'] if value: shipping_value = value * int(item['quantity']) shipping = shipping + shipping_value return format_price(shipping)
def cart(self): cart = get_cart() data = [] for item in cart: info = {} product = uuidToObject(item) quantity = cart[item] info['uuid'] = item info['quantity'] = quantity info['title'] = product.Title() info['description'] = product.Description() info['image_tag'] = self.image_tag(product) info['url'] = product.absolute_url() info['price'] = product.price info['shipping'] = product.shipping_price info['price_pretty'] = format_price(product.price) total = int(quantity) * product.price info['price_total'] = format_price(total) data.append(info) return data
def prettifyPrice(self, price): return format_price(price)
def cart_vat(self): total = self.cart_total() vat = total * 0.19 return format_price(vat)
def cart_net(self): return format_price(self.cart_total())