0

I am trying to make my "New Order" email template to look like in the image below: enter image description here I want to include "Price" of each item excluding and including tax. Same applies to the subtotal.

Here is the current state of my "New Order" email template: enter image description here

I believe, I need to change the items.phtml file located in /app/design/frontend/base/default/template/email/order/items.phtml. Am I even looking in the right place?

1 Answer 1

1

The layout definition for the new order emails can be found at design/frontend/default/base/layout/sales.xml with the handle <sales_email_order_items>.

LAYOUT: app/design/frontend/base/default/layout/sales.xml

<sales_email_order_items>
    <block type="sales/order_email_items" name="items" template="email/order/items.phtml">
        <action method="addItemRender"><type>default</type><block>sales/order_email_items_order_default</block><template>email/order/items/order/default.phtml</template></action>
        <action method="addItemRender"><type>grouped</type><block>sales/order_email_items_order_grouped</block><template>email/order/items/order/default.phtml</template></action>
        <block type="core/template" name="order_totals_wrapper" as="order_totals" template="email/order/totals/wrapper.phtml">
            <block type="sales/order_totals" name="order_totals" template="sales/order/totals.phtml">
                <action method="setLabelProperties"><value>colspan="3" align="right" style="padding:3px 9px"</value></action>
                <action method="setValueProperties"><value>align="right" style="padding:3px 9px"</value></action>
                <block type="tax/sales_order_tax" name="tax" template="tax/order/tax.phtml">
                    <action method="setIsPlaneMode"><value>1</value></action>
                </block>
            </block>
        </block>
    </block>
    <block type="core/text_list" name="additional.product.info" />
</sales_email_order_items>

The first block declared is Mage_Sales_Block_Order_Email_Items (sales/order_email_items) and has the template email/order/items.phtml. This template controls the loop for rendering each of the order items.

TEMPLATE: app/design/frontend/base/default/template/email/order/items.phtml

<?php $i=0; foreach ($_order->getAllItems() as $_item): ?>
<?php if($_item->getParentItem()) continue; else $i++; ?>
<tbody<?php echo $i%2 ? ' bgcolor="#F6F6F6"' : '' ?>>
    <?php echo $this->getItemHtml($_item) ?> // Renders individual products
</tbody>
<?php endforeach; ?>

Mage_Sales_Block_Order_Email_Items::getItemHtml($_item) will get the relevant item renderer depending on the product type. In most cases this will be Mage_Sales_Block_Order_Email_Items_Order_Default which has the template app/design/frontend/base/default/template/email/order/items/order/default.phtml.

This is the template you should overwrite in your theme to modify the position of the table cells. In the template you will see that it has a number of conditions which check for price and tax display settings but does the majority of what you require already.

If you're using them, you might need to update the different product type renderer templates too.

4
  • wow. There is a lot more to it than I thought. Great answer. +1 from me. I'm just fighting my way through it and will accept once I manage to get it sorted :) Thank you for your interest.
    – Greg
    Commented May 18, 2018 at 8:47
  • I am having a bit of trouble trying to implement this to my template file... It would be greatly appreciated if you could guide me a little. I'm still a novice when it comes to things like this :/
    – Greg
    Commented May 18, 2018 at 9:14
  • I can certainly try, drop me an email at hello[at]adampaterson.co.uk Commented May 18, 2018 at 10:00
  • I have email you :) Although I mark this question as accepted. I got all the information that I needed from you :) Thanks!
    – Greg
    Commented May 18, 2018 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.