I’m experiencing an issue with the cart functionality in my Shopify theme. When I click the ‘Add to Cart’ button in a regular browser window, the item is added to the cart correctly, and I can see it on the cart page. However, when I try the same action in the Shopify theme editor preview, clicking ‘Add to Cart’ takes me to the cart page, but the cart appears empty. Why is this happening, and how can I ensure that items show up in the cart within the theme editor as well?
Hey @PraveenKumar123 ,
It seems that the issue with the cart in the theme editor preview is due to how session data (like cart contents) is handled in the editor. Here are the steps to resolve it:
- Test on a live version: Check the cart functionality on your unpublished store’s live URL, as the theme editor doesn’t always sync cart data.
- Check Cart AJAX: Ensure your theme’s JavaScript properly handles AJAX cart updates.
- Clear Cache: Test in an incognito window or clear your browser’s cache to rule out stale session data.
- Disable Conflicting Scripts: Temporarily disable custom scripts or apps that might be interfering with the cart.
Let me know if you need further assistance!
If I was able to help you, please don’t forget to Like and mark it as the Solution!
If you’re looking for expert help with customization or coding, I’d be delighted to support you. Please don’t hesitate to reach out via the email in my signature below—I’m here to help bring your vision to life!
Best Regard,
Rajat Sharma
Hi @rajweb thanks for help ,
this is my product details code
{% assign current_variant = product.selected_or_first_available_variant %}
{% assign featured_image = current_variant.featured_image | default: product.featured_image %}
{% for image in product.images %}
{% endfor %}
{{ product.title }}
{{ current_variant.price | money }} quantity Add to cartthis my cart page code
{% if cart.item_count >0 %}
Shopping Cart
| Product | Description | Quantity | Unit Price | Total Price | Remove |
|---|---|---|---|---|---|
|
|
{{ item.product.title }}{{ item.product.description }} |
{{ item.quantity
}}
|
{{ item.product.price | money_without_currency }} | {{ item.line_price | money_without_currency}} | Remove |
Subtotal
{{ cart.total_price | money }}
{% schema %}
{
“name”: “Cart Template”,
“settings”: [
]
}
{% endschema %}
And then I am published the theme in live so open the live is working the cart functionality but theme Editor is not worked