Question

When a customer places an order they receive an order confirmation email. In that email - below where the line items are displayed - the Subtotal, Shipping & Handling and Grand Total are outputted.

enter image description here

What I'm trying to do is show that same thing on the shipping notification email. I'm a magento newb, so what I typically do is find the core template that handles this and copy it into my local folder to make the changes.

So I copied : app/design/frontend/base/default/template/email/order/shipment/items.phtml

to: app/design/frontend/default/mytheme/template/email/order/shipment/items.phtml

Here's what that file looks like (with some of my customizations already):

<?php $_shipment = $this->getShipment() ?>
<?php $_order    = $this->getOrder() ?>
<?php if ($_shipment && $_order): ?>
<table cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
    <thead>
        <tr>
            <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px">Item #</th>
            <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Item Name') ?></th>
            <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px;text-align:center;">Unit <br />Price</th>
            <th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px;text-align:center;">Shipped<br />Quantity</th>
            <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px;;text-align:center;">UOM</th>
        </tr>
    </thead>

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

When I look in the file app/design/frontend/base/default/template/email/order/invoice/items.phtml which has the totals I want to display on the shipping template, it looks like the portion of code that controls it is here:

<tfoot>
    <?php echo $this->getChildHtml('invoice_totals')?>
</tfoot>

So I've pasted that into my shipping items.phtml but the totals are not displaying. Can anyone point me in the right direction? I feel like I'm close but am still missing something.

Was it helpful?

Solution

Found out the issue. I should not have been using the code sample from app/design/frontend/base/default/template/email/order/invoice/items.phtml but should have used this snippet of code

<tfoot>
    <?php echo $this->getChildHtml('order_totals')?>
</tfoot>

from here app/design/frontend/base/default/template/email/order/items.phtml

In addition to that, my sales.xml file had to be modified, specifically the <sales_email_order_shipment_items> block to mimic what is found in <sales_email_order_items>:

<sales_email_order_shipment_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="sales/order_totals" name="order_totals" template="sales/order/totals.phtml">
            <action method="setLabelProperties"><value>colspan="5" 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 type="core/text_list" name="additional.product.info" />
</sales_email_order_shipment_items>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top