Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add email notification in storefront

akjanikd620424c478d
diff --git a/saleor/order/emails.py b/saleor/order/emails.py
index 3cb91fb677..858273572f 100644
--- a/saleor/order/emails.py
+++ b/saleor/order/emails.py
@@ -5,23 +5,29 @@ from templated_email import send_templated_mail
CONFIRM_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 file
diff --git a/saleor/order/views.py b/saleor/order/views.py
index f4a105c03e..eff6c1e520 100644
--- a/saleor/order/views.py
+++ b/saleor/order/views.py
@@ -7,14 +7,16 @@ from django.db import transaction
from django.http import Http404, HttpResponseForbidden, HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect
from django.template.response import TemplateResponse
+from django.urls import reverse
from django.utils.translation import pgettext_lazy
from payments import PaymentStatus, RedirectNeeded
+from .emails import send_note_confirmation
from .forms import PaymentDeleteForm, PaymentMethodsForm, PasswordForm
from .models import Order, Payment
from .utils import attach_order_to_user, check_order_status
from ..checkout.forms import NoteForm
-from ..core.utils import get_client_ip
+from ..core.utils import get_client_ip, build_absolute_uri
from ..registration.forms import LoginForm
from ..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.email
index 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.email
index 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 %}