VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: P Humstad on December 01, 2014, 05:09:29 AM

Title: Extra field in print template
Post by: P Humstad on December 01, 2014, 05:09:29 AM
Hi everybody,

I,ve been struggeling for months adding one field to my order print. My store contains over 3000 products, all of these have a unique placement in our warehouse. When we recive a order it would save us a lot of time if we could print the location of the product i the print sheet of the order.

For the time beeing we have been using the MPN field in product manager for this. When a order arrives we now have to go into every product manually to find the location of the product in our warehose.

What I need is a simple way to add the MPN field to the order print template. Can someone please provide a short and simple guide for this !
Title: Re: Extra field in print template
Post by: AH on January 27, 2015, 14:49:04 PM
You will probably have to do a core change this will get overwritten every time you upgrade


administrator/components/com_virtuemart/models/orders.php

Around line 200
$q = 'SELECT virtuemart_order_item_id, product_quantity, order_item_name,
    order_item_sku, i.virtuemart_product_id, product_item_price,
    product_final_price, product_basePriceWithTax, product_discountedPriceWithoutTax, product_priceWithoutTax, product_subtotal_with_tax, product_subtotal_discount, product_tax, product_attribute, order_status, p.product_available_date, p.product_availability,
    intnotes, virtuemart_category_id


change to
$q = 'SELECT virtuemart_order_item_id, product_quantity, order_item_name,
    order_item_sku, i.virtuemart_product_id, product_item_price,
    product_final_price, product_basePriceWithTax, product_discountedPriceWithoutTax, product_priceWithoutTax, product_subtotal_with_tax, product_subtotal_discount, product_tax, product_attribute, order_status, p.product_available_date, p.product_availability,
    intnotes, virtuemart_category_id,p.product_mpn



Now you can do a template override to the invoice - this will not get overwritten if you upgrade:-

templates/yourtemplate/html/com_virtuemart/invoice/invoice_items.php

To show the MPN

<?php echo $item->product_mpn?>

Title: Re: Extra field in print template
Post by: GJC Web Design on January 27, 2015, 16:50:52 PM
or do the query directly in the  templates/yourtemplate/html/com_virtuemart/invoice/invoice_items.php but some people see this as being akin to sleeping with your sister...  (not recommended apparently)

then it won't be over written
Title: Re: Extra field in print template
Post by: AH on January 27, 2015, 18:23:31 PM
LOL GJC.

And should IMHO be part of core
Title: Re: Extra field in print template
Post by: P Humstad on January 29, 2015, 12:05:41 PM
It looks like a nice trick, your above guide, but

but where will I find the original com_virtuemart/invoice/invoice_items.php so I can make the overide ?
I,m a novice, thats why I,m asking
Title: Re: Extra field in print template
Post by: AH on January 29, 2015, 15:17:36 PM
It is here

components/com_virtuemart/views/invoice/tmpl/invoice_items.php
Title: Re: Extra field in print template
Post by: P Humstad on January 29, 2015, 16:24:56 PM
Thanks a lot ;)
Title: Re: Extra field in print template
Post by: P Humstad on January 30, 2015, 05:35:52 AM
Dear GJC

I followed yoyr guide step by step but cant get this to work. I modified the order.php file as instructed.
I then added the echo call in the discount column where I want the mpn to show up, but I cant see any changes,.... Probably I,m doing something wrong :(
Am I missing something,
Now I,m a little bit stuck
Title: Re: Extra field in print template
Post by: AH on January 30, 2015, 09:38:00 AM
You should use my instructions, not GJC as GJC has not given you a detailed step by step approach for doing it all in the view
Title: Re: Extra field in print template
Post by: P Humstad on January 30, 2015, 12:33:58 PM
Sorry Hutson,

The message were ment for you. I have used your instructions but still cant get it to work. Can some cached files be a problem ?

As for the first issue you helped me with, the overide did not work, but when modifying the original virtuemart file it worked. I,m refering to the extra fields in product list mpn and stock.
Basicly this works exactly like I wanted it, but using the original file, not an overide ? I,m a little bit confused, cause I,ve never managed to get overides to work !
Title: Re: Extra field in print template
Post by: AH on January 30, 2015, 14:24:57 PM
You are not putting your override in the correct directory

templates/YOURTEMPLATE/html/com_virtuemart/invoice/invoice_items.php

YOURTEMPLATE is the frontend template for your site  e.g. beez5
Title: Re: Extra field in print template
Post by: servlet on June 22, 2016, 01:12:04 AM
@AH... was it added to the core. I try it to hack just now but there is p.product_mpn
Title: Re: Extra field in print template
Post by: servlet on June 22, 2016, 02:32:42 AM
It works... Just add <?php echo $item->product_mpn; ?> in your template...
Title: Re: Extra field in print template
Post by: AH on June 22, 2016, 09:35:39 AM
yes it was added to core  :)