Page 1 of 1

Product Option Out-of-stock Warning in Option List

Posted: Fri Nov 05, 2010 5:34 am
by JustinBull
Hello & sorry for the poor thread title,

I found it rather frustrating when a user/guest wanted to check out with a product with an option they didn't get notified of it's stock status until they actually attempted to pay for it.

Image

Basically speaking, the product would list 8 available, but maybe that didn't include the option the user wanted. So what I've done is a super small edit to have the Product Option drop down box display an "Out-of-stock" warning on any option that had it's stock 0 or less. Note that this is a dirty edit, and does not check your stock/quantity settings

Edit below based upon OpenCart 1.4.9.2

Locate catalog/view/theme/YOUR_THEME/template/product/product.tpl:
Find (around line 65):

Code: Select all

<?php if ($option_value['price']) { ?>
<?php echo $option_value['prefix']; ?><?php echo $option_value['price']; ?>
<?php } ?>
Add after:

Code: Select all

<?php echo $option_value['quantity']; ?>

Locate catalog/model/catalog/product.php:
Find (around line 419):

Code: Select all

'prefix'                  => $product_option_value['prefix']
Replace:

Code: Select all

'prefix'                  => $product_option_value['prefix'], 
'quantity'                => $product_option_value['quantity']

Locate catalog/controller/product/product.php:
Find (around line 252):

Code: Select all

foreach ($option['option_value'] as $option_value) {
Add after:

Code: Select all

if($option_value['quantity'] <= 0) {
	$status = ' &nbsp; *** Out of stock ***';	
} else {
	$status = '';	
}
Find (around line 264):

Code: Select all

'prefix'          => $option_value['prefix']
Replace:

Code: Select all

'prefix'          => $option_value['prefix'],
'quantity'        => $status
--
I also wanted to add that a good feature addition would have the product stock be calculated by the total number of option stocks.

For example:

I have a product My T-Shirt. Options are Red and Blue. There are 3 Blue My T-Shirts, and 4 Red My T-Shirts. Therefore the stock total for My T-Shirt would be 7.


Thanks guys.

Re: Product Option Out-of-stock Warning in Option List

Posted: Fri Nov 05, 2010 8:02 am
by Johnathan
I did almost the exact same thing at A Trade For A Trade, except I made the option non-selectable if it was out of stock. I agree it would be a good feature to add to the core.

Re: Product Option Out-of-stock Warning in Option List

Posted: Fri Nov 05, 2010 9:54 am
by Qphoria
Yea same with options plus.. disabled if out of stock.. but many people are confused by this notion.. seems there is no one method

Re: Product Option Out-of-stock Warning in Option List

Posted: Fri Nov 05, 2010 11:12 am
by JustinBull
Not to take away from your Options Plus extension, but any plan to include this in the newer version of 1.5.x?

Also, slightly unrelated, but I hear Daniel wants to change the Control/Model/View system in the new version? Is there somewhere I can read up on / contribute?

Re: Product Option Out-of-stock Warning in Option List

Posted: Fri Nov 05, 2010 11:19 am
by Qphoria
Options will be improved a lot in the next version.. there will still be some enhancements that options plus will supply, but it will be a complete overhaul because of the way options are changing