Пример #1
0
 def _process_order(self, data):
     pstate = getMultiAdapter((self.context, self.request), name=u"plone_portal_state")
     portal_url = pstate.portal_url()
     settings = self._payment_settings()
     cart = get_cart()
     txn = cart["txn_id"]
     orderinfo = txn[self.txnid]
     txnid = self._generate_txn_id()
     txn_id = self._url_quote(txnid)
     success_url = portal_url + "/@@order-processed?oid=" + txn_id
     mto = settings["shop_email"]
     envelope_from = orderinfo["billing.email"]
     if data["enquiry"] is None:
         order_type = _(u"Order")
     else:
         order_type = _(u"Enquiry")
     subject = _(u"Chromsystems Shop: %s") % order_type
     options = orderinfo
     cart = self.cart()
     options["cartitems"] = cart
     body = ViewPageTemplateFile("enquiry_mail.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")
     return self.request.response.redirect(success_url)
Пример #2
0
 def get_default(self, name):
     cart = get_cart()
     address = cart['txn_id']
     data = address.values()[0]
     try:
         value = data[name]
     except TypeError:
         value = ''
     return value
Пример #3
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']
     txnid = txn_id[0]
     if self.is_equal(order_id, txnid):
         self.next_url = here_url + '/@@order-confirmation?txnid=' + txn_id
         wipe_cart()
Пример #4
0
 def cart(self):
     cart = get_cart()
     data = []
     for item in cart:
         if item != "txn_id":
             info = {}
             product = uuidToObject(item)
             quantity = cart[item]
             info["uuid"] = item
             info["quantity"] = quantity
             info["title"] = self.localized_value(product, fieldname="title")
             info["detail"] = self.localized_value(product, fieldname="details")
             info["oid"] = product.productCode
             info["url"] = product.absolute_url()
             data.append(info)
     return data
Пример #5
0
 def cart(self):
     cart = get_cart()
     data = []
     for item in cart:
         if item != 'txn_id':
             info = {}
             product = uuidToObject(item)
             quantity = cart[item]
             info['uuid'] = item
             info['quantity'] = quantity
             info['title'] = self.localized_value(product,
                                                  fieldname='title')
             info['detail'] = self.localized_value(product,
                                                   fieldname='details')
             info['oid'] = product.productCode
             info['url'] = product.absolute_url()
             data.append(info)
     return data
Пример #6
0
 def _storeCheckoutData(self, data):
     pstate = getMultiAdapter((self.context, self.request),
                              name=u"plone_portal_state")
     portal_url = pstate.portal_url()
     txn_id = self.get_txnid()
     cart = get_cart()
     address = cart['txn_id']
     order = address.values()[0]
     for item in data:
         order[item] = data[item]
     txn_data = {}
     txn_data[txn_id] = order
     updater = getUtility(ICartUpdaterUtility)
     updater.mark(txn_data)
     IStatusMessage(self.request).add(
         _(u"Billing address successfully updated"),
         type='info')
     success_url = portal_url + '/@@checkout?txnid=' + txn_id
     return self.request.response.redirect(success_url)
Пример #7
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
         if product:
             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
Пример #8
0
 def has_cart(self):
     cart = get_cart()
     return len(cart) > 0
Пример #9
0
 def address_information(self):
     cart = get_cart()
     address = cart["txn_id"]
     return address[self.txnid]
Пример #10
0
 def get_txnid(self):
     cart = get_cart()
     address = cart['txn_id']
     tid = address.keys()[0]
     return tid
Пример #11
0
 def has_txn_info(self):
     cart = get_cart()
     info = False
     if 'txn_id' in cart:
         info = True
     return info
Пример #12
0
 def address_information(self):
     cart = get_cart()
     address = cart['txn_id']
     return address.keys()[0]