Mark Product is already in cart 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'] == $product.id}
{$in_cart = 1}
{/if}
{/foreach}

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

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

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