VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: dorex on April 09, 2013, 16:07:27 PM

Title: How to count each different item (row) in the pdf invoice ?
Post by: dorex on April 09, 2013, 16:07:27 PM
Hi everyone!

How can I have a colon in the pdf generated invoice (a 1st colon, prior to SKU), that should count the ordered products. Something like this:

No._______SKU_______Product Name_______......................._______Discount_______Total
1_______FLO-017_______Blue rose_______......................._______$0_______$0.5
2_______SNK-028_______red sneakers_______......................._______$0_______$16
3_______TOY-052_______Small plastic toy_______......................._______$0_______$7
                                                                            Total:................................................


I suppose I should insert a colon in this file:           /MyTemplate/html/com_virtuemart/invoice/invoice_items.php

... but what should I echo in that colon in order to output the counter from the first colon (1, 2, 3, etc.)?

I'm pretty sure my question may be considered stupid and the answer is very obvious, but I'm not familiar to php.

Thank you for your help!
Title: Re: How to count each different item (row) in the pdf invoice ?
Post by: K&K media production on April 10, 2013, 02:12:36 AM
above: foreach($this->orderDetails['items'] as $item) {

add: $count = 1;

in your in your table cell add: echo $count;

above: } ?>

add: $count++;
Title: Re: How to count each different item (row) in the pdf invoice ?
Post by: dorex on April 10, 2013, 05:48:27 AM
Quote from: kkmediaproduction on April 10, 2013, 02:12:36 AM
above: foreach($this->orderDetails['items'] as $item) {

add: $count = 1;

in your in your table cell add: echo $count;

above: } ?>

add: $count++;

Great! It works. Thank you!
Title: Re: How to count each different item (row) in the pdf invoice ?
Post by: MihaiDumitrele on June 19, 2014, 18:29:39 PM
Very useful, but on bills in romania is necessary to have numbered in line with product and shipping cost.
In addition must add a new column containing units of measure (UM), which must have a fixed text (pieces) for each product
Please help me to add these two informations on my bill like:

Nr ...............product.................UM...........price.........qty...........final price
1                  product 1              pieces                   
2                  product2               pieces
3                  product 3              pieces
4                  shipping                pieces                      1             shipping cost
Title: Re: How to count each different item (row) in the pdf invoice ?
Post by: GJC Web Design on June 19, 2014, 20:59:38 PM
Sounds like u need to re-over throw the government and this time put all the tax bureaucrats in the Danube..

Never heard anything so anally retentive.. why do governments treat their citizens like children especially small businesses that are driving the economy? (but I guess that is a bit off topic)...

It will be just experimenting with that template till u get the layout correct...

then the number for shipping will be the $count after the closing brace