Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add email markup to mail template
Pacu232062ee053d9
diff --git a/saleor/order/emails.py b/saleor/order/emails.pyindex dc3902ca94..1cda8a8201 100644--- a/saleor/order/emails.py+++ b/saleor/order/emails.py@@ -6,6 +6,7 @@ from templated_email import send_templated_mailfrom ..core.utils import build_absolute_urifrom .models import Fulfillment, Order+from .email_helpers import get_order_confirmation_schemaCONFIRM_ORDER_TEMPLATE = 'source/order/confirm_order'CONFIRM_FULFILLMENT_TEMPLATE = 'source/order/confirm_fulfillment'@@ -42,7 +43,9 @@ def collect_data_for_email(order_pk, template):def send_order_confirmation(order_pk):order = Order.objects.get(pk=order_pk)email_data = collect_data_for_email(order_pk, CONFIRM_ORDER_TEMPLATE)- email_data.update({'context': {'order': order}})+ email_markup = get_order_confirmation_schema(order)+ context = {'order': order, 'email_markup': email_markup}+ email_data.update({'context': context})_send_confirmation(**email_data)diff --git a/saleor/order/emails_helpers.py b/saleor/order/emails_helpers.pyindex 9135a9ac8f..b22f2a2a94 100644--- a/saleor/order/emails_helpers.py+++ b/saleor/order/emails_helpers.py@@ -1,6 +1,5 @@import json-from django.conf import settingsfrom django.contrib.sites.models import Sitefrom django.core.serializers.json import DjangoJSONEncoder@@ -41,7 +40,7 @@ def get_product_data(line, currency, organization):return product_data-def get_order_confirmation_schema(order):+def get_order_confirmation_markup(order):"""Generates schema.org markup for order confirmation e-mail message."""organization = get_organization()order_url = build_absolute_uri(order.get_absolute_url())diff --git a/templates/templated_email/source/order/confirm_order.email b/templates/templated_email/source/order/confirm_order.emailindex 449844c66f..92445130a6 100644--- a/templates/templated_email/source/order/confirm_order.email+++ b/templates/templated_email/source/order/confirm_order.email@@ -35,4 +35,5 @@ Sincerely,{% block html %}{% include 'templated_email/compiled/confirm_order.html' %}+<script type="application/ld+json">{{ email_markup|safe }}</script>{% endblock %}