Jump to content

Change add to cart button color in relationship category ID


Recommended Posts

Hello, i need to setting different color for button "add to cart" different for each category. 

 

I see this post but is for old version of Prestashop (i use 1.6.1.4). I try to setting this code but nothing chage. What can i do to setting different color?

 

This is my code that i've try:

 

On product-list.tpl
 

<div class="button-container">
              {if $ category-> id == 15}-argomenti {/ if}
{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($product.id_product_attribute) && $product.id_product_attribute}&ipa={$product.id_product_attribute|intval}{/if}{if isset($static_token)}&token={$static_token}{/if}{/capture}
<a class="buttonmyshopBlu 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-attribute="{$product.id_product_attribute|intval}" 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="buttonmyshopBlu button ajax_add_to_cart_button btn btn-default disabled">
<span>{l s='Add to cart'}</span>
</span>
{/if}
{/if}
<a class="buttonmyshopOrange button lnk_view btn btn-default" href="{$product.link|escape:'html':'UTF-8'}" title="{l s='View'}">
<span>{if (isset($product.customization_required) && $product.customization_required)}{l s='Customize'}{else}{l s='More'}{/if}</span>
</a>
</div>

And on global.css setting the class:

.argomenti{background: red;}

Thanks

 

Link to comment
Share on other sites

There's no need to modify any TPL files. You can just use code like the following:

.category-3 .button.ajax_add_to_cart_button span {
    background: #ee0000;
​    border-color: #ff0000;
}

.category-3 .button.ajax_add_to_cart_button span:hover {
    background: #aa0000;
​    border-color: #bb0000;
}

Change 3 to the ID of the category page you want to change the "Add to cart" button.

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