Product Option Out-of-stock Warning in Option List
Posted: Fri Nov 05, 2010 5:34 am
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.

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):
Add after:
Locate catalog/model/catalog/product.php:
Find (around line 419):
Replace:
Locate catalog/controller/product/product.php:
Find (around line 252):
Add after:
Find (around line 264):
Replace:
--
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.
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.

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 } ?>
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']
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) {
Code: Select all
if($option_value['quantity'] <= 0) {
$status = ' *** Out of stock ***';
} else {
$status = '';
}
Code: Select all
'prefix' => $option_value['prefix']
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.