VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Geppux on February 13, 2016, 10:46:26 AM

Title: How to modify price in virtuemart module product
Post by: Geppux on February 13, 2016, 10:46:26 AM
VM 3.0.12 J 3.4.8

Hi, in my home page I have the virtuemart module that shows the latest products, but the product is shown only with the final price... I would like to show also the base price with tax but without discount and the discount amount. I know which file has to be edited and I made some try but without success, can somebody helps me?
Thank you.
Giuseppe
Title: Re: How to modify price in virtuemart module product
Post by: Geppux on February 18, 2016, 15:36:32 PM
In the template/mytemplate/html/mod_virtuemart_product/default.php the price is set with this code:
<span class="product-price">
<?php 
// $product->prices is not set when show_prices in config is unchecked
if ($show_price and  isset($product->prices)) {
echo '<div class="product-price">'.$currency->createPriceDiv ('salesPrice'''$product->pricesFALSEFALSE1.0TRUE);
if ($product->prices['salesPriceWithDiscount'] > 0) {
echo $currency->createPriceDiv ('salesPriceWithDiscount'''$product->pricesFALSEFALSE1.0TRUE);
}
echo '</div>';
}?>

</span>

any suggestion on how to modify it to obtain what I need?
In the category page prices are displayed as I need but the code of the template/mytemplate/html/com_virtuemart/category/default.php is completely different and I don't understand how to do.
Thank you.

Giuseppehe code of the template/mytemplate/html/com_virtuemart/category/default.php
Title: Re: How to modify price in virtuemart module product
Post by: PRO on February 18, 2016, 21:38:17 PM
if u notice the word    salesPrice in
echo '<div class="product-price">'.$currency->createPriceDiv ('salesPrice', '', $product->prices, FALSE, FALSE, 1.0, TRUE);

salesPrice is the sales price.
You can add any one you want.

in the category, you can look at the code with firebug etc. and see the correct name for the price you want.
for example, mine says
<span class="PricepriceWithoutTax">$99.99</span>

This text PricepriceWithoutTax      is the name of the price

Title: Re: How to modify price in virtuemart module product
Post by: Geppux on February 18, 2016, 22:50:46 PM
Thank you Pro, tomorrow I'll try.
Title: Re: How to modify price in virtuemart module product
Post by: Geppux on February 18, 2016, 23:49:46 PM
I can't wait tomorrow...  ;D even if it's late!
I checked with firebug in the category page and the name of the price is PricebasePriceWithTax so I added this to the file but the price completely disappeared... so I thought I inserted in the wrong place so I just replaced salesPrice with PricebasePriceWithTax and I expected to have the full price displayed as in the category page, but again no price displayed... what I'm missing?
Thank you.
Giuseppe

www.mulligan.it
VM 3.0.12
J 3.4.8
Title: Re: How to modify price in virtuemart module product
Post by: Jörgen on February 19, 2016, 07:40:10 AM
Hello Geppux

You don´t say what You changed. Changing the CSS is not enough. You have to change the PHP echo statement. I this does not help. Have You published the price You want to see in the backend ?

regards

Joergen @ Kreativ Fotografi
Title: Re: How to modify price in virtuemart module product
Post by: Geppux on February 19, 2016, 10:03:31 AM
Hi Jorgen,
I didn't changed the CSS, I modified the template/mytemplate/html/mod_virtuemart_product/default.php
The price I want to see is published in the back end, in fact I can see it regularly in the category page.
You can check here: http://mulligan.it/it/gps-e-telemetri-da-golf.html
Title: Re: How to modify price in virtuemart module product
Post by: Jörgen on February 19, 2016, 10:30:18 AM
Hi Geppux

He, he, I looked at my site and the same happens (doesn´t show) to crossed over price.  :-[
Have to take a check and see what happens. Maybe I get time to investigate this weekend.

regards

Jörgen @ Kreativ Fotografi
Title: Re: How to modify price in virtuemart module product
Post by: Geppux on February 19, 2016, 10:35:02 AM
Thank you Jorgen, let me know if you have news, bye.
Title: Re: How to modify price in virtuemart module product
Post by: PRO on February 19, 2016, 15:28:06 PM
so weird, i looked into it.

i can get the prices, but print_r  but it will not echo it
Title: Re: How to modify price in virtuemart module product
Post by: Geppux on February 19, 2016, 15:55:13 PM
So no chance to obtain what I want?  :(
Title: Re: How to modify price in virtuemart module product
Post by: PRO on February 19, 2016, 19:07:40 PM
i dont know
Title: Re: How to modify price in virtuemart module product
Post by: Jörgen on February 20, 2016, 09:00:52 AM
Hello Geppux

I just made a quick test. If You include this, You will get the crossed out price without discount. Look into the sublayout prices.php and You will find the other prices You are looking for.
// Only displays if we have discount
if (round($product->prices['basePriceWithTax'],$currency->_priceConfig['salesPrice'][1]) != round($product->prices['salesPrice'],$currency->_priceConfig['salesPrice'][1])) {
echo '<span class="price-crossed" >' . $currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $product->prices) . "</span>";
}


best regards

Jörgen @ Kreativ Fotografi


Title: Re: How to modify price in virtuemart module product
Post by: Geppux on February 20, 2016, 18:02:45 PM
Great Jorgen!! You did it.
Thank you very much for your help!

Giuseppe
Title: Re: How to modify price in virtuemart module product
Post by: Jörgen on February 20, 2016, 18:14:24 PM
You´re welcome :)

Jörgen @ Kreativ Fotografi
Title: Re: How to modify price in virtuemart module product
Post by: jeanette on March 03, 2016, 14:01:00 PM
Hi,
i am also trying to do this, but seems nothing is showing. Maybe i have put this in the wrong place? Hope you can advice where to put this code, cause i obviously did not get it :)

I am editing the \mod_virtuemart_product\default.php to this:

<?php 
// $product->prices is not set when show_prices in config is unchecked
if ($show_price and  isset($product->prices)) {
echo '<div class="product-price">'.$currency->createPriceDiv ('salesPrice'''$product->pricesFALSEFALSE1.0TRUE);
if ($product->prices['salesPriceWithDiscount'] > 0) {
echo $currency->createPriceDiv ('salesPriceWithDiscount'''$product->pricesFALSEFALSE1.0TRUE);
}
if (round($product->prices['basePriceWithTax'],$currency->_priceConfig['salesPrice'][1]) != round($product->prices['salesPrice'],$currency->_priceConfig['salesPrice'][1])) {
echo '<span class="price-crossed" >' $currency->createPriceDiv ('basePriceWithTax''COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX'$product->prices) . "</span>";
}
echo '</div>';
}?>
Title: Re: How to modify price in virtuemart module product
Post by: jeanette on March 03, 2016, 14:44:23 PM
Actually i figured it out. I had to edit the single.php instead of the default.php

Thanks for your tip above :)  :)