Add order status email notifications and templates

Introduces email notifications for order status changes (created, cancelled, completed, paid, missing payment, refund events) and adds corresponding HTML email templates. Refactors notification tasks to use only the order object and updates model logic to trigger notifications on relevant status changes.
This commit is contained in:
2026-01-25 22:21:00 +01:00
parent 679cff2366
commit ca62e8895a
11 changed files with 544 additions and 61 deletions

View File

@@ -0,0 +1,49 @@
<h3 style="color:#5cb85c; font-size:18px; margin-top:0;">✓ Your Order is Ready for Pickup!</h3>
<p>Dear {{ order.first_name }} {{ order.last_name }},</p>
<p>Excellent news! Your order is now ready for pickup. You can collect your package at your convenience during store hours.</p>
<h4 style="color:#333; margin-top:20px; margin-bottom:10px;">Pickup Information</h4>
<table width="100%" cellpadding="8" cellspacing="0" style="border-collapse:collapse;">
<tr style="border-bottom:1px solid #ddd;">
<td style="padding:8px; font-weight:bold;">Order ID:</td>
<td style="padding:8px;">{{ order.id }}</td>
</tr>
<tr style="border-bottom:1px solid #ddd;">
<td style="padding:8px; font-weight:bold;">Ready Since:</td>
<td style="padding:8px;">{{ order.carrier.updated_at|date:"d.m.Y H:i" }}</td>
</tr>
<tr>
<td style="padding:8px; font-weight:bold;">Pickup Location:</td>
<td style="padding:8px;">Our Store</td>
</tr>
</table>
<h4 style="color:#333; margin-top:20px; margin-bottom:10px;">Order Items</h4>
<table width="100%" cellpadding="10" cellspacing="0" border="1" style="border-collapse:collapse; border-color:#ddd;">
<thead>
<tr style="background-color:#f9f9f9;">
<th style="text-align:left; padding:10px; border:1px solid #ddd;">Product</th>
<th style="text-align:center; padding:10px; border:1px solid #ddd;">Qty</th>
<th style="text-align:right; padding:10px; border:1px solid #ddd;">Price</th>
</tr>
</thead>
<tbody>
{% for item in order.items.all %}
<tr>
<td style="padding:10px; border:1px solid #ddd;">{{ item.product.name }}</td>
<td style="text-align:center; padding:10px; border:1px solid #ddd;">{{ item.quantity }}</td>
<td style="text-align:right; padding:10px; border:1px solid #ddd;">{{ item.get_total_price }} {{ order.get_currency }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<p style="margin-top:20px; padding:15px; background-color:#f0f8f0; border-left:4px solid #5cb85c;">
<strong>What to Bring:</strong> Please bring a valid ID and your order confirmation (this email). Your package is being held for you and will be released upon presentation of these documents.
</p>
<p style="margin-top:20px; color:#666;">
Thank you for your business! If you have any questions, please don't hesitate to contact us.
</p>

View File

@@ -0,0 +1,55 @@
<h3 style="color:#5cb85c; font-size:18px; margin-top:0;">📦 Your Package is on its Way!</h3>
<p>Dear {{ order.first_name }} {{ order.last_name }},</p>
<p>Great news! Your order has been shipped via Zásilkovna and is on its way to you.</p>
<h4 style="color:#333; margin-top:20px; margin-bottom:10px;">Shipping Information</h4>
<table width="100%" cellpadding="8" cellspacing="0" style="border-collapse:collapse;">
<tr style="border-bottom:1px solid #ddd;">
<td style="padding:8px; font-weight:bold;">Order ID:</td>
<td style="padding:8px;">{{ order.id }}</td>
</tr>
<tr style="border-bottom:1px solid #ddd;">
<td style="padding:8px; font-weight:bold;">Carrier:</td>
<td style="padding:8px;">Zásilkovna</td>
</tr>
<tr style="border-bottom:1px solid #ddd;">
<td style="padding:8px; font-weight:bold;">Shipped Date:</td>
<td style="padding:8px;">{{ order.carrier.updated_at|date:"d.m.Y H:i" }}</td>
</tr>
</table>
<h4 style="color:#333; margin-top:20px; margin-bottom:10px;">Delivery Instructions</h4>
<p>Your package will be delivered to your selected Zásilkovna pickup point. You will receive an SMS/email notification from Zásilkovna when the package arrives at the pickup point.</p>
<h4 style="color:#333; margin-top:20px; margin-bottom:10px;">Order Items</h4>
<table width="100%" cellpadding="10" cellspacing="0" border="1" style="border-collapse:collapse; border-color:#ddd;">
<thead>
<tr style="background-color:#f9f9f9;">
<th style="text-align:left; padding:10px; border:1px solid #ddd;">Product</th>
<th style="text-align:center; padding:10px; border:1px solid #ddd;">Qty</th>
<th style="text-align:right; padding:10px; border:1px solid #ddd;">Price</th>
</tr>
</thead>
<tbody>
{% for item in order.items.all %}
<tr>
<td style="padding:10px; border:1px solid #ddd;">{{ item.product.name }}</td>
<td style="text-align:center; padding:10px; border:1px solid #ddd;">{{ item.quantity }}</td>
<td style="text-align:right; padding:10px; border:1px solid #ddd;">{{ item.get_total_price }} {{ order.get_currency }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<p style="margin-top:20px; padding:15px; background-color:#f9f9f9; border-left:4px solid #5cb85c;">
<strong>Delivery Address:</strong><br>
{{ order.first_name }} {{ order.last_name }}<br>
{{ order.address }}<br>
{{ order.postal_code }} {{ order.city }}
</p>
<p style="margin-top:20px; color:#666;">
You can track your package on the Zásilkovna website. If you have any questions, please contact us.
</p>