Page 1 of 1
Product Option Quantity
Posted: Wed Mar 27, 2013 5:54 pm
by Meeker
Hi I am looking for someone to do a tiny bit of custom work please. I need to have the number of items left in stock displayed for a Product Option. See my post below.
http://forum.opencart.com/viewtopic.php ... 10#p393310
I think it is a simple job to do, but my php is not good enough. Anyone interested in quoting?
Re: Product Option Quantity
Posted: Wed Mar 27, 2013 6:36 pm
by grgr
catalog/controller/product/product.php
replace
with
Code: Select all
($option_value['name'] . " [" . $option_value['quantity'] . "]"),
Re: Product Option Quantity
Posted: Wed Mar 27, 2013 6:54 pm
by Meeker
Hi grgr,
Thanks for your reply. When I amend this on the front end, I get:
Example Option 1 []
Example Option 2 []
I tried with and without the code from the previous post in the theme/template/product/product.tpl file, but no joy. I think we are getting closer!
Re: Product Option Quantity
Posted: Wed Mar 27, 2013 6:55 pm
by Meeker
PS, I also found this in very small text at the top of the page - Notice: Undefined index: quantity in /home/linweb08/c/crawfordsmd.com-1048376755/user/htdocs/catalog/controller/product/product.php on line 266Notice: Undefined index: quantity in /home/linweb08/c/crawfordsmd.com-1048376755/user/htdocs/catalog/controller/product/product.php on line 266
Re: Product Option Quantity
Posted: Wed Mar 27, 2013 9:47 pm
by straightlight
replace:
Code: Select all
($option_value['name'] . " [" . $option_value['quantity'] . "]"),
with:
Code: Select all
(!empty($option_value['quantity'])) ? html_entity_decode($option_value['name'], ENT_QUOTES, 'UTF-8') . ' [' . (int)$option_value['quantity'] . ']' : html_entity_decode($option_value['name'], ENT_QUOTES, 'UTF-8') . ' [0]',
Re: Product Option Quantity
Posted: Wed Mar 27, 2013 9:56 pm
by Meeker
Editing catalog/controller/product/product.php produces in the Product Option dropdown on the frontend:
Example Option 1 [0]
Example Option 2 [0]
The error message at the top has disappeared though.
Re: Product Option Quantity
Posted: Wed Mar 27, 2013 10:54 pm
by straightlight
The [0] either means that the option quantity has not been queried from the models or the true value of those quantities are truly as the found quantity result.
Re: Product Option Quantity
Posted: Wed Mar 27, 2013 11:01 pm
by paulfeakins
Yes it seems like option quantities haven't been entered properly?
Are you using an extension such as OpenStock for this?
Re: Product Option Quantity
Posted: Wed Mar 27, 2013 11:06 pm
by Meeker
No I haven't. Would either of you be interested in a paid job to fix this for me? Send me a PM.
Re: Product Option Quantity
Posted: Wed Apr 03, 2013 5:40 pm
by Meeker
Hi all, I finally found a solution.
In catalog/controller/product/product.php around line 266, find:
FIND:
REPLACE WITH:
Code: Select all
'name' => (!empty($option_value['quantity'])) ? html_entity_decode($option_value['name'], ENT_QUOTES, 'UTF-8') . ' [' . (int)$option_value['quantity'] . ']' : html_entity_decode($option_value['name'], ENT_QUOTES, 'UTF-8') . ' [0]',
Thanks....
Re: Product Option Quantity
Posted: Thu Apr 04, 2013 10:59 pm
by paulfeakins
And also don't forget there needs to be a small change in the product model so that $option_value['quantity'] is available!