Skip to content

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

Add email markup to mail template

Pacu232062ee053d9
diff --git a/saleor/order/emails.py b/saleor/order/emails.py
index dc3902ca94..1cda8a8201 100644
--- a/saleor/order/emails.py
+++ b/saleor/order/emails.py
@@ -6,6 +6,7 @@ from templated_email import send_templated_mail
from ..core.utils import build_absolute_uri
from .models import Fulfillment, Order
+from .email_helpers import get_order_confirmation_schema
CONFIRM_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.py
index 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 settings
from django.contrib.sites.models import Site
from 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.email
index 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 %}