2

We have the following two attributes that are used in our transactional emails:

  • {{supplier_qty}}
  • {{qty}}

We would like to output the result of: {{supplier_qty * qty}}

For example, 5 * 1 = 5 (so 5 should be the resulting output).

How can we do this in Magento variables?

2

An option could be that you add a block to your email template so that you can calculate the items in the block. You can do that by adding the following to your email template:

{{layout handle="modulename_email_items" supplier={{supplier_qty}} qty={{qty}}}}

Then in your layout.xml file in your theme add the following:

<modulename_email_items>
        <block type="core/template" name="items" template="modulename/email/items.phtml"/>
    </modulename_email_items>

Then in your template specified above modulename/email/items.phtml add the look at calculating it there:

<table cellspacing="0" cellpadding="0" border="0" width="600">        
    <tbody>
        <tr>
           <td>
              <?php if ($supplierQty = $this->getSupplierQty() && $qty = $this->getQty()) : ?>
                 Qty: $supplierQty * $qty
              <?php endif ?>
          </td>
       </tr>
    </tbody>
</table>
| improve this answer | |

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.