Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add confirmation emails sending in order & payment
Michal Ociepkaca35d64e919f
diff --git a/order/models.py b/order/models.pyindex 40750ea7fb..ea61c78fa4 100644--- a/order/models.py+++ b/order/models.py@@ -1,10 +1,13 @@+from communication.mail import send_emailfrom decimal import Decimalfrom django.conf import settings+from django.core.urlresolvers import reversefrom django.db import modelsfrom django.utils.translation import pgettext_lazyfrom django_prices.models import PriceFieldfrom prices import Pricefrom product.models import Product, Subtyped+from saleor.utils import build_absolute_urifrom satchless.item import ItemSet, ItemLinefrom userprofile.models import Addressfrom uuid import uuid4@@ -78,14 +81,20 @@ class Order(models.Model, ItemSet):def billing_full_name(self):return u'%s %s' % (self.billing_first_name, self.billing_last_name)- @models.permalinkdef get_absolute_url(self):- return ('order:details', (), {'token': self.token})+ return reverse('order:details', kwargs={'token': self.token})def get_delivery_total(self):return sum([group.price for group in self.groups.all()],Price(0, currency=settings.SATCHLESS_DEFAULT_CURRENCY))+ def send_confirmation_email(self):+ email = self.get_user_email()+ payment_url = build_absolute_uri(+ reverse('order:payment:index', kwargs={'token': self.token}))+ context = {'payment_url': payment_url}+ send_email(email, 'order/emails/confirm_email.txt', context)+class DeliveryGroup(Subtyped, ItemSet):diff --git a/payment/models.py b/payment/models.pyindex 660f39330b..9c47e46f33 100644--- a/payment/models.py+++ b/payment/models.py@@ -1,7 +1,9 @@+from communication.mail import send_emailfrom django.core.urlresolvers import reversefrom django.db import modelsfrom order.models import Orderfrom payments.models import BasePayment+from saleor.utils import build_absolute_uriclass Payment(BasePayment):@@ -14,3 +16,10 @@ class Payment(BasePayment):def get_success_url(self):return reverse('order:success', kwargs={'token': self.order.token})++ def send_confirmation_email(self):+ email = self.order.get_user_email()+ order_url = build_absolute_uri(+ reverse('order:details', kwargs={'token': self.order.token}))+ context = {'order_url': order_url}+ send_email(email, 'payment/emails/confirm_email.txt', context)