[Mod]Displaying something other than $0 if no price is given
49 posts
• Page 1 of 3 • 1, 2, 3
[Mod]Displaying something other than $0 if no price is given
Anyone have an easy solution to this? Ideally, I'd love the system to say "Coming soon" if a product is listed at a price of $0.00
Thanks in advance.
Thanks in advance.
- dashik
- Posts: 32
- Joined: Fri Jul 31, 2009 12:10 pm
Re: Displaying something other than $0 when no price is given
There is a solution, I don't know whether you'd call it "easy".
In your top level language file (ie. "catalog/language/english/english.php"), insert the following:-
Then in the following files:-
Then, (in the same files) find:
and replace with:
Also, in "catalog/controller/product/product.php" find:
and replace with:
In your top level language file (ie. "catalog/language/english/english.php"), insert the following:-
- Code: Select all
$_['text_no_price'] = 'Coming Soon';
Then in the following files:-
- catalog/controller/product/category.php
catalog/controller/product/manufacturer.php
catalog/controller/product/search.php
catalog/controller/product/special.php
catalog/controller/product/product.php
- Code: Select all
$this->data['text_no_price'] = $this->language->get('text_no_price');
Then, (in the same files) find:
- Code: Select all
if ($discount) {
$price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
$special = $this->model_catalog_product->getProductSpecial($result['product_id']);
if ($special) {
$special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
}
}
and replace with:
- Code: Select all
if ($discount) {
$price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
} else {
if ($result['price'] == 0) {
$price = $this->language->get('text_no_price');
} else {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
$special = $this->model_catalog_product->getProductSpecial($result['product_id']);
if ($special) {
$special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
}
}
Also, in "catalog/controller/product/product.php" find:
- Code: Select all
if ($discount) {
$this->data['price'] = $this->currency->format($this->tax->calculate($discount, $product_info['tax_class_id'], $this->config->get('config_tax')));
$this->data['special'] = FALSE;
} else {
$this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
$special = $this->model_catalog_product->getProductSpecial($this->request->get['product_id']);
if ($special) {
$this->data['special'] = $this->currency->format($this->tax->calculate($special, $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$this->data['special'] = FALSE;
}
}
and replace with:
- Code: Select all
if ($discount) {
$this->data['price'] = $this->currency->format($this->tax->calculate($discount, $product_info['tax_class_id'], $this->config->get('config_tax')));
$this->data['special'] = FALSE;
} else {
if ($product_info['price'] == 0) {
$this->data['price'] = $this->language->get('text_no_price');
} else {
$this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
}
$this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
$special = $this->model_catalog_product->getProductSpecial($this->request->get['product_id']);
if ($special) {
$this->data['special'] = $this->currency->format($this->tax->calculate($special, $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$this->data['special'] = FALSE;
}
}

If you're not living on the edge ... you're taking up too much space!
Multi-Vendor Plugin for OpenCart 1.5.1.x
Have I helped you?
-

fido-x - Posts: 1960
- Joined: Fri Jun 27, 2008 5:09 pm
- Location: Tasmania, Australia
Re: Displaying something other than $0 when no price is given
Thanks for the info! My code isn't the same (i'm running 1.3.0) but i was able to get this to work on the product pages.
However, I haven't been able to get it to work on the category pages.
Here's what my code looks like in category.php
However, I haven't been able to get it to work on the category pages.
Here's what my code looks like in category.php
- Code: Select all
$special = $this->model_catalog_product->getProductSpecial($result['product_id']);
if ($special) {
$special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$special = FALSE;
}
- dashik
- Posts: 32
- Joined: Fri Jul 31, 2009 12:10 pm
Re: Displaying something other than $0 when no price is given
Ah, 1.3.0. That's slightly different. OK, here goes.
In the controller files previously mentioned, you will find a block of code that reads:
Before this, insert:
Then in the products array, where it says:
Replace with:
In the controller files previously mentioned, you will find a block of code that reads:
- Code: Select all
$this->data['products'][] = array(
'name' => $result['name'],
'model' => $result['model'],
'rating' => $rating,
'stars' => sprintf($this->language->get('text_stars'), $rating),
'thumb' => HelperImage::resize($image, $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height')),
'price' => $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))),
'special' => $special,
'href' => $this->model_tool_seo_url->rewrite($this->url->http('product/product&product_id=' . $result['product_id']))
);
Before this, insert:
- Code: Select all
if ($result['price'] == 0) {
$price = $this->language->get('text_no_price');
} else {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
}
Then in the products array, where it says:
- Code: Select all
'price' => $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))),
Replace with:
- Code: Select all
'price' => $price,

