leowls Posted April 7, 2013 Share Posted April 7, 2013 Hi guys, Anyone knows how to hide the "Add to cart" button when your product becomes unavailable or is sold out? Can't find such option in the back office. Thanks much! Link to comment Share on other sites More sharing options...
Doulas Akula Posted April 7, 2013 Share Posted April 7, 2013 Enable stock management in back office - it will take stock of products as they decrease and for products not in stock it will show "unavailable" - you can use this attribute to hide or display the add to cart button in your product.tpl file. Link to comment Share on other sites More sharing options...
leowls Posted April 7, 2013 Author Share Posted April 7, 2013 Hi Doulas, Stock management has been enabled. How do I modify the product.tpl file? Link to comment Share on other sites More sharing options...
Doulas Akula Posted April 7, 2013 Share Posted April 7, 2013 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 More sharing options...
tdr170 Posted April 8, 2013 Share Posted April 8, 2013 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 More sharing options...
leowls Posted April 8, 2013 Author Share Posted April 8, 2013 Thanks Doulas, can you show me which line do I insert the code in in product.tpl? Link to comment Share on other sites More sharing options...
leowls Posted April 8, 2013 Author Share Posted April 8, 2013 hi tdr170, Allow ordering out of stock products has beeb set to NO, however it only disable the cart button but not hiding it. I'm using 1.5.3.1 by the way. Link to comment Share on other sites More sharing options...
Doulas Akula Posted April 8, 2013 Share Posted April 8, 2013 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 More sharing options...
tdr170 Posted April 8, 2013 Share Posted April 8, 2013 It is disabled so customers can not order no need to hide if it does not work. I guess this would be a preference issue as I see no need for hiding. Link to comment Share on other sites More sharing options...
leowls Posted April 8, 2013 Author Share Posted April 8, 2013 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now