Post by darren » Sun Jan 10, 2010 1:16 am

Hi all,

Was wondering if there was a way to remove the 'Add to Cart' button if the product matched a certain type of Availability status?

I know that the visitor won't be able to proceed to the checkout if the product is out of stock; just wondered if there was a way to achieve the above question.

Thanks,
Darren

Newbie

Posts

Joined
Sun Jan 10, 2010 1:11 am

Post by Qphoria » Sun Jan 10, 2010 1:56 am

1. EDIT: catalog/view/theme/YOURTHEME/template/product/product.tpl

2. FIND:

Code: Select all

<div style="background: #F7F7F7; border: 1px solid #DDDDDD; padding: 10px;"><?php echo $text_qty; ?>
                <input type="text" name="quantity" size="3" value="1" />
                <a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a></div>

3. REPLACE WITH:

Code: Select all

<?php if ($stock != "Out Of Stock") {?>
<div style="background: #F7F7F7; border: 1px solid #DDDDDD; padding: 10px;"><?php echo $text_qty; ?>
                <input type="text" name="quantity" size="3" value="1" />
                <a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a></div>
<?php } ?>

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by darren » Sun Jan 10, 2010 10:10 pm

Thanks for taking the time to reply.

I've done what you suggested, but the Add to Cart button is still there for products which are out of stock.

Any other ideas? Thanks.

Newbie

Posts

Joined
Sun Jan 10, 2010 1:11 am

Post by Qphoria » Mon Jan 11, 2010 1:35 am

Ah yea.. sorry.. forgot it only show the stock count when instock.
I also had the code in the wrong place. I've updated the code above.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by darren » Mon Jan 11, 2010 3:57 am

Thanks very much, it now works exactly how we wanted. :)

Newbie

Posts

Joined
Sun Jan 10, 2010 1:11 am

Post by Yakiv » Mon Jan 11, 2010 4:33 am

Wondering if this will be fixed in 1.3.5?

Active Member

Posts

Joined
Tue Dec 15, 2009 5:31 pm

Post by Qphoria » Mon Jan 11, 2010 5:53 am

It would have to be "broke" to be fixed. The actual stock check is done at the cart page, which is the most secure. Technically I could just hack the source with FF and add an add to cart button if i really wanted. But the cart page checks if it is in stock or not before going to checkout.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by momtrepreneur » Wed Apr 21, 2010 3:15 am

Just wondering if there was an update for this code for Version 1.4.4? I would like to still have the product show but an "Out of Stock" status for the add to cart button or something similiar to that. I tried the above code but got no results. Any Ideas?

Opencart 1.4.9.1
Global Options Mod


New member

Posts

Joined
Wed Apr 21, 2010 2:27 am
Who is online

Users browsing this forum: Bing [Bot] and 19 guests