Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 def prettifyPrice(self, price):
     return format_price(price)
Exemplo n.º 6
0
 def cart_vat(self):
     total = self.cart_total()
     vat = total * 0.19
     return format_price(vat)
Exemplo n.º 7
0
 def cart_net(self):
     return format_price(self.cart_total())