1

I'm trying to change something in Magento's automatic email.

The text of {{layout handle="sales_email_order_items" order=$order}} is this one :

Subtotal : xx € Shipping & Handling : xx € (...)

I wanna change the text label in this variable and in other of email template. Unfortunetly, I can't find how to change label 'Subtotal' (or any other), do someone know how I can do it ?

Thank's a lot ;)

6

This is how you can find out, where the text comes from:

First: use grep to search for the layout handle sales_email_order_items in the magento codebase.

You will find some files like app/design/frontend/base/default/layout/sales.xml where the template is defined:

<!--
Email layouts section
-->
    <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="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 type="core/text_list" name="additional.product.info" />
    </sales_email_order_items>

Have a look at the block in the middle <block type="sales/order_totals" name="order_totals" template="sales/order/totals.phtml">...</block>. If you open sales/order/totals.phtml you will see that this template contains the loop for the output of the totals. The totals itself come from Mage_Sales_Block_Order_Totals (check out the @see Mage_Sales_Block_Order_Totals block in the phtml-file.

The label itself is set in Mage_Sales_Block_Order_Totals. Draw your attention to the _initTotals method:

/**
     * Initialize order totals array
     *
     * @return Mage_Sales_Block_Order_Totals
     */
    protected function _initTotals()
    {
        $source = $this->getSource();

        $this->_totals = array();
        $this->_totals['subtotal'] = new Varien_Object(array(
            'code'  => 'subtotal',
            'value' => $source->getSubtotal(),
            'label' => $this->__('Subtotal')
        ));

     ...
    }

This means: The label is set in the _initTotals method of Mage_Sales_Block_Order_Totals. $this->_totals['subtotal'] = new Varien_Object(array( 'code' => 'subtotal', 'value' => $source->getSubtotal(), 'label' => $this->__('Subtotal') ));

The label is put into the template in sales/order/totals.phtml here:

     <td <?php echo $this->getLabelProperties()?>>
         <?php if ($_total->getStrong()):?>
         <strong><?php echo $this->escapeHtml($_total->getLabel());?></strong>
         <?php else:?>
         <?php echo $this->escapeHtml($_total->getLabel());?>
         <?php endif?>
     </td>

How to change the label?

If you want to change the labels in your shop globally I suggest you put it into your translation files (app/design/frontend/yourpackage/yourtheme/locale/en_US/translate.csv in your shop template OR in one of your shop base modules - if you have something like this).

If you only want to change the label in the e-mails, the easiest might be to define your own template for <block type="sales/order_invoice_totals" .... > ... </block>, for example:

<block type="sales/order_invoice_totals" name="invoice_totals" template="your/costom/template_for_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>

Why creating your own template file?

The template sales/order/totals.phtml is used quite often in different layout XML-files and you this will also change the label, wherever this template is used.

  • Thank's a lot =) – Malerick Nov 5 '14 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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