Editing Magento Order Confirmation Email: Removing Shipping & Grand Total Lines
So you’re looking to modify your Magento order confirmation email templates? Specifically, you want to remove the shipping and grand total lines, keeping only the subtotal. I’ll guide you through this process step-by-step.
Identifying the Relevant Template
First things first - let’s find the right template file for your task. In Magento, order confirmation emails are controlled by two templates: one for registered users (sales_email_order_items.html) and another for guest customers (sales_email_order_guest_items.html).
You can usually locate these files under:
app/design/frontend/<your_theme>/template/email/
However, if you’ve overridden the Magento core with your own module or theme, they might be located in a different path. Use the following command to find them:
grep -r "sales_email_order_items.html" app/
Replace app with the path of your Magento root directory.
Editing the Templates
Once you’ve identified the correct files, open them up for editing. In both templates, look for this block of code:
<item_options>
<table class="item-options">
<tr>
<th><?= $this->__('Item Options') ?></th>
<td><?= $this->escapeHtml($item->getDescription()) ?></td>
</tr>
</table>
</item_options>
<table class="order-item-table">
<col width="20%" />
<col width="80%" />
<tr>
<th><?= $this->__('Item') ?></th>
<td><?= $this->escapeHtml($item->getName()) ?></td>
</tr>
<tr>
<th><?= $this->__('SKU') ?></th>
<td><?= $item->getSku() ?></td>
</tr>
<tr>
<th><?= $this->__('Qty') ?></th>
<td><?= $item->getQtyOrdered() ?></td>
</tr>
<tr>
<th><?= $this->__('Subtotal') ?></th>
<td><?= $this->helper('tax')->formatPrice($item->getRowTotal()) ?></td>
</tr>
</table>
This is the core structure for displaying the order items, including subtotal.
Removing Shipping & Grand Total Lines
To remove the shipping and grand total lines, you’ll need to target these sections:
<tr>
<th><?= $this->__('Shipping') ?></th>
<td><?= $this->helper('tax')->formatPrice($item->getShippingAmount()) ?></td>
</tr>
And either:
<tr>
<th><?= $this->__('Subtotal') ?></th>
<td><?= $this->helper('tax')->formatPrice($order->getSubtotal()) ?></td>
</tr>
Or:
<tr>
<th><?= $this->__('Grand Total') ?></th>
<td><?= $this->helper('tax')->formatPrice($order->getGrandTotal()) ?></td>
</tr>
Simply delete or comment out these lines. Remember, for the grand total line, you’ll need to target it in both the sales_email_order_items.html and sales_email_order_guest_items.html files.
Saving Your Changes
After making your edits, save the files. Magento will now send order confirmation emails without the shipping and grand total lines for registered users and guest customers.
Remember, if you want to make this change permanent across upgrades or theme switches, consider using a custom module. This can be created using Magento’s extension development guide available here.
Conclusion
Editing the Magento order confirmation email is straightforward once you know where to look. By targeting the right template files and removing the unwanted lines, you can create a clean, concise email experience for your customers.
Don’t forget to test your changes thoroughly before pushing them live.
Happy coding!