Post by JustinBull » 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.

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.

Freelance web design & coding.
http://www.justinbull.ca


Newbie

Posts

Joined
Tue Oct 26, 2010 12:24 am

Post by Johnathan » Fri Nov 05, 2010 8:02 am

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.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by Qphoria » Fri Nov 05, 2010 9:54 am

Yea same with options plus.. disabled if out of stock.. but many people are confused by this notion.. seems there is no one method

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JustinBull » Fri Nov 05, 2010 11:12 am

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?
Last edited by JustinBull on Fri Nov 05, 2010 11:20 am, edited 1 time in total.

Freelance web design & coding.
http://www.justinbull.ca


Newbie

Posts

Joined
Tue Oct 26, 2010 12:24 am

Post by Qphoria » Fri Nov 05, 2010 11:19 am

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

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 2 guests