If you're not living on the edge ... you're taking up too much space!
Multi-Vendor Plugin for OpenCart 1.5.1.x
Have I helped you?
-

fido-x - Posts: 1960
- Joined: Fri Jun 27, 2008 5:09 pm
- Location: Tasmania, Australia
Re: Displaying something other than $0 when no price is given
Absolutely spot on! Thank you 

- dashik
- Posts: 32
- Joined: Fri Jul 31, 2009 12:10 pm
Re: Displaying something other than $0 when no price is given
hi,
i changed only in products.php, and i get error like this..
Parse error: syntax error, unexpected T_ELSE in /catalog/controller/product/product.php on line 306
please, help!
i changed only in products.php, and i get error like this..
Parse error: syntax error, unexpected T_ELSE in /catalog/controller/product/product.php on line 306
please, help!
- Donce
- Posts: 68
- Joined: Fri Aug 28, 2009 12:22 pm
Re: Displaying something other than $0 when no price is give
A little trick to make this a lot easier for you..
Remember all prices pass through the currency->format() function, even if they are 0
1. EDIT: system/library/currency.php (or system/helper/currency.php for certain versions)
2. FIND:
3. BEFORE, ADD:
That's it! One file handles ALL places.. even custom mods are automatically changed
Remember all prices pass through the currency->format() function, even if they are 0
1. EDIT: system/library/currency.php (or system/helper/currency.php for certain versions)
2. FIND:
- Code: Select all
$string = '';
3. BEFORE, ADD:
- Code: Select all
if ($format && (float)$value == 0) {
return 'FREE';
}
That's it! One file handles ALL places.. even custom mods are automatically changed

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18209
- Joined: Mon Jul 21, 2008 7:02 pm

Re: Displaying something other than $0 when no price is given
Cha!
awesome, works! Thank you very much!
awesome, works! Thank you very much!
- Donce
- Posts: 68
- Joined: Fri Aug 28, 2009 12:22 pm
Re: [Mod]Displaying something other than $0 if no price is given
this is perfect for my products that i don't have a price applied to
if ($format && (int)$value == 0) {
return 'coming soon';
}
it shows up perfect.
however when you have pickup for shipping its show ups as:
Pickup Up: and in the price instead of 0.00 is shown as 'coming soon'
which is a problem i completely understand why... but
is there some way to make it apply to everything but the free shipping ?
if ($format && (int)$value == 0) {
return 'coming soon';
}
it shows up perfect.
however when you have pickup for shipping its show ups as:
Pickup Up: and in the price instead of 0.00 is shown as 'coming soon'
which is a problem i completely understand why... but
is there some way to make it apply to everything but the free shipping ?
- nzjollyroger
- Posts: 54
- Joined: Sun Nov 15, 2009 9:26 pm
Re: [Mod]Displaying something other than $0 if no price is given
nzjollyroger wrote:however when you have pickup for shipping its show ups as:
is there some way to make it apply to everything but the free shipping ?
Try this:
- Code: Select all
if ($format && (int)$value == 0) {
$trace = debug_backtrace();
if (isset($trace[1]) && $trace[1]['class'] == 'ModelShippingFree') {
return "0.00";
} else {
return 'coming soon';
}
}

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18209
- Joined: Mon Jul 21, 2008 7:02 pm

