News:

Looking for documentation? Take a look on our wiki

Main Menu

[Virtuemart 2.0.6] show zero prices

Started by jenjis, October 03, 2012, 15:13:15 PM

Previous topic - Next topic

jenjis

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

sleepigrl

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.

sleepigrl

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.

jenkinhill

All I do is set the product price to 0.00 - the the product price displays as zero. No need to hack any files.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

sleepigrl

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:

  • If "Call for Price" is turned on in config, I see that
  • If "Call for Price" is turned off, I don't see any price and the price div isn't created at all.

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? 


jenjis

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!!!

QubeSys Technologies

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.
Blissful!

laytintudong

<a href="http://hocseohanoi.com">Auto update website content, E-content joomla,  Manual e-content</a>

QubeSys Technologies

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.
Blissful!

stresskills

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?
"If you think you can do a thing or think you can't do a thing, you're right." Henry Ford

nordmograph

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";
            }*/

davide81

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

Jörgen

Hello

Try with the price 0.00005

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

davide81

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

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.