Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add email notification in storefront
akjanikd620424c478d
diff --git a/saleor/order/emails.py b/saleor/order/emails.pyindex 3cb91fb677..858273572f 100644--- a/saleor/order/emails.py+++ b/saleor/order/emails.py@@ -5,23 +5,29 @@ from templated_email import send_templated_mailCONFIRM_ORDER_TEMPLATE = 'order/confirm_order'CONFIRM_PAYMENT_TEMPLATE = 'order/payment/confirm_payment'+CONFIRM_NOTE_TEMPLATE = 'order/note/confirm_note'-def _send_confirmation(address, url, template):+def _send_confirmation(email, url, template):site = Site.objects.get_current()send_templated_mail(from_email=settings.ORDER_FROM_EMAIL,- recipient_list=[address],+ recipient_list=[email],context={'site_name': site.name,'url': url},template_name=template)@shared_task-def send_order_confirmation(address, url):- _send_confirmation(address, url, CONFIRM_ORDER_TEMPLATE)+def send_order_confirmation(email, url):+ _send_confirmation(email, url, CONFIRM_ORDER_TEMPLATE)@shared_task-def send_payment_confirmation(address, url):- _send_confirmation(address, url, CONFIRM_PAYMENT_TEMPLATE)+def send_payment_confirmation(email, url):+ _send_confirmation(email, url, CONFIRM_PAYMENT_TEMPLATE)+++@shared_task+def send_note_confirmation(email, url):+ _send_confirmation(email, url, CONFIRM_NOTE_TEMPLATE)\ No newline at end of filediff --git a/saleor/order/views.py b/saleor/order/views.pyindex f4a105c03e..eff6c1e520 100644--- a/saleor/order/views.py+++ b/saleor/order/views.py@@ -7,14 +7,16 @@ from django.db import transactionfrom django.http import Http404, HttpResponseForbidden, HttpResponseRedirectfrom django.shortcuts import get_object_or_404, redirectfrom django.template.response import TemplateResponse+from django.urls import reversefrom django.utils.translation import pgettext_lazyfrom payments import PaymentStatus, RedirectNeeded+from .emails import send_note_confirmationfrom .forms import PaymentDeleteForm, PaymentMethodsForm, PasswordFormfrom .models import Order, Paymentfrom .utils import attach_order_to_user, check_order_statusfrom ..checkout.forms import NoteForm-from ..core.utils import get_client_ip+from ..core.utils import get_client_ip, build_absolute_urifrom ..registration.forms import LoginFormfrom ..userprofile.models import User@@ -35,12 +37,17 @@ def details(request, token):order.notes.create(user=request.user,content=note_form.cleaned_data.get('note', ''))+ order_url = build_absolute_uri(+ reverse('order:details', kwargs={'token': order.token}))+ email = order.get_user_current_email()+ send_note_confirmation.delay(email, order_url)return HttpResponseRedirect(request.META.get('HTTP_REFERER'))- return TemplateResponse(request, 'order/details.html', {- 'order': order,- 'groups': groups,- 'notes': notes,- 'note_form': note_form})+ ctx = {+ 'order': order,+ 'groups': groups,+ 'notes': notes,+ 'note_form': note_form}+ return TemplateResponse(request, 'order/details.html', ctx)def payment(request, token):diff --git a/templates/templated_email/order/confirm_order.email b/templates/templated_email/order/confirm_order.emailindex 2b174f6387..ea7b55da97 100644--- a/templates/templated_email/order/confirm_order.email+++ b/templates/templated_email/order/confirm_order.email@@ -11,6 +11,8 @@ Hi!Thank you for your order. To see your payment details please visit:{{ url }}+This is an automatically generated email, please do not reply.+Sincerely,{{ site_name }}{% endblocktrans %}diff --git a/templates/templated_email/order/payment/confirm_payment.email b/templates/templated_email/order/payment/confirm_payment.emailindex f890526d6c..6f4b52380b 100644--- a/templates/templated_email/order/payment/confirm_payment.email+++ b/templates/templated_email/order/payment/confirm_payment.email@@ -11,6 +11,8 @@ Hi!Thank you for your payment. To see your payment details please visit:{{ url }}+This is an automatically generated email, please do not reply.+Sincerely,{{ site_name }}{% endblocktrans %}