VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: mogaka on August 29, 2016, 16:25:10 PM

Title: How to show 'Free" for 0 priced products
Post by: mogaka on August 29, 2016, 16:25:10 PM
Software used:
Database Version: 5.5.36
PHP Version: 5.4.27
Joomla! Version: 3.3.3
Virtuemart: 2.9.9

I edited this file: administrator/components/com_virtuemart/helpers/currencydisplay.php, line 349 to become:
$priceFormatted = 'Free';

After doing that, product on the main virtuemart shop displays correctly as shown in 'pic 1' but products on the additional virtumart modules eg recently viewed do not diplay the text 'Free' as shown in 'pic 2'.

and lastly, when I add a free product to the cart, i get the following error messages as show in 'pic 3'.

Notice: Undefined index: product_price in C:\xampp\htdocs\cadpick\administrator\components\com_virtuemart\helpers\calculationh.php on line 269
Notice: Undefined index: product_currency in C:\xampp\htdocs\cadpick\administrator\components\com_virtuemart\helpers\calculationh.php on line 270
Notice: Undefined index: override in C:\xampp\htdocs\cadpick\administrator\components\com_virtuemart\helpers\calculationh.php on line 271
Notice: Undefined index: product_override_price in C:\xampp\htdocs\cadpick\administrator\components\com_virtuemart\helpers\calculationh.php on line 272
Notice: Undefined index: product_tax_id in C:\xampp\htdocs\cadpick\administrator\components\com_virtuemart\helpers\calculationh.php on line 273
Notice: Undefined index: product_discount_id in C:\xampp\htdocs\cadpick\administrator\components\com_virtuemart\helpers\calculationh.php on line 274

Kindly help
Title: Re: How to show 'Free" for 0 priced products
Post by: jenkinhill on August 29, 2016, 16:44:01 PM
You should not be using VM2.9.9 which was part of a test/development version leading up to the release of VM3 and is known to be buggy and insecure - the current stable VM version is 3.0.16 (http://dev.virtuemart.net/projects/virtuemart/files )
Joomla 3.3.3 is also very old and insecure.  These versions should not be used on a live site.
http://forum.virtuemart.net/index.php?topic=118683.0

You should not edit core files as this can lead to all sorts of problems. That should be done using template overrides or by building plugins.

AS for the php notices:  http://forum.virtuemart.net/index.php?topic=102555.0
Title: Re: How to show 'Free" for 0 priced products
Post by: mogaka on September 26, 2016, 08:08:54 AM
Thank you for your help @jenkinhill - it has greatly improved my site. I have upgraded my software as follows:
Joomla: 3.6.2
Php: 5.4.27
Virtuemart: 3.0.16

However I still have the problem I had earlier. I want to display 'Free' for 0 priced products on the main products page and on the additional virtuemart modules e.g the recently viewed products. Currently, if a product has a price of 0, the price div is not even displayed - as show on the attachments on my previous post.

Help on this matter will be highly appreciated.
Title: Re: How to show 'Free" for 0 priced products
Post by: GJC Web Design on September 26, 2016, 12:43:29 PM
you can do this in the templates.. or in the sublayout prices - over ride it


e.g.


//echo $currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
$salesprice = $currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);

if(empty($saleprice)) {
echo 'Free';
}else{
echo $currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
}




not tested
Title: Re: How to show 'Free" for 0 priced products
Post by: mogaka on November 13, 2016, 16:32:59 PM
Hi @GJC Web Design, thank you for the reply but unfortunately it doesn't work - it displays 'Free' for all products including the ones with a price.
However i found a very simple solution to my problem, simply set the minimum product price as 0.000001 on the vmvendor configuration.