0

I want to add a new column in customer's frontend where they can see also the discount amount.

http://example.com/sales/order/invoice/order_id/11111/ 

I would like to add the column in this table. enter image description here Thank you!

1 Answer 1

0

You need to modify following two templates:

app/design/frontend/rwd/default/template/sales/order/invoice/items.phtml

<?php $_order = $this->getOrder() ?> <p class="order-links"><a href="<?php echo $this->getPrintAllInvoicesUrl($_order) ?>" onclick="this.target='_blank'" class="link-print"><?php echo $this->__('Print All Invoices') ?></a></p> <?php foreach ($_order->getInvoiceCollection() as $_invoice): ?> <h2 class="sub-title"><?php echo $this->__('Invoice #') ?><?php echo $_invoice->getIncrementId(); ?> <span class="separator">|</span> <a href="<?php echo $this->getPrintInvoiceUrl($_invoice) ?>" onclick="this.target='_blank'" class="link-print"><?php echo $this->__('Print Invoice') ?></a></h2> <h3 class="table-caption"><?php echo $this->__('Items Invoiced') ?></h3> <table class="data-table linearize-table" id="my-invoice-table-<?php echo $_invoice->getId(); ?>"> <col /> <col width="1" /> <col width="1" /> <col width="1" /> <col width="1" /> <col width="1" /> <thead> <tr> <th><?php echo $this->__('Product Name') ?></th> <th><?php echo $this->__('SKU') ?></th> <th><?php echo $this->__('Discount Amount') ?></th> <th class="a-right" data-rwd-label="<?php echo $this->__('Price') ?>"><?php echo $this->__('Price') ?></th> <th class="a-center" data-rwd-label="<?php echo $this->__('Qty Invoiced') ?>"><span class="nobr"><?php echo $this->__('Qty Invoiced') ?></span></th> <th class="a-right" data-rwd-label="<?php echo $this->__('Subtotal') ?>"><?php echo $this->__('Subtotal') ?></th> </tr> </thead> <tfoot> <?php echo $this->getInvoiceTotalsHtml($_invoice)?> </tfoot> <?php $_items = $_invoice->getAllItems(); ?> <?php $_count = count($_items) ?> <?php foreach ($_items as $_item): ?> <?php if ($_item->getOrderItem()->getParentItem()) continue; ?> <tbody> <?php echo $this->getItemHtml($_item) ?> </tbody> <?php endforeach; ?> </table> <script type="text/javascript">decorateTable('my-invoice-table-<?php echo $_invoice->getId(); ?>', {'tbody' : ['odd', 'even'], 'tbody tr' : ['first', 'last']})</script> <?php echo $this->getInvoiceCommentsHtml($_invoice)?> <?php endforeach; ?> 

And

app/design/frontend/rwd/default/template/sales/order/invoice/items/renderer/default.phtml

add following line after SKU column. <td data-rwd-label=" <?php echo $this->__('Discount Amount') ?>"> <?php echo $_item->getDiscountAmount();?> </td>

Now looks like:

......... <td data-rwd-label="<?php echo $this->__('SKU') ?>"><?php echo $this->escapeHtml(Mage::helper('core/string')->splitInjection($this->getSku())) ?></td> <td data-rwd-label="<?php echo $this->__('Discount Amount') ?>"><?php echo $_item->getDiscountAmount();?></td> <td class="a-right" data-rwd-label="<?php echo $this->__('Price') ?>"> ........ 

Lastly

app/design/frontend/rwd/default/layout/sales.xml

<sales_order_invoice translate="label"> <label>Customer My Account Order Invoice View</label> <update handle="customer_account"/> <reference name="my.account.wrapper"> <block type="sales/order_info" as="info" name="sales.order.info"> <block type="sales/order_info_buttons" as="buttons" name="sales.order.info.buttons" /> </block> <block type="sales/order_invoice" name="sales.order.invoice"> <block type="sales/order_invoice_items" name="invoice_items" template="sales/order/invoice/items.phtml"> <action method="addItemRender"><type>default</type><block>sales/order_item_renderer_default</block><template>sales/order/invoice/items/renderer/default.phtml</template></action> <action method="addItemRender"><type>grouped</type><block>sales/order_item_renderer_grouped</block><template>sales/order/invoice/items/renderer/default.phtml</template></action> <block type="sales/order_invoice_totals" name="invoice_totals" template="sales/order/totals.phtml"> <action method="setLabelProperties"><value>colspan="5" class="a-right"</value></action> <action method="setValueProperties"><value>class="last a-right"</value></action> <block type="tax/sales_order_tax" name="tax" template="tax/order/tax.phtml" /> </block> <block type="sales/order_comments" name="invoice_comments" template="sales/order/comments.phtml" /> </block> </block> </reference> <reference name="sales.order.info"> <action method="addLink" translate="label" module="sales"><name>view</name><path>*/*/view</path><label>Order Information</label></action> <action method="addLink" translate="label" module="sales"><name>invoice</name><path></path><label>Invoices</label></action> <action method="addLink" translate="label" module="sales"><name>shipment</name><path>*/*/shipment</path><label>Shipments</label></action> <action method="addLink" translate="label" module="sales"><name>creditmemo</name><path>*/*/creditmemo</path><label>Refunds</label></action> </reference> <block type="core/text_list" name="additional.product.info" /> </sales_order_invoice> 

Especially you change here colspan. Default 4, now you need to change that 5.

Clear cache.

So overwrite these two templates and added a new column. For base template file you can find under base/default directory instead of rwd/default.

Note: Don't modify core file.

4
  • it's magento 1, not magento 2 Commented Mar 7, 2019 at 12:42
  • Check updated answer. Commented Mar 7, 2019 at 12:44
  • yea, i know the files, but i want the code to update the files. so please write the code modifications. thank you Commented Mar 7, 2019 at 12:49
  • Check updated answer Commented Mar 7, 2019 at 15:22

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.