Jump to content

[SOLVED] Hide/disable cart button if attributes ?


Recommended Posts

In the product list page, We can hide/disable "Add to cart" button if we add a customizable field that is required.

For the moment, I modified this page as follow :

BEFORE

{if ($product.allow_oosp OR $product.quantity > 0) && $product.customizable != 2}



AFTER

{if ($product.allow_oosp OR $product.quantity > 0) && ($product.customizable != 1 AND $product.customizable != 2)}



The result is that the "Add to cart" is disable if there is a customized filed, even if it's not mandatory.


But this cannot solve my problem, since I want to hide/disable the "Add to cart" button if the product has attributes.

Has somebody any idea on how to modify the page product-list.tpl, so that I can test if the product has attributes.


Thanks

Link to comment
Share on other sites

Found :

If the product has no attributes, the variable $product.id_product_attribute = 0

{if ($product.quantity > 0 OR $product.allow_oosp) AND ($product.customizable != 1 AND $product.customizable != 2)  && $product.id_product_attribute == 0}

Link to comment
Share on other sites

  • 4 months later...
  • 8 months later...
  • 1 year later...

I want to do a similar thing - I want to hide the buy_block from the product page when a product has attributes.

 

The section of product.tpl looks like this:

 

<!-- add to cart form-->
 <form id="buy_block" {if $PS_CATALOG_MODE AND !isset($groups) AND $product->quantity > 0}class="hidden"{/if} action="{$link->getPageLink('cart.php')}" method="post">

 

I've tried applying the same logic as the "Add to cart"button above but I either get a smarty error or nothing happens.

 

Could anyone help please?

 

Cheers

Edited by pel024 (see edit history)
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...