Jump to content

How to add a total of sold items at invoice


Recommended Posts

To show the total of sold items of a order invoice you could do something like this:

1. Edit / override the file /classes/pdf/HTMLTemplateInvoice.php and in function getContent() look for the comment:

/**
 * Need the $round_mode for the tests.
 */ 

And add above the comment this code:

/* order products sold */
$footer['products_sold'] = count($order_details); 

 Then edit file /pdf/invoice.total-tab.tpl and inside table tag add:

<tr>
    <td class="grey" width="70%">
        {l s='Products sold' pdf='true'}
    </td>
    <td class="white" width="30%">
        {$footer.products_sold}
    </td>
</tr>
Edited by gabdara (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 5 weeks later...

Find the foreach loop in the invoice.tpl

 

Make this code:

<!-- PRODUCTS -->
{foreach $order_details as $order_detail}
{cycle values='#FFF,#DDD' assign=bgcolor}
<tr style="line-height:6px;background-color:{$bgcolor};">

Into this:

<!-- PRODUCTS -->
{assign var="total_quantity" value="`0`"}
{foreach $order_details as $order_detail}
{assign var="total_quantity" value="`$order_detail.product_quantity + $total_quantity`"}
{cycle values='#FFF,#DDD' assign=bgcolor}
<tr style="line-height:6px;background-color:{$bgcolor};">

Now you should be able to insert the code

{$total_quantity}

where ever you want to show the total quantity.

Edited by Fancy Things (see edit history)
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

×
×
  • Create New...