Example #1
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
Example #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()
Example #3
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
Example #4
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)
Example #5
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
Example #6
0
 def has_txn_info(self):
     cart = get_cart()
     info = False
     if 'txn_id' in cart:
         info = True
     return info
Example #7
0
 def has_cart(self):
     cart = get_cart()
     return len(cart) > 0
Example #8
0
 def address_information(self):
     cart = get_cart()
     address = cart['txn_id']
     return address.keys()[0]
Example #9
0
 def get_txnid(self):
     cart = get_cart()
     address = cart['txn_id']
     tid = address.keys()[0]
     return tid
Example #10
0
 def address_information(self):
     cart = get_cart()
     address = cart['txn_id']
     return address[self.txnid]
Example #11
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]
     txn_id = self._url_quote(self.txnid)
     success_url = portal_url + '/@@order-processed?oid=' + txn_id
     envelope_from = orderinfo['billing.email']
     if data['enquiry'] is None:
         order_type = _(u"order")
         subject_en = 'Chromsystems Shop: Your order'
         subject_de = 'Chromsystems Shop: Ihre Bestellung'
         mailto = ('*****@*****.**',
                   '*****@*****.**')
         cart_headline_en = _(u"Ordered products")
         cart_headline_de = _(u"Von Ihnen bestellte Produkte:")
     else:
         order_type = _(u"quotation inquiry")
         subject_en = 'Chromsystems Shop: Your quotation inquiry'
         subject_de = 'Chromsystems Shop: Ihre Angebotsanfrage'
         mailto = ('*****@*****.**',
                   '*****@*****.**')
         cart_headline_en = _(u"For the following products you will get a "
                              u"quotation:")
         cart_headline_de = _(u"Zu folgenden Produkten werden wir Ihnen "
                              u"umgehend ein Angebot unterbreiten:")
     mto = settings['shop_email']  # edit for alternative email
     options = orderinfo
     options['order_type'] = order_type
     options['language'] = self.current_lang()
     cart = self.cart()
     options['cartitems'] = cart
     if self.current_lang() == 'de':
         subject = subject_de
         options['cart_headline'] = cart_headline_de
         body = ViewPageTemplateFile("ordermail_de.pt")(self, **options)
         msg = ViewPageTemplateFile("customermail_de.pt")(self, **options)
     else:
         subject = subject_en
         options['cart_headline'] = cart_headline_en
         body = ViewPageTemplateFile("ordermail_en.pt")(self, **options)
         msg = ViewPageTemplateFile("customermail_en.pt")(self, **options)
     # send email
     mailhost = getToolByName(self.context, 'MailHost')
     for address in mailto:
         mailhost.send(body,
                       mto=address,
                       mfrom=envelope_from,
                       subject=subject,
                       charset='utf-8')
     # send order confirmation
     mailhost.send(msg,
                   mto=envelope_from,
                   mfrom=mto,
                   subject=subject,
                   charset='utf-8')
     IStatusMessage(self.request).add(
         _(u"Your email has been forwarded."),
         type='info')
     return self.request.response.redirect(success_url)
Example #12
0
 def cart(self):
     cart = get_cart()
     if 'txn_id' in cart:
         return ''
     else:
         return cart