Post by dashik » Sat Nov 14, 2009 8:52 am

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.

New member

Posts

Joined
Fri Jul 31, 2009 8:10 pm

Post by fido-x » Sat Nov 14, 2009 9:34 am

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

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
insert:

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;
	}
}

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by dashik » Sat Nov 14, 2009 1:42 pm

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

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;
						
					}

New member

Posts

Joined
Fri Jul 31, 2009 8:10 pm

Post by fido-x » Sat Nov 14, 2009 2:25 pm

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:

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,

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by dashik » Sat Nov 14, 2009 8:58 pm

Absolutely spot on! Thank you :)

New member

Posts

Joined
Fri Jul 31, 2009 8:10 pm

Post by Donce » Sun Nov 15, 2009 12:53 am

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!

New member

Posts

Joined
Fri Aug 28, 2009 8:22 pm

Post by Qphoria » Sun Nov 15, 2009 6:46 am

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 && (float)$value == 0) {
	return 'FREE';
}
That's it! One file handles ALL places.. even custom mods are automatically changed

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Donce » Sun Nov 15, 2009 8:11 am

Cha!
awesome, works! Thank you very much!

New member

Posts

Joined
Fri Aug 28, 2009 8:22 pm

Post by dashik » Sun Nov 15, 2009 12:11 pm

Good stuff!

New member

Posts

Joined
Fri Jul 31, 2009 8:10 pm

Post by nzjollyroger » Mon Feb 08, 2010 8:22 am

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 ?

New member

Posts

Joined
Mon Nov 16, 2009 5:26 am

Post by Qphoria » Thu Feb 11, 2010 8:57 pm

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';
	}
}

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by pepiw » Tue Mar 30, 2010 9:39 am

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

Newbie

Posts

Joined
Thu Mar 25, 2010 7:17 pm

Post by Marcel » Wed Mar 31, 2010 5:44 am

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

OpenCart Newbie | Using v1.5.1.1


New member

Posts

Joined
Tue Mar 09, 2010 3:04 am
Location - Colorado

Post by Marcel » Thu Apr 01, 2010 2:39 am

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


New member

Posts

Joined
Tue Mar 09, 2010 3:04 am
Location - Colorado

Post by cmebd » Mon Jul 19, 2010 2:12 am

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

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


User avatar
Active Member

Posts

Joined
Fri Nov 13, 2009 11:17 am
Location - Tasmania, Australia

Post by dbe » Thu Sep 23, 2010 10:11 pm

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, Application Development, OOP, .NET, IBM Cognos BI


User avatar
dbe
New member

Posts

Joined
Wed Sep 22, 2010 1:01 am
Location - Erembodegem - Belgium

Post by Qphoria » Thu Sep 23, 2010 11:25 pm

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');
}

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by dbe » Fri Sep 24, 2010 1:43 am

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, Application Development, OOP, .NET, IBM Cognos BI


User avatar
dbe
New member

Posts

Joined
Wed Sep 22, 2010 1:01 am
Location - Erembodegem - Belgium

Post by Qphoria » Fri Sep 24, 2010 3:11 am

You need to put that same in the admin/language/english/english.php file

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by dbe » Fri Sep 24, 2010 11:44 pm

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.

Dimitri Backaert
Web Development, Application Development, OOP, .NET, IBM Cognos BI


User avatar
dbe
New member

Posts

Joined
Wed Sep 22, 2010 1:01 am
Location - Erembodegem - Belgium
Who is online

Users browsing this forum: No registered users and 7 guests