How to show if a product is already in cart in Woocommerce ?

In this tutorial we’ll learn how to display already in cart text if a product is already in cart.

This is our default single product screen.

Now add this product to cart by clicking add to cart button. You’ll notice this doesn’t create any change on product page and the user donot know whether this product is already in cart or not. To achieve this add the following lines of code at the end of your functions.php file.