How can I check if the current page is the cart page in theme.liquid? I tried page.handle=='cart'
but it is not working.
Click on your online store. Under Shopify themes settings, select your theme, then click on UPDATE CART.
to checkout in preview URL do below steps: OPen Shopify Admin -> Click on the theme 'Action' button which you want to check preview -> Click on 'Preview' in the same browser in which you have opened the Shopify backend. Now proceed with the checkout. It's allows you to do checkout in the preview theme.
The cart page shows a summary of all of the products that a customer has added to the cart, a subtotal and a total price for the order, and a Checkout button that directs customers to Shopify's secure checkout pages.
You don't need the handle
filter, you can just use:
{% if template == 'cart' %}
...
{% endif %}
Neither answer is absolutely correct, including the accepted one.
The cart template as others may have alternates e.g. cart.fancy.liquid
which can be accessed via /cart?view=fancy
. In that case, the equality operator will not work as expected as template
variable will be equal to cart.fancy
.
The contains
operator is not the best option as well, as it will also be TRUE for product.cartridge.liquid
and similar templates.
Based on the above here's the better solution to use in your themes:
{%- assign templateBase = template | slice: 0, 4 -%}
{%- if templateBase == 'cart' -%}
...
{%- endif -%}
cart
sequence in their suffixes i.e. alternate views.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With