Jump to content

Show add to cart button if the goods have 1 attribute


habross

Recommended Posts

Hello,


I have a delicate problem. The administration can enable or disable the add to cart button, if the goods have or haven´t attributes. I am using layered filter because I wanted to have a unified color catalog with colors in the form of attributes, It means that black chair that has no other color attributes, I set the attribute to black and now the search is located among others. But there does not appear click add to cart.


Therefore, the question is: Does anyone know where in the code to set this condition to click Add to Cart if the goods have one attribute? If 2 or more obviously make this button disappearing.


Thanks for any ideas

Link to comment
Share on other sites

The code you are looking for is in the product-list.tpl file in your theme. There you will find the following fragment

{if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.customizable != 2 && !$PS_CATALOG_MODE}
  {if (!isset($product.customization_required) || !$product.customization_required) && ($product.allow_oosp || $product.quantity > 0)}
    {capture}add=1&id_product={$product.id_product|intval}{if isset($static_token)}&token={$static_token}{/if}{/capture}
    <a class="button ajax_add_to_cart_button btn btn-default" href="{$link->getPageLink('cart', true, NULL, $smarty.capture.default, false)|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Add to cart'}" data-id-product="{$product.id_product|intval}" data-minimal_quantity="{if isset($product.product_attribute_minimal_quantity) && $product.product_attribute_minimal_quantity > 1}{$product.product_attribute_minimal_quantity|intval}{else}{$product.minimal_quantity|intval}{/if}">
      <span>{l s='Add to cart'}</span>
    </a>
  {else}
    <span class="button ajax_add_to_cart_button btn btn-default disabled">
      <span>{l s='Add to cart'}</span>
    </span>
  {/if}
{/if}

The flag that keeps track which button should be shown when a product has attributes is "$add_prod_display".

Edited by musicmaster (see edit history)
Link to comment
Share on other sites

Hi, thank you for your reply. I try this code but nothing happend. Items having more than 1 attributes have available add to cart button anyway the items having 1 attribute. I need to hide add to cart button for items with more than 1 attributes and show this button for the items having 1 attribute.

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