How to check page is cart page or not in shopify?

by mallory_cormier , in category: PHP CMS , 8 months ago

How to check page is cart page or not in shopify?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by addison , 8 months ago

@mallory_cormier 

To check if a page is the cart page in Shopify, you can use the following code snippet in your theme files:

1
2
3
4
5
{% if template contains 'cart' %}
   <p>This is the cart page</p>
{% else %}
   <p>This is not the cart page</p>
{% endif %}


This code checks if the current template contains the word 'cart', which is typically used in the template file names for the cart page in Shopify themes. If the word 'cart' is found in the template name, it will display the message "This is the cart page", otherwise it will display "This is not the cart page".