Skip to content

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

update confirm fulfillment email for digital products

Maciej Korycinski944989bd2881
diff --git a/saleor/order/emails.py b/saleor/order/emails.py
index 63a0fe5257..590829b7fb 100644
--- a/saleor/order/emails.py
+++ b/saleor/order/emails.py
@@ -41,7 +41,13 @@ def collect_data_for_email(order_pk, template):
def collect_data_for_fullfillment_email(order_pk, template, fulfillment_pk):
fulfillment = Fulfillment.objects.get(pk=fulfillment_pk)
email_data = collect_data_for_email(order_pk, template)
- email_data['context'].update({'fulfillment': fulfillment})
+ lines = fulfillment.lines.all()
+ physical_lines = [line for line in lines if not line.order_line.is_digital]
+ digital_lines = [line for line in lines if line.order_line.is_digital]
+ context = email_data['context']
+ context.update(
+ {'fulfillment': fulfillment, 'physical_lines': physical_lines,
+ 'digital_lines': digital_lines})
return email_data
diff --git a/templates/templated_email/order/confirm_fulfillment.email b/templates/templated_email/order/confirm_fulfillment.email
index f181be81b1..9cceac876c 100644
--- a/templates/templated_email/order/confirm_fulfillment.email
+++ b/templates/templated_email/order/confirm_fulfillment.email
@@ -2,14 +2,14 @@
{% block subject %}
{% blocktrans trimmed with order=fulfillment.order context "Fulfillment confirmation email subject" %}
- A shipment from order {{ order }} is on the way
+ Your order {{ order }} has been fulfilled
{% endblocktrans %}
{% endblock %}
{% block plain %}
{% include 'templated_email/shared/_header.email' %}
{% blocktrans context "Fulfillment confirmation email text" %}
-Thank you for your order. Below is the list of shipped products.
+Thank you for your order. Below is the list of fulfilled products.
{% endblocktrans %}
{% if fulfillment.tracking_number %}
{% blocktrans trimmed with tracking_number=fulfillment.tracking_number context "Fulfillment confirmation email text" %}
@@ -17,10 +17,14 @@ You can track your shipment with {{ tracking_number }} code.
{% endblocktrans %}
{% endif %}
-{% for line in fulfillment %}
+{% for line in physical_lines %}
{{ line.quantity }} x {{ line.order_line.product_name }}
{% endfor %}
+{% for line in digital_lines %}
+{{ line.quantity }} x {{ line.order_line.digital_content_url.get_absolute_url }}
+{% endfor %}
+
{% include 'templated_email/shared/_footer.email' %}
{% endblock %}
diff --git a/templates/templated_email/source/confirm_fulfillment.mjml b/templates/templated_email/source/confirm_fulfillment.mjml
index bdec238874..e84837ef20 100644
--- a/templates/templated_email/source/confirm_fulfillment.mjml
+++ b/templates/templated_email/source/confirm_fulfillment.mjml
@@ -14,7 +14,7 @@
</mj-text>
<mj-text>
{% blocktrans trimmed context "Fulfillment confirmation email text" %}
- Thank you for your order. Below is the list of shipped products.
+ Thank you for your order. Below is the list of fulfilled products.
{% endblocktrans %}
{% if fulfillment.tracking_number %}
{% blocktrans trimmed with tracking_number=fulfillment.tracking_number context "Fulfillment confirmation email text" %}
@@ -22,6 +22,13 @@
{% endblocktrans %}
{% endif %}
</mj-text>
+ <mj-text>
+ {% if digital_lines %}
+ {% blocktrans trimmed context "Fulfillment digital products email text" %}
+ You can download your digital products by clicking in download link(s).
+ {% endblocktrans %}
+ {% endif %}
+ </mj-text>
</mj-column>
</mj-section>
<mj-include path="./partials/_fulfillment_lines.mjml" />
diff --git a/templates/templated_email/source/partials/_fulfillment_lines.mjml b/templates/templated_email/source/partials/_fulfillment_lines.mjml
index 33ee278704..37e967447b 100644
--- a/templates/templated_email/source/partials/_fulfillment_lines.mjml
+++ b/templates/templated_email/source/partials/_fulfillment_lines.mjml
@@ -1,20 +1,44 @@
<mj-section>
<mj-column>
- <mj-table>
- <thead class="table-header-row">
- <tr>
- <th style="text-align: left;">Item</th>
- <th style="text-align: right;">Quantity</th>
- </tr>
- </thead>
- <tbody>
- {% for line in fulfillment %}
- <tr class="table-item-row">
- <td>{{ line.order_line.translated_product_name|default:line.order_line.product_name }}</td>
- <td style="text-align: right;">{{ line.quantity }}</td>
- </tr>
- {% endfor %}
- </tbody>
- </mj-table>
+ <mj-text>
+ {% if physical_lines %}
+ <table style="width:100%">
+ <thead class="table-header-row">
+ <tr>
+ <th style="text-align: left;">Item</th>
+ <th style="text-align: right;">Quantity</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for line in fulfillment %}
+ <tr class="table-item-row">
+ <td>{{ line.order_line.translated_product_name|default:line.order_line.product_name }}</td>
+ <td style="text-align: right;">{{ line.quantity }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ {% endif %}
+ {% if digital_lines %}
+ <table style="width:100%">
+ <thead class="table-header-row">
+ <tr>
+ <th style="text-align: left;">Item</th>
+ <th style="text-align: right;">Download Link</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for line in fulfillment %}
+ <tr class="table-item-row">
+ <td>{{ line.order_line.translated_product_name|default:line.order_line.product_name }}</td>
+ <td style="text-align: right;">
+ <a href={{ line.order_line.digital_content_url.get_absolute_url }}>Link</a>
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ {% endif %}
+ </mj-text>
</mj-column>
</mj-section>