VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: jenjis on October 03, 2012, 15:13:15 PM

Title: [Virtuemart 2.0.6] show zero prices
Post by: jenjis on October 03, 2012, 15:13:15 PM
Hi,
how can i show in product details the value "0"?
when the product has no price set, the price div shows no information!

and, please, someone can say me where is the createPriceDiv function?

Thanks
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: sleepigrl on October 03, 2012, 16:05:21 PM
I'm interested in this as well.  I have some products where the price is determined entirely by the options chosen in custom fields.  The price is correct when added to the cart, but the user can't see it on the product details view.
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: sleepigrl on October 03, 2012, 16:49:41 PM
Found it!

The createpricediv function is in administrator/components/com_virtuemart/helpers/currencydisplay.php

I changed two lines there and am able to display a zero price (or leave the price blank until custom field prices are chosen).

This line (360) prevents the price div from being created if the price is empty (0 = empty/false):
if(empty($product_price)) return '';

changed to:
//if(empty($product_price)) return '';




@line 387 there is another check for an empty price:
if(!empty($price)){
$vis = "block";
$priceFormatted = $this->priceDisplay($price,0,(float)$quantity,false,$this->_priceConfig[$name][1] );
} else {
$priceFormatted = '';
$vis = "none";
}


I modified this to show the price block in either case:

if(!empty($price)){
$vis = "block";
$priceFormatted = $this->priceDisplay($price,0,(float)$quantity,false,$this->_priceConfig[$name][1] );
} else {
$priceFormatted = '';
$vis = "block";
}


I also experimented with changing the $priceFormatted value to something like $priceFormatted ='$0.00', which worked fine, but since I don't actually need to show the zero price (just the price with the included options), I'm leaving it as is for now.

Seems like it would really be better to check to see whether the product_price is NULL rather than "empty."  I think that would allow zero prices to be shown.
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: jenkinhill on October 03, 2012, 23:35:37 PM
All I do is set the product price to 0.00 - the the product price displays as zero. No need to hack any files.
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: sleepigrl on October 03, 2012, 23:41:22 PM
Jenkinhill, what version of VM are you using? 

For me, using VM 2.0.10, putting a zero in the product price has one of two effects:

In addition, in the default template, the "Add to Cart" button does not show for products with a zero price.  That's easy enough to fix via template override. 

Are you using a template override to show the zero price?  If so, can you tell me what field you're using? 

Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: jenjis on October 08, 2012, 13:07:28 PM
Quote from: sleepigrl on October 03, 2012, 16:49:41 PM
Found it!

The createpricediv function is in administrator/components/com_virtuemart/helpers/currencydisplay.php

I changed two lines there and am able to display a zero price (or leave the price blank until custom field prices are chosen).

[...]

Thank you!
you've been very helpful! :D


however in 2.0.6 the solution is a bit different:

in administrator/components/com_virtuemart/helpers/currencydisplay.php

the line to comment is 719
//if(empty($product_price)) return '';

and the second block is at line 767.

