Jump to content

[solved] Disable add to cart button in product_list.tpl


Recommended Posts

I've searched how to do this but only found information for product.tpl and am not sure how to incorporate it into product_list.tpl.

 

If you look at the site:

http://boojh.x10host...-alexander?&p=4

 

Scroll down and see the piece that is sold out...3rd row....the greyed out button seems to throw the layout a bit off and it kind of looks odd.

 

Is there anyway to hide this so I can avoid the weird formatting?

 

Thanks so much.

Link to comment
Share on other sites

in the product-list.tpl you can find code like this:

{if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.minimal_quantity <= 1 && $product.customizable != 2 && !$PS_CATALOG_MODE}
 {if ($product.allow_oosp || $product.quantity > 0)}
  {if isset($static_token)}
   <a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}&token={$static_token}", false)}" title="{l s='Add to cart'}"><span></span>{l s='Add to cart'}</a>
  {else}
   <a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add=1&id_product={$product.id_product|intval}", false)}" title="{l s='Add to cart'}"><span></span>{l s='Add to cart'}</a>
  {/if}	 
 {else}
  <span class="exclusive"><span></span>{l s='Add to cart'}</span><br />
 {/if}
   {/if}

 

comment / remove it

Link to comment
Share on other sites

Hi tdr170,

 

I have the following setup....

Under Preferences ->Products ->Products stock

No for Allow ordering of out-of-stock products

 

What that will do is disable the add to cart button onthe product page (which is great)

and it will also disable the add to cart button on the product list

 

What I would like to do, is in the product list, hid the add to cart button if a product quantity =0

The reason I would like to do this, is becuase my product list page is setup as a grid, and the add the add to cart button that shows when a product is sold out makes the format look odd.

 

I am including a picture. If you see where I have circled in red. When a product is sold out the Grey add to cart button shows, but unfortunately it overlaps with the product below it.

 

Ideally I'd like it to disappear for that product. If it cannot be done that is ok.

 

I was hoping there would be something like

if quantity = 0 then don't show the add to cart button

else

show it

 

but to be honest, I am not quite sure how to go about doing that.

 

If I am unclear, I do apologize. I can see in my mind what I want to achieve, but sometimes describing it in writing is harder.

 

Thank you again,

Violet

post-614734-0-87982400-1375724590_thumb.jpg

Link to comment
Share on other sites

The problem is actually an empty <p id></p> , probably added when adding the text out of stock or so.

This gives problems, as all <p> tags have a padding bottom of 20px (see right in picture) turning this off makes the layout look ok.

 

 

pascal

post-455771-0-74857700-1375726723_thumb.jpg

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...