I need to display points earned by customer on Order Information page under customer account.
module.xml
<sales_order_view>
<reference name="order_items">
<action method="addItemRender" ifconfig="mymodule/general/active"><type>default</type>
<block>sales/order_item_renderer_default</block>
<template>namespace/mymodule/sales/order/items/renderer/default.phtml</template>
</action>
</reference>
</sales_order_view>
Copied file from core - sales/order/items/renderer/default.phtml
to namespace/mymodule/sales/order/items/renderer/default.phtml
and along with default code, I added mine
<!--show points earned on each product-->
<?php $finalPointsEarned = ($_item->getCustomerProductPoints() * $_item->getQtyOrdered()); ?>
<div class="product-cart-sku">
<span style="color: #d4af37; font-weight: bold;"><?php echo $this->__('Points Earned:'); ?>
<?php echo $finalPointsEarned ?>
</span>
</div>
<!--show points earned on each product-->
As shown in below image, this is how points earned are shown
- Is this the correct approach/method to show custom data on Order Information page ?
- If not, how do I override
Sales/Order/Item/Rendered/Default
block to show the same without copying core file in my extension and then adding my code ?
Will it be same for below mentioned files too ?
sales/order/invoice/items/renderer/
sales/order/shipment/items/renderer/
sales/order/creditmemo/items/renderer/
Also, I am showing the same information in admin section by copying files in my extension
adminhtml\default\default\template\namespace\modulename\sales\order\total.phtml
P.S. The files belongs to community extension
EDIT AS PER CUSTOM BLOCK CREATION
config.xml
<global>
<blocks>
<productpoint>
<class>Namespace_Modulename_Block</class>
</productpoint>
<sales>
<rewrite>
<order_item_renderer_default>Namespace_Modulename_Block_Sales_Order_Item_Renderer_Default</order_item_renderer_default>
</rewrite>
</sales>
</blocks>
</global>
points.xml
<sales_order_invoice>
<reference name="invoice_items">
<block type="core/text_list" name="invoice.productpoints.info" translate="label">
<label>Additional Points Info</label>
</block>
</reference>
</sales_order_invoice>
Sales/Order/Item/Renderer/Default.php
<?php
class Namespace_Modulename_Block_Sales_Order_Item_Renderer_Default extends Mage_Sales_Block_Order_Item_Renderer_Default
{
public function getInvoiceProductPoints()
{
parent::getItem();
$_item = $this->getItem();
$finalPointsEarned = ($_item->getCustomerProductPoints() * $_item->getQty());
return $finalPointsEarned;
}
}
sales/order/items/renderer/default.phtml
<?php $addInfoBlock = $this->getInvoiceProductPoints(); ?>
<?php if ($addInfoBlock): ?>
<?php echo $addInfoBlock ?>
<?php endif;?>