0
votes

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

Image

  1. Is this the correct approach/method to show custom data on Order Information page ?
  2. 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

1

1 Answers

0
votes

I think you follow standard way.

In order to override template file there are following way.

  1. Copy core template in your theme template file and then customize

  2. Create an extension and then override core template file in your extension

Second one is better when you either create an extension or theme for 3party users too.

First one is better when you have only your own store concern. is it up to you which one you would like to choose.

Thanks