Post by traceofwind » Fri Apr 08, 2011 11:03 pm

Hi,

I have a curious problem -product options do not display when option value is less than 1. However, if I select the option by ticking the checkbox then the price will be carried into the cart correctly. I am not a PHP programmer and have tried to figure this out myself but to no avail. I have posted the basic code from the Global Mega Options provided template to provide an example.

I am using OpenCart v1.4.9.3 and am using custom templates. This problem persists in the default template and across all option types (checkbox, radio -etc).

For example, let's say we have 3 options (1) 4.29 (2) 4.29 (3) 0.94; the third option price will not display on the product.tpl page. Here's an example of how it will look:

Option1 +£4.29
Option2 +£4.29
Option3

Here is the related code:

Code: Select all

<?php echo $option_value['name']; ?>
<?php if ($option_value['price']) { ?>
<?php echo $option_value['prefix']; ?><?php echo $option_value['price']; ?>
Really hope someone can help, this has been driving me crazy.

Thanks in advance,

Gary

New member

Posts

Joined
Fri Jul 02, 2010 6:37 am

Post by traceofwind » Sat Apr 09, 2011 12:04 am

OK,
I managed to fix it. If I am not mistaken, this shouldn't have made it into released code -hopefully the author of GMO will correct me if I am wrong or update for the next release. Nonetheless, here is the fix I made:

Locate the following code:

Code: Select all

'price'           => (int)$option_value['price'] ? $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))) : FALSE,
and replace with:

Code: Select all

'price'           => (float)$option_value['price'] ? $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))) : FALSE,
in the /catalog/controller/product.product.php file.

This will register your option values with decimal precision, rather than assuming value<1 = null. At least, that is how I understand it!

All the best,

Gary

New member

Posts

Joined
Fri Jul 02, 2010 6:37 am

Post by mberlant » Sun Apr 10, 2011 9:35 pm

I would suppose that this behavior is by design and not by error. OC has several locations where specifying a precedence of -1 leaves the entry active but hidden.

For example, this convention is useful for hiding a category or product that should be available to certain customers without having to put the customer into a special customer group. A good example is for a store that sells via eBay. Upon closing of the auction, the store owner sends an email to the winner advising the winner to "click this link to pay for your item." The winner is then brought to this hidden "product" in the seller's OC store, which was added just for him or her. In this case, it would be impossible to classify the customer into a particular restricted customer group because the store operator does not yet know the customer registration information of the winner.

I imagine that some store operator could get creative with having hidden options, if so desired, and this convention being built into the Options functionality would make sense, as it fits with the same convention applied elsewhere in OC.

Please use proper English at all times, so that all members may understand you.


User avatar
Active Member

Posts

Joined
Sun Mar 13, 2011 8:33 pm

Post by traceofwind » Sun Apr 10, 2011 10:37 pm

Thanks for the reply, mberlant, I am sure it will help others decide whether or not to amend the code as I did.

Cheers

New member

Posts

Joined
Fri Jul 02, 2010 6:37 am

Post by robster » Sun Jun 19, 2011 3:45 am

Very useful post - thanks. I updated the code and now it works for prices under £1.

robster

I know my place...!


User avatar
Active Member

Posts

Joined
Tue Jul 13, 2010 8:08 pm
Location - North Yorkshire, UK

Post by otix » Wed Mar 07, 2018 3:56 am

Same on opencart v.2.3.0.2 - prices are not shown if price set less that 1 EUR.
Any recommendation?

Newbie

Posts

Joined
Tue Feb 13, 2018 10:04 pm
Who is online

Users browsing this forum: No registered users and 10 guests