Re: [Mod]Displaying something other than $0 if no price is given
Qphoria wrote:nzjollyroger wrote:however when you have pickup for shipping its show ups as:
is there some way to make it apply to everything but the free shipping ?
Try this:
- Code: Select all
if ($format && (int)$value == 0) {
$trace = debug_backtrace();
if (isset($trace[1]) && $trace[1]['class'] == 'ModelShippingFree') {
return "0.00";
} else {
return 'coming soon';
}
}
Qphoria wrote:Burrito is correct. The way options were designed in OpenCart was to make the product price the default option price. Leaving the default option at 0.00
Example
Ok, I understand this.
But,... I have only one price for the product with 4 diferent optional samples (their price = 0€)
When add a product in this way:
product_A - 12.10 €
options: sample_1 - 0 €, sample _2 - 0 €, sample_3 - 0 €, sample_4 - 0 €
.... The price is clearly visible, but when the product is added to the basket, there is no price, only is displayed 0.00 €, do not fall in the amount of purchase!
and when add a product in second way:
product_A - 0.00 €
options: sample_1 - 12.10 €, sample _2 - 12.10 €, sample_3 - 12.10 €, sample_4 - 12.10 €
Now price is visible in the cart and counted to sub-total but on the product list and view the price of product_A is 0.00 €! I think this is a little frivolous to our customers.
I tried this code:
if ($format && (int)$value == 0) {
$trace = debug_backtrace();
if (isset($trace[1]) && $trace[1]['class'] == 'ModelShippingFree') {
return "0.00";
} else {
return 'Price depends on choice options';
}
}
I think it's not really suitable solution because it is essentially only one price for this product. I have also a few items without options, but their price is less than 1, for example price is € 0.45 and in these item is still visible sign "Price depends on choice options" instead of price!
Otherwise I really like OpenCart. Is friendly, transparent, modern, and so I decided that I worked with him (until now I have used Zencart).
I hope you will help me in eliminating errors and defects that sometimes occur.
Thanks in advance
PS: I Using OC v1.4.4
- pepiw
- Posts: 4
- Joined: Thu Mar 25, 2010 11:17 am
Re: [Mod]Displaying something other than $0 if no price is given
Thanks this works nicely
My sold products are now in a Category called Sold and they show SOLD instead of a price.
My Free Shipping shows as 0.00 in Delivery Information
But here's the problem, in the final step of the checkout under Totals
the Free Shipping item shows as SOLD
My sold products are now in a Category called Sold and they show SOLD instead of a price.
My Free Shipping shows as 0.00 in Delivery Information
But here's the problem, in the final step of the checkout under Totals
the Free Shipping item shows as SOLD
OpenCart Newbie | Using v1.5.1.1
- Marcel
- Posts: 29
- Joined: Mon Mar 08, 2010 7:04 pm
- Location: Colorado
Re: [Mod]Displaying something other than $0 if no price is given
Anybody …I need to fix this problem with SOLD displaying in the Totals column instead of 0.00
OpenCart Newbie | Using v1.5.1.1
- Marcel
- Posts: 29
- Joined: Mon Mar 08, 2010 7:04 pm
- Location: Colorado
Re: [Mod]Displaying something other than $0 if no price is g
When using anything in a product but 0.00 you cannot access free checkout, which defeats the object for me. Any ideas anyone?
I want one specific product to provide a POA type message and the customer be able to complete the order.
Cheers
I want one specific product to provide a POA type message and the customer be able to complete the order.
Cheers
A stupid question is the one you -don't- ask.........(Anon)
)C1.5.0.1 (IN devel)
OC V1.4.9.5
OC V1.4.9.2
OC V1.4.7
OC V1.3.4
)C1.5.0.1 (IN devel)
OC V1.4.9.5
OC V1.4.9.2
OC V1.4.7
OC V1.3.4
-

