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.
I believe this is not possible.
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
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:
AFTER:
ADD:
2. IN:
AFTER:
ADD:
3. IN:
REPLACE:
WITH:
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.
1. IN:
Code: Select all
/catalog/model/catalog/product.php
Code: Select all
'prefix' => $product_option_value['prefix']
Code: Select all
, 'quantity' => $product_option_value['quantity']
Code: Select all
/catalog/controller/product/product.php
Code: Select all
'prefix' => $option_value['prefix']
Code: Select all
, 'quantity' => $option_value['quantity']
Code: Select all
/catalog/view/theme/YOURTHEME/template/product/product.tpl
Code: Select all
><?php echo $option_value['name']; ?>
Code: Select all
<?php if($option_value['quantity'] == '0') {
echo ' disabled="disabled">' . $option_value['name'] . ' (sold out)';
} else {
echo '>' . $option_value['name'];
} ?>
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:
Find:
Replace with:
Basically.... if it's Out Of Stock it replaces the "Qty: #" and "Add to Cart" button with text that simply says "Out of Stock".
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
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 } ?>
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 } ?>
Who is online
Users browsing this forum: No registered users and 103 guests