Page 2 of 4

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Sat Sep 25, 2010 8:41 pm
by i2Paq
Have a good look at: Hide add to cart button for items not in stock?, here you find everything you need.

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Sat Sep 25, 2010 11:10 pm
by dbe
Thanks i2Paq, I'll check it out!

The problem with this forum is, that there's loads of information available, but it gets hard finding the
right URL's...

Gr33tz

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Thu Nov 11, 2010 1:19 pm
by dramony
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';
	}
}
Doesn't work on the Pick-up from Store

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Fri Nov 12, 2010 11:08 am
by Qphoria
I'm sure it does. Be sure you have the controller name correct

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Fri Nov 12, 2010 12:16 pm
by dramony
Thanks Q! In my case i used ModelShippingPickup so that 0.00 will appear on the Pick-up shipping page.
However, it doesnt appear right on the Cart module. Need more tweaks Q. Thanks again.

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Thu Nov 18, 2010 4:13 pm
by deeve
Hi Q,
is there a way to make the text substitution in this MOD only show once in Product Description page & Category pages if used in combination with 'Prices shown with & without VAT' - currently I get 'Call for Price' twice.. I'm using the code suggested in these two threads:

http://forum.opencart.com/viewtopic.php ... 25&start=0
http://forum.opencart.com/viewtopic.php ... 54#p112554

Thanks.

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Wed Dec 15, 2010 1:12 am
by webmom
Hi! I just upgraded to 4.9.1. I have Q's Option Price Update and Options Plus Mods installed - we sell things using weight-based options. I am trying to get this to work so that instead of a $0.00 price, it says "Please select weight option"
However, as the page loads, I can see the text "Please select weight option" flash - but then it disappears and is replaced with $NaN as the price. Selecting a weight option does not update the price (it remains $NaN). I appreciate any help - this is my first Opencart installation and so far it has been great!

Edit: Just to be clear - I am trying to make this work using the single edit to currency.php.

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Fri Jan 07, 2011 8:55 pm
by deeve
Marcel wrote: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
..just wondered if anyone came up with a solution to this particular question +same problem appears in Product Options?

Thanks.

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Mon Jan 10, 2011 7:59 am
by deeve
I've been going over the php files for the 'checkout' & 'product options' controllers & suspect there's a way to use a line similar to

Code: Select all

if (isset($trace[1]) && $trace[1]['class'] == 'ModelShippingFree') {
in system/currency.php to specify those classes as well but can't for the life of me work out how to declare them!

Can anyone please enlighten me ..it's getting late here!

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Wed Jan 12, 2011 12:58 am
by deeve
Feels like I'm writing to myself on here these days :-\

I thought I needed to declare the 'ControllerCheckoutConfirm' class as well to solve the checkout problem but has had no effect when written like this:

Code: Select all

if ($format && (int)$value == 0) {
   			$trace = debug_backtrace();
   		if (isset($trace[1]) && $trace[1]['class'] == 'ModelShippingFree') {
      		return "£0.00";
   		} elseif (isset($trace[1]) && $trace[1]['class'] == 'ControllerCheckoutShipping') {
			return "£0.00";
		} else	{
      		return 'Call for Price';
   		}
		}
Anyone have any suggestions?

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Thu Jan 13, 2011 1:24 am
by deeve
Am going to continue talking to myself :D as the solutions I'm discovering may be of use to other php newbies like me..
Well, I have managed to solve the Checkout problem [only by lots of trial & error]:

Code: Select all

if ($format && (int)$value == 0) {
   			$trace = debug_backtrace();
   		if (isset($trace[1]) && $trace[1]['class'] == 'ModelShippingFree') {
      		return "£0.00";
		} elseif (isset($trace[1]) && $trace[1]['class'] == 'ModelTotalShipping') {
      		return "£0.00";
		} else {
      		return 'Call for Price';
   		}
		}
This works great but am still left with the problem of trying to display £0.00 within the Product Options drop-down list.. Feel free to chip in if anyone knows ;)

Got a hunch it should be 'ModelCatalogProduct' but how to separate this from Product's price & also am not sure you can have more than one instance of elseif ??

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Thu Jan 13, 2011 5:48 pm
by deeve
Okay, here's an interesting anomaly; I've just realized that within the product Options drop-down list, the items which are declared as +0.00 actually have nothing showing as an additional value, yet any item which has an additional value between 0 & 1, ie: +0.85 are the ones now showing as 'Call for Price'.

