Mark Product is already in cart in PrestaShop 1.7

Wednesday, 3 May 2017 16:28/ Posted by Misha Pyskur in PrestaShop 1.7

This tutorial will allow to change text on "Add to cart" button to "Already in cart", if selected product was added in the cart.

For this you need to open file: /themes/classic/templates/catalog/_partials/product-add-to-cart.tpl

And find this code: 

{l s='Add to cart' d='Shop.Theme.Actions'}

And replace this code on below: 

{$in_cart = 0}
{foreach from=$cart['products'] item='cart_product' }
{if $cart_product['id_product'] == $}
{$in_cart = 1}

{if $in_cart}
{l s='Already in cart' d='Shop.Theme.Actions'}
{l s='Add to cart' d='Shop.Theme.Actions'}

After changes open some product and click on "Add to cart button":

And you will see that button will change on "Already in cart":