def sendRecommendation(self): """ """ if self.request.get("email", "") == "": utool = getToolByName(self.context, "plone_utils") utool.addPortalMessage(_("Please add a e-mail address.")) url = "%s/thank-you" % self.context.absolute_url() else: # Get charset props = getToolByName(self.context, "portal_properties").site_properties charset = props.getProperty("default_charset") template = getMultiAdapter((self.context, self.request), name="send-recommendation-template") text = template() sendMultipartMail( context=self.context, from_=self.context.getMailFrom(), to=self.request.get("email"), subject="Empfehlung Demmelhuber Holz und Raum GmbH", text=text, charset=charset) utool = getToolByName(self.context, "plone_utils") utool.addPortalMessage(_("Your mail has been sent.")) url = "%s/thank-you" % self.context.absolute_url() self.request.response.redirect(url)
def mailOrderSubmitted(order): """Sends email to shop owner that an order has been submitted. """ shop = IShopManagement(order).getShop() # Get sender and receiver mail_addresses = IMailAddresses(shop) sender = mail_addresses.getSender() receivers = mail_addresses.getReceivers() if sender and receivers: view = getMultiAdapter((order, order.REQUEST), name="mail-order-submitted") text = view() # get charset props = getToolByName(order, "portal_properties").site_properties charset = props.getProperty("default_charset") sendMultipartMail( context=order, sender=sender, receiver=", ".join(receivers), subject="E-Shop: New order", text=text, charset=charset, )
def sendRecommendation(self): """ """ if self.request.get("email", "") == "": utool = getToolByName(self.context, "plone_utils") utool.addPortalMessage(_("Please add a e-mail address.")) url = "%s/thank-you" % self.context.absolute_url() else: # Get charset props = getToolByName(self.context, "portal_properties").site_properties charset = props.getProperty("default_charset") template = getMultiAdapter((self.context, self.request), name="send-recommendation-template") text = template() sendMultipartMail( context=self.context, from_=self.context.getMailFrom(), to=self.request.get("email"), subject="Empfehlung Demmelhuber Holz und Raum GmbH", text=text, charset=charset, ) utool = getToolByName(self.context, "plone_utils") utool.addPortalMessage(_("Your mail has been sent.")) url = "%s/thank-you" % self.context.absolute_url() self.request.response.redirect(url)
def mailOrderSent(order): """Sends email to customer that the order has been sent. """ shop = IShopManagement(order).getShop() # Get mail content view = getMultiAdapter((order, order.REQUEST), name="mail-order-sent") text = view() # Get customer customer = order.getCustomer() # Get charset props = getToolByName(order, "portal_properties").site_properties charset = props.getProperty("default_charset") # Get sender sender = IMailAddresses(shop).getSender() sendMultipartMail( context=order, sender=sender, receiver=customer.email, subject="Your order %s has been sent." % order.getId(), text=text, charset=charset, )
def mailOrderSubmitted(order): """Sends email to shop owner that an order has been submitted. """ shop = IShopManagement(order).getShop() # Get sender and receiver mail_addresses = IMailAddresses(shop) sender = mail_addresses.getSender() receivers = mail_addresses.getReceivers() if sender and receivers: view = getMultiAdapter((order, order.REQUEST), name="mail-order-submitted") text = view() # get charset props = getToolByName(order, "portal_properties").site_properties charset = props.getProperty("default_charset") sendMultipartMail(context=order, sender=sender, receiver=", ".join(receivers), subject="E-Shop: New order", text=text, charset=charset)
def mailOrderSent(order): """Sends email to customer that the order has been sent. """ shop = IShopManagement(order).getShop() # Get mail content view = getMultiAdapter((order, order.REQUEST), name="mail-order-sent") text = view() # Get customer customer = order.getCustomer() # Get charset props = getToolByName(order, "portal_properties").site_properties charset = props.getProperty("default_charset") # Get sender sender = IMailAddresses(shop).getSender() sendMultipartMail(context=order, sender=sender, receiver=customer.email, subject="Your order %s has been sent." % order.getId(), text=text, charset=charset)
def send_rating_mails(self): """ """ live = self.request.get("live") now = DateTime() # Get sender mail_addresses = IMailAddresses(self.context) sender = mail_addresses.getSender() bcc = ["*****@*****.**", "*****@*****.**"] wftool = getToolByName(self.context, "portal_workflow") # Get all relevant orders om = IOrderManagement(self.context) for order in om.getOrders(): # Send mail only once (below "rating-mail" is set) if "rating-mail" in order.getMarketingInfo(): continue try: last_state = wftool.getInfoFor(order, "review_history")[-1] except IndexError: continue # Send mail only for closed orders if last_state["review_state"] != "closed": continue # Send only mails for orders which closed at lease2 weeks # ago if now - last_state["time"] < (2 * 7): continue # Send only mails for orders which have at least on product with # a valid url (aka product which is not deleted in the meanwhile) if self.hasItems(order) == False: continue if live is None: receiver = "*****@*****.**" if sender and receiver: view = getMultiAdapter((order, order.REQUEST), name="rating-mail") text = view() # get charset props = getToolByName(order, "portal_properties").site_properties charset = props.getProperty("default_charset") sendMultipartMail(context=order, sender=sender, receiver=receiver, subject="Bitte bewerten Sie Ihr Produkt", text=text, charset=charset) else: # Get receiver customer = order.getCustomer() address = IAddressManagement(customer).getShippingAddress() receiver = address.email if sender and receiver: view = getMultiAdapter((order, order.REQUEST), name="rating-mail") text = view() # get charset props = getToolByName(order, "portal_properties").site_properties charset = props.getProperty("default_charset") sendMultipartMail(context=order, sender=sender, receiver=receiver, bcc=bcc, subject="Bitte bewerten Sie Ihr Produkt", text=text, charset=charset) # set marketing info mi = list(order.getMarketingInfo()) mi.append("rating-mail") order.setMarketingInfo(mi)
def send_rating_mails(self): """ """ live = self.request.get("live") now = DateTime() # Get sender mail_addresses = IMailAddresses(self.context) sender = mail_addresses.getSender() bcc = ["*****@*****.**", "*****@*****.**"] wftool = getToolByName(self.context, "portal_workflow") # Get all relevant orders om = IOrderManagement(self.context) for order in om.getOrders(): # Send mail only once (below "rating-mail" is set) if "rating-mail" in order.getMarketingInfo(): continue try: last_state = wftool.getInfoFor(order, "review_history")[-1] except IndexError: continue # Send mail only for closed orders if last_state["review_state"] != "closed": continue # Send only mails for orders which closed at lease2 weeks # ago if now - last_state["time"] < (2*7): continue # Send only mails for orders which have at least on product with # a valid url (aka product which is not deleted in the meanwhile) if self.hasItems(order) == False: continue if live is None: receiver = "*****@*****.**" if sender and receiver: view = getMultiAdapter((order, order.REQUEST), name="rating-mail") text = view() # get charset props = getToolByName(order, "portal_properties").site_properties charset = props.getProperty("default_charset") sendMultipartMail( context = order, sender = sender, receiver = receiver, subject = "Bitte bewerten Sie Ihr Produkt", text = text, charset = charset) else: # Get receiver customer = order.getCustomer() address = IAddressManagement(customer).getShippingAddress() receiver = address.email if sender and receiver: view = getMultiAdapter((order, order.REQUEST), name="rating-mail") text = view() # get charset props = getToolByName(order, "portal_properties").site_properties charset = props.getProperty("default_charset") sendMultipartMail( context = order, sender = sender, receiver = receiver, bcc = bcc, subject = "Bitte bewerten Sie Ihr Produkt", text = text, charset = charset) # set marketing info mi = list(order.getMarketingInfo()) mi.append("rating-mail") order.setMarketingInfo(mi)