I've tried changing the initial line to:

Code: Select all

if ($format && (int)$value == 0.0000) {

&

Code: Select all

if ($format && (int)$value == 0.00) {
but with no joy.

Any ideas, feel free to pitch in.. ;)

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Thu Jan 13, 2011 6:12 pm
by deeve
Problem solved! All it needed was anextra '=' in the first line:

Code: Select all

if ($format && (int)$value === 0.00) {
   			$trace = debug_backtrace();
   		if (isset($trace[1]) && $trace[1]['class'] == 'ModelShippingFree') {
      		return "£0.00";
		} elseif (isset($trace[1]) && $trace[1]['class'] == 'ModelTotalShipping') {
      		return "£0.00";
		} else {
      		return 'Call for Price';
   		}
		}
**Added after I posted**

Not quite! Now the product's price is showing as £0.00 again - doh!

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Fri Jan 14, 2011 12:36 am
by deeve
Im really getting FED UP with this !! Now I get 'Call for Price' as it should be in Category view but then 0 in Product view ???

Code: Select all

if ($format && (int)$value == 0.00) {
   			$trace = debug_backtrace();
   		if (isset($trace[1]) && $trace[1]['class'] === 'ModelShippingFree') {
      		return "£0.00";
		} elseif (isset($trace[1]) && $trace[1]['class'] === 'ModelTotalShipping') {
      		return "£0.00";
		} elseif (isset($trace[1]) && $trace[1]['class'] === 'ControllerProductProduct') {
      		return "$value";
		} else {
      		return 'Call for Price';
   		}
		}
There has to be a way to distinguish between Option value and Product price..
Is there anyone still alive on this forum?

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Fri Jan 14, 2011 1:05 am
by Qphoria
There is no way to distinguish option value and product price because the calls for the currency format come from the product controller

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Fri Jan 14, 2011 10:01 pm
by deeve
Bummer, but thanks for clearing that up, Q.
I shall have no other option than to create a static Satellite page for those products then.

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Fri Aug 05, 2011 3:06 pm
by Jojon
whether it can support OpenCart v.1.5.1.1 ? :)

Re: Displaying something other than $0 when no price is give

Posted: Fri Sep 02, 2011 1:01 am
by ivex
Qphoria you are a freakin genius!!!.......thanks so much.....works perfectly in 1.4.9.3
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 && (float)$value == 0) {
	return 'FREE';
}
That's it! One file handles ALL places.. even custom mods are automatically changed

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Fri Nov 11, 2011 5:23 pm
by DJB31st
Just to clarify for anyone going through this post that you MUST use


if ($format && (float)$value == 0) {

rather than with an INT

If you use an INT anything at £0.99 or below will show as FREE

Re: [Mod]Displaying something other than $0 if no price is g

Posted: Wed Dec 14, 2011 11:12 am
by mldnkslvc
deeve wrote:Im really getting FED UP with this !! Now I get 'Call for Price' as it should be in Category view but then 0 in Product view ???

Code: Select all

if ($format && (int)$value == 0.00) {
   			$trace = debug_backtrace();
   		if (isset($trace[1]) && $trace[1]['class'] === 'ModelShippingFree') {
      		return "£0.00";
		} elseif (isset($trace[1]) && $trace[1]['class'] === 'ModelTotalShipping') {
      		return "£0.00";
		} elseif (isset($trace[1]) && $trace[1]['class'] === 'ControllerProductProduct') {
      		return "$value";
		} else {
      		return 'Call for Price';
   		}
		}
There has to be a way to distinguish between Option value and Product price..
Is there anyone still alive on this forum?
Hi... elseif (isset($trace[1]) && $trace[1]['class'] === 'ControllerProductProduct') {
return "$value";
} this code is reduntant because it's said in the code above that if an amount is equal to 0 it displays call for price so all you need to do is to set product's price to 0 and it displays call for price on zero priced products.and another thing your code says to put a price in zero priced products.
to more expirienced programmers:

the code above works fine except it is now showing call for price instead of 0,00 amount in my cart in header.

i tried adding elseif ($trace[1] && $trace[1]['class'] === 'ControllerCheckoutCart') {
return "$value.00$symbol_right";
}
but it doesn't do the trick. what needs to be done to sort this out.Thanks in advance.