Magento – Add Unit Price To Order Email Template

magento-1.7magento-1.8magento-1.9magento-enterprise

In the email sent to customer for order confirmation, product unit price does not show. I did the following changes, but I am facing these issues,

  1. Order is being processed, but I am not being redirected to Thankyou page. Before implementing these codes, when I click Place Order it will redirected to Thank you page.
  2. No email confirmation as well, before implementing this code, I received email confirmation as well.
  3. When I click Place Order it does not take me to the next page which is Thank You page, instead it stays in the Place Order page, but the order is been processed shows in the admin section

1) app/design/frontend/base/default/template/email/order/items.phtml

I added Unit Price under SKU

<th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Unit Price') ?></th>


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

Below this line:

<td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;"><?php echo $this->htmlEscape($this->getSku($_item)) ?></td>

I added the following code:

 `<td align="center" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;">
<!-- Show Unit Price here -->
<?php
if ($this->helper('tax')->displaySalesPriceInclTax($_order->getStore())) {
$itemprice = $this->helper('checkout')->getPriceInclTax($_item) ;
echo $this->helper('checkout')->formatPrice($itemprice);
} else {
echo $this->helper('checkout')->formatPrice($_item->getPrice()) ;
}
?>
<!-- END UNIT PRICE -->
</td>`
  1. app/design/frontend/base/default/layout/sales.xml

In "sales_email_order_items", I changed the colspan from 3 to 4

<pre><code><action method="setLabelProperties"><value>colspan="3" align="right" style="padding:3px 9px"</value></action></code></pre>

and changed it to

<action method="setLabelProperties"><value>colspan="4" align="right" style="padding:3px 9px"</value></action>

Any help here? Thanks!

Best Answer

Add following code 




if($this->helper('tax')->displaySalesPriceInclTax($_order->getStore())) 
{
     $itemprice = $this->helper('checkout')->getPriceInclTax($_item) ;
     echo $this->helper('checkout')->formatPrice($itemprice);
} 
else 
{
    echo $this->helper('checkout')->formatPrice($_item->getPrice()) ;
}
Related Topic