furthermore in components/com_virtuemart/views/productdetails/tmpl/default.php
the line 421
if (!VmConfig::get('use_as_catalog', 0) and !empty($this->product->prices)) {

has to become

if (!VmConfig::get('use_as_catalog', 0)) {



Bye!!!
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: QubeSys Technologies on November 06, 2012, 07:18:20 AM
Quote from: jenkinhill on October 03, 2012, 23:35:37 PM
All I do is set the product price to 0.00 - the the product price displays as zero. No need to hack any files.

Sadly, that doesnt work.

IT doesnt take if we put 0.
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: laytintudong on November 06, 2012, 08:02:40 AM
Ok, thanks
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: QubeSys Technologies on November 06, 2012, 08:04:35 AM
Quote from: jenjis on October 08, 2012, 13:07:28 PM
Quote from: sleepigrl on October 03, 2012, 16:49:41 PM
Found it!

The createpricediv function is in administrator/components/com_virtuemart/helpers/currencydisplay.php

I changed two lines there and am able to display a zero price (or leave the price blank until custom field prices are chosen).

[...]

Thank you!
you've been very helpful! :D


however in 2.0.6 the solution is a bit different:

in administrator/components/com_virtuemart/helpers/currencydisplay.php

the line to comment is 719
//if(empty($product_price)) return '';

and the second block is at line 767.

furthermore in components/com_virtuemart/views/productdetails/tmpl/default.php
the line 421
if (!VmConfig::get('use_as_catalog', 0) and !empty($this->product->prices)) {

has to become

if (!VmConfig::get('use_as_catalog', 0)) {



Bye!!!

YOU ARE AWESOME!! THAT HACK WORKED PERFECT.
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: stresskills on February 28, 2014, 01:06:34 AM
Quote from: QubeSys Technologies on November 06, 2012, 08:04:35 AM
Quote from: jenjis on October 08, 2012, 13:07:28 PM
Quote from: sleepigrl on October 03, 2012, 16:49:41 PM
Found it!

The createpricediv function is in administrator/components/com_virtuemart/helpers/currencydisplay.php

I changed two lines there and am able to display a zero price (or leave the price blank until custom field prices are chosen).

[...]

Thank you!
you've been very helpful! :D


however in 2.0.6 the solution is a bit different:

in administrator/components/com_virtuemart/helpers/currencydisplay.php

the line to comment is 719
//if(empty($product_price)) return '';

and the second block is at line 767.

furthermore in components/com_virtuemart/views/productdetails/tmpl/default.php
the line 421
if (!VmConfig::get('use_as_catalog', 0) and !empty($this->product->prices)) {

has to become

if (!VmConfig::get('use_as_catalog', 0)) {



Bye!!!

YOU ARE AWESOME!! THAT HACK WORKED PERFECT.

Anyone know how to do this for 2.0.24 or current version by chance?
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: nordmograph on March 14, 2016, 12:37:45 PM
Old topic, but I needed it for VM3.0.12, so here it is
in administrator/components/com_virtuemart/helpers/currencydisplay.php

replace
if(!empty($price) or $name == 'billTotal' or $name == 'billTaxAmount'){
with
// if(!empty($price) or $name == 'billTotal' or $name == 'billTaxAmount'){

and

/* } else {
                $priceFormatted = '';
                $vis = " vm-nodisplay";
            }*/
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: davide81 on January 11, 2018, 10:01:15 AM
Hi, I use VirtueMart 3.2.12


I made the changes for the version VM3.0.12 Posted by: nordmograph but for this version they do not work.
I still do not see prices. I noticed that if I enter 0 in the product it is not saved and the field remains empty.

Best Regards
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: Jörgen on January 11, 2018, 10:39:57 AM
Hello

Try with the price 0.00005

regards

Jörgen @ Kreativ Fotografi
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: davide81 on January 11, 2018, 12:34:14 PM
Hello,
yes with 0.00005 the price was shown, but in the price field I see 5.0E-5 and I need to change it in all the product manually.

I'd like to be able to view the price by leaving 0
Thank you
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: Jörgen on January 11, 2018, 13:19:55 PM
What Do You want to do ?

Where Do You want to display 0? Because I see 0.00 in my prices.

regards

Jörgen @ Kreativ Fotografi
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: davide81 on January 11, 2018, 16:19:05 PM
Hi,
I want see price=o in product details page.

I upgraded to VirtueMart 3.2.12,  in the old version I saw it correctly if I left 0 in the price.

Now the price field is empty and if I put 0 and save it remains empty

Example:

http://cortinadoccia.com/negozio/docce-in-tessuto/versione-angolo/art-202-aeb-da-63a66-cm-detail
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: jenkinhill on January 11, 2018, 17:35:10 PM
These are my test results using Beez template, J3.8.3  VM3.2.12
In the first two Show call for price, when the price is empty in Configuration/Pricing is disabled.
Setting cost price as 0.0001 with no override:

(https://image.ibb.co/iN3R46/price1.png) (https://ibb.co/eF9cBm)


Price override used, set to 0:

(https://image.ibb.co/nfxaxR/price2.png) (https://ibb.co/k0d4rm)


Price override set to 0, Show call for price, when the price is empty in Configuration/Pricing is enabled

(https://image.ibb.co/f1xm46/price3.png) (https://ibb.co/c3UcBm)


And finally, cost price set to 0 and saved, no override:

(https://image.ibb.co/jL9cBm/price4.png) (https://ibb.co/gFxVWm)

All works as expected.
Title: Re: [Virtuemart 2.0.6] show zero prices
Post by: Jörgen on January 12, 2018, 07:17:06 AM
Upgraded from what ?

This is probably due to old override.

regards

Jörgen @ Kreativ Fotografi