Page 1 of 1
Making "Out of stock" options unable to add to the cart
Posted: Thu Dec 09, 2010 11:02 am
by rezter
I was wondering if it's possible to make items that have options appear as "Out of Stock" in the drop down menu and then impossible to add to the cart? For example: I am selling clothing items so I have the options of sizes, but users can still add the item to their cart if it's out of stock in the selected size. I realize that it comes up with a warning in the shopping cart and stops them from checking out but I would prefer if they couldn't add it to the cart to begin with.
Re: Making "Out of stock" options unable to add to the cart
Posted: Thu Dec 09, 2010 7:48 pm
by i2Paq
I believe this is not possible.
Re: Making "Out of stock" options unable to add to the cart
Posted: Thu Dec 09, 2010 7:50 pm
by JAY6390
You could do it,but it would require quite a bit of hacking to get right, it's certainly no easy feat
Re: Making "Out of stock" options unable to add to the cart
Posted: Fri Dec 10, 2010 1:47 am
by Johnathan
It's actually not that hard, you just have to disable the option when there's no quantity. I do this on my site
A Trade For A Trade. For an example, take a look at
this product. Here are the edits required:
1. IN:
Code: Select all
/catalog/model/catalog/product.php
AFTER:
Code: Select all
'prefix' => $product_option_value['prefix']
ADD:
Code: Select all
, 'quantity' => $product_option_value['quantity']
2. IN:
Code: Select all
/catalog/controller/product/product.php
AFTER:
Code: Select all
'prefix' => $option_value['prefix']
ADD:
Code: Select all
, 'quantity' => $option_value['quantity']
3. IN:
Code: Select all
/catalog/view/theme/YOURTHEME/template/product/product.tpl
REPLACE:
Code: Select all
><?php echo $option_value['name']; ?>
WITH:
Code: Select all
<?php if($option_value['quantity'] == '0') {
echo ' disabled="disabled">' . $option_value['name'] . ' (sold out)';
} else {
echo '>' . $option_value['name'];
} ?>
The only caveat is that the first option sort-wise should have stock, or else it will be selected by default when the page loads. I'm sure there's a way around this (e.g. using jQuery) if someone wants to take the time to figure it out.
Re: Making "Out of stock" options unable to add to the cart
Posted: Sat Dec 11, 2010 11:49 am
by rezter
Thank you very much bro. It seems to work perfectly for me even when I deliberately put an out of stock option as the first in the sort order it automatically went to the next one upon loading the page so it is impossible to add it to the cart. Much appreciated my friend.
It may also be noted that if the item is out of stock (irrespective of the options) it can still be added to the cart... you are stopped in the cart by a notice and you can't progress to purchasing it but my aim was to stop people adding out of stock items to their cart. So what I did to resolve it was very simply used this code:
In:
Code: Select all
/catalog/view/theme/YOURTHEME/template/product/product.tpl
Find:
Code: Select all
<?php echo $text_qty; ?>
<input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
<a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a>
<?php if ($minimum > 1) { ?><br/><small><?php echo $text_minimum; ?></small><?php } ?>
Replace with:
Code: Select all
<?php if($product_info['quantity'] == '0') { echo $stock; } else { echo $text_qty; ?>
<input type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" />
<a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a>
<?php if ($minimum > 1) { ?><br/><small><?php echo $text_minimum; ?></small><?php } ?>
<?php } ?>
Basically.... if it's Out Of Stock it replaces the "Qty: #" and "Add to Cart" button with text that simply says "Out of Stock".
Re: Making "Out of stock" options unable to add to the cart
Posted: Sat Dec 11, 2010 11:07 pm
by Johnathan
Yeah, I do the same thing on A Trade For A Trade. As a customer, I prefer it when I don't have to jump through hoops to find out if I can order a product or not.
Re: Making "Out of stock" options unable to add to the cart
Posted: Mon Oct 03, 2011 9:15 pm
by sekmo
Now in the 1.5 there's an option for that, right?