cmebd - Posts: 405
- Joined: Fri Nov 13, 2009 3:17 am
- Location: Tasmania, Australia
Re: Displaying something other than $0 when no price is give
Qphoria wrote:A little trick to make this a lot easier for you..
Remember all prices pass through the currency->format() function, even if they are 0
1. EDIT: system/library/currency.php (or system/helper/currency.php for certain versions)
2. FIND:
- Code: Select all
$string = '';
3. BEFORE, ADD:
- Code: Select all
if ($format && (int)$value == 0) {
return 'FREE';
}
That's it! One file handles ALL places.. even custom mods are automatically changed
Hi Qphoria,
Concerning the above post I quoted:
is there any way you can display the hardcoded text (in this case 'FREE') in multiple languages?
I'm stuck at that part...

Dimitri Backaert
Web Development, OOP, .NET, IBM Cognos BI, SQL
Web Development, OOP, .NET, IBM Cognos BI, SQL
- dbe
- Posts: 48
- Joined: Tue Sep 21, 2010 5:01 pm
- Location: Erembodegem - Belgium
Re: [Mod]Displaying something other than $0 if no price is g
add an entry into the main language file for each language (english.php, spanish.php, etc)
Then change the currency.php file to use
- Code: Select all
$_['text_free'] = 'Free';
Then change the currency.php file to use
- Code: Select all
if ($format && (int)$value == 0) {
return $this->language->get('text_free');
}

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18209
- Joined: Mon Jul 21, 2008 7:02 pm

Re: [Mod]Displaying something other than $0 if no price is g
Qphoria wrote:add an entry into the main language file for each language (english.php, spanish.php, etc)
- Code: Select all
$_['text_free'] = 'Free';
Then change the currency.php file to use
- Code: Select all
if ($format && (int)$value == 0) {
return $this->language->get('text_free');
}
Hi Qphoria,
Thanks for the solution.
In the Front End, it works.
In the Admin part however, i get the message 'text_no_price' (which is the name of my language file entry).
Any solution for that?
Greets
Dimitri Backaert
Web Development, OOP, .NET, IBM Cognos BI, SQL
Web Development, OOP, .NET, IBM Cognos BI, SQL
- dbe
- Posts: 48
- Joined: Tue Sep 21, 2010 5:01 pm
- Location: Erembodegem - Belgium
Re: [Mod]Displaying something other than $0 if no price is g
You need to put that same in the admin/language/english/english.php file

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18209
- Joined: Mon Jul 21, 2008 7:02 pm

Re: [Mod]Displaying something other than $0 if no price is g
I See...
The Admin section has a separate language file.
Thanks for pointing that out.
I seem to have some other problems now.
All products having the standard text value 'FREE' are messing up the actual shopping cart.
When adding these products to the cart, the subtotal and total values don't seem to be working
correctly.
Ideally, a customer should not be able to add these products to the shopping cart.
In fact, this section should be some sort of image gallery, displaying the product examples, and
having a standard text or a link to an e-mail address, to ask for more information.
The Admin section has a separate language file.
Thanks for pointing that out.
I seem to have some other problems now.
All products having the standard text value 'FREE' are messing up the actual shopping cart.
When adding these products to the cart, the subtotal and total values don't seem to be working
correctly.
Ideally, a customer should not be able to add these products to the shopping cart.
In fact, this section should be some sort of image gallery, displaying the product examples, and
having a standard text or a link to an e-mail address, to ask for more information.
Dimitri Backaert
Web Development, OOP, .NET, IBM Cognos BI, SQL
Web Development, OOP, .NET, IBM Cognos BI, SQL
- dbe
- Posts: 48
- Joined: Tue Sep 21, 2010 5:01 pm
- Location: Erembodegem - Belgium
49 posts
• Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 9 guests













