Jump to content

Hide "Add to cart" button when product is sold out


Recommended Posts

Try this in your product.tpl file.

{* add to cart btn *}

{if $product->quantity > 0}

<p id="add_to_cart" {if (!$allow_oosp && $product->quantity <= 0) OR !$product->available_for_order OR (isset($restricted_country_mode) AND $restricted_country_mode) OR $PS_CATALOG_MODE} style="display:none;"{/if}>

<a class="exclusive" href="javascript:document.getElementById('add2cartbtn').click();">{l s='Add to cart'}</a>

<input id="add2cartbtn" type="submit" name="Submit" value="{l s='Add to cart'}" />

</p>

{/if}

 

- It checks first to determine whether the product quantity is zero or not before proceeding with other checks in displaying the add to cart button.

 

Hope that helps. :)

Link to comment
Share on other sites

Just go to the products tab and set to not allow ordering of out of stock products, no need to edit and modify files for this.

Always post your version as the options can be slightly different from one version to the next.

 

Preferences, Products - Allow ordering out of stock products -set to NO

 

image from 1.4 but is same for 1.5.

 

 

Link to comment
Share on other sites

To hide it that patch on the product.tpl file will work but to disable it the option by tdr170 will work. Then to replace the code it should be around line 290 to 295 of ypur product.tpl file. - I use a different theme and PS version 1.4.7 and cannot give a specific line. But look for the code that displays the add to cart button and sorround it with this code {if $product->quantity > 0} {/if} or upload your product.tpl file I tell you the specific lines to edit.

Link to comment
Share on other sites

Hi tdr170, thanks for the reply.

 

I need to hide it because of the cart button positioning issue.

 

I have gotten a web host account today. Once I resolved the error 500 issue on the web, I will show you my website to see the problem. Thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...