All things Shopify and commerce
Hello everybody. Hope you doing good. Currently, I have a major issue with the Fashe Theme on Shopify. The "remove" button on the cart page is not working properly. Every time I click the remove button, the checkout page suddenly appears. This happens as well when I click the "update cart" button. Can someone please help me out? I would really appreciate your help and hope that people who got the same issue can benefit as well from this.
Solved! Go to the solution
This is an accepted solution.
Hi @sadie2022
My apologies I used window instead of location and if we return false at the end it'll prevent other event listeners from firing.
So replace:
<button onclick="cart.remove('{{ item.variant_id }}');window.reload();" class="remove s-text7 flex-c-m m-l-30 m-t-10 p-l-10 p-r-10 p-t-5 p-b-5 bo1 bo-rad-23 hov1 trans-0-4" data-key="{{ item.variant_id }}">
{{ 'cart.general.remove' | t }}
</button>
with this code (notice the modified onclick attribute):
<button onclick="cart.remove('{{ item.variant_id }}');location.reload(); return false" class="remove s-text7 flex-c-m m-l-30 m-t-10 p-l-10 p-r-10 p-t-5 p-b-5 bo1 bo-rad-23 hov1 trans-0-4" data-key="{{ item.variant_id }}">
{{ 'cart.general.remove' | t }}
</button>
That should then work properly again?
hi @sadie2022 try removing cache and cookies or open in incognito mode or in private browser!
I'm sorry but did not really understand how this could help? Did I understand you right, you want me to open my store in an incognito window or a private browser?
Try to check your store in incongito window @sadie2022
Okay, I just tried this but unfortunately, it did not work out. Is there anything else I can do?
Is there anything to edit in the code that could be done to remove this error?
If it's giving same issue in incongito window then we have to update Ajax JavaScript Framework to be coded properly with updated library not to have this issue but first try with incongito window
I tried several times to remove items from the cart page by using the incognito window but it did not work out. So how can I edit the Ajax JavaScript Framework? I would like to do it myself, I just need a little bit of advice.
Thanks for waiting
Here is everything
https://help.shopify.com/en/themes/development/templates/cart-liquid
Thank you so much. But could you tell me where exactly I need to put this on my cart.liquid ?
Here is my Code from the cart-liquid:
<!-- Title Page -->
<section class="bg-title-page p-t-40 p-b-50 flex-col-c-m" {% if settings.show_cart_top_image %}
style="background-image:url({{ 'cart_top.jpg' | asset_url }});" {% endif %}>
<h2 class="l-text2 t-center">
{{ page_title }}
</h2>
</section>
<!-- Cart -->
<section class="cart bgwhite p-t-70 p-b-100">
<div class="container">
{% if cart.item_count > 0 %}
<form action="/checkout" method="post" id="cart_form">
<!-- Cart item -->
<div class="container-table-cart pos-relative">
<div class="wrap-table-shopping-cart bgwhite">
<table class="table-shopping-cart">
<tr class="table-head">
<th class="column-1"></th>
<th class="column-2">{{ 'cart.general.heading_product_name' | t }}</th>
<th class="column-3">{{ 'cart.general.heading_unit_price' | t }}</th>
<th class="column-4 p-l-70">{{ 'cart.general.heading_quantity' | t }}</th>
<th class="column-5">{{ 'cart.general.heading_total' | t }}</th>
</tr>
{% for item in cart.items %}
<tr class="table-row" data-line="{{ forloop.index }}">
<td class="column-1">
<div class="cart-img-product b-rad-4 o-f-hidden">
<a href="{{ item.url }}">
<img src="{{ item | img_url: '90x120' }}" alt="{{ item.title | escape }}" title="{{ item.title | escape }}" class="" />
</a>
</div>
</td>
<td class="column-2">
<a href="{{ item.url }}">{{ item.product.title }}</a>
{% unless item.variant.title contains 'Default' %}
<br />
<small>{{ item.variant.title }}</small>
{% endunless %}
{% if settings.product_quantity_message and item.variant.inventory_management and item.variant.inventory_quantity <= 0 and item.variant.incoming %}
{% assign date = item.variant.next_incoming_date | date: format: 'month_day_year' %}
<br />
<small>{{ 'products.product.will_not_ship_until' | t: date: date }}</small>
{% endif %}
{% assign property_size = item.properties | size %}
{% if property_size > 0 %}
{% for p in item.properties %}
{% if forloop.first %}<br>{% endif %}
{% unless p.last == blank %}
{{ p.first }}:
{% if p.last contains '/uploads/' %}
<a href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
{% else %}
{{ p.last }}
{% endif %}
<br>
{% endunless %}
{% endfor %}
{% endif %}
</td>
<td class="column-3">{{ item.price | money }}</td>
<td class="column-4">
<div class="flex-w bo5 of-hidden w-size17">
<button class="btn-num-product-down color1 flex-c-m size7 bg8 eff2">
<i class="fs-12 fa fa-minus" aria-hidden="true"></i>
</button>
<input type="number" name="updates[]" id="updates_{{ item.id }}" data-key="{{ item.id }}" value="{{ item.quantity }}" min="0" class="size8 m-text18 t-center num-product" data-line="{{ forloop.index }}">
<button class="btn-num-product-up color1 flex-c-m size7 bg8 eff2">
<i class="fs-12 fa fa-plus" aria-hidden="true"></i>
</button>
</div>
<button class="remove s-text7 flex-c-m m-l-30 m-t-10 p-l-10 p-r-10 p-t-5 p-b-5 bo1 bo-rad-23 hov1 trans-0-4" data-key="{{ item.variant_id }}">
{{ 'cart.general.remove' | t }}
</button>
</td>
<td class="column-5">{{ item.line_price | money }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
<div class="flex-w flex-sb-m p-t-25 p-b-25 bo8 p-l-35 p-r-60 p-lr-15-sm">
<div class="flex-w flex-m w-full-sm">
<div class="size11 bo4 m-r-10">
<input class="sizefull s-text7 p-l-22 p-r-22" type="text" name="discount" id="discount" placeholder="Coupon Code">
</div>
<div class="size12 trans-0-4 m-t-10 m-b-10 m-r-10">
<!-- Button -->
<!-- <button class="flex-c-m sizefull bg1 bo-rad-23 hov1 s-text1 trans-0-4">
Apply coupon
</button> -->
</div>
</div>
<div class="size10 trans-0-4 m-t-10 m-b-10">
<!-- Button -->
<button class="update-cart flex-c-m sizefull bg1 bo-rad-23 hov1 s-text1 trans-0-4">
{{ 'cart.general.update' | t }}
</button>
</div>
</div>
<!-- Total -->
<div class="bo9 w-size18 p-l-40 p-r-40 p-t-30 p-b-38 m-t-30 m-r-0 m-l-auto p-lr-15-sm">
<h5 class="m-text20 p-b-24">
Cart Totals
</h5>
<!-- -->
{% if cart.total_discounts > 0 %}
{% assign savings = cart.total_discounts | money %}
<div class="flex-w flex-sb-m p-b-12">
<span class="s-text18 w-size19 w-full-sm">
{{ 'cart.general.discount' | t }}:
</span>
<span class="m-text21 w-size20 w-full-sm">
{{ 'cart.general.savings_html' | t: price: savings }}
</span>
</div>
{% endif %}
<!-- <div class="flex-w flex-sb-m p-b-12">
<span class="s-text18 w-size19 w-full-sm">
{{ 'cart.general.subtotal' | t }}:
</span>
<span class="m-text21 w-size20 w-full-sm">
{{ cart.total_price | money }}
</span>
</div>
-->
<!-- -->
<div class="flex-w flex-sb bo10 p-t-15 p-b-20">
<span class="s-text18 w-size19 w-full-sm">
Shipping:
</span>
<div class="w-size20 w-full-sm">
<!-- <p class="s-text8 p-b-23">
There are no shipping methods available. Please double check your address, or contact us if you need any help.
</p> -->
{% include 'shipping-calculator' %}
<!--
<div class="rs2-select2 rs3-select2 rs4-select2 bo4 of-hidden w-size21 m-t-8 m-b-12">
<select class="selection-2" name="country">
<option>Select a country...</option>
<option>US</option>
<option>UK</option>
<option>Japan</option>
</select>
</div>
<div class="size13 bo4 m-b-12">
<input class="sizefull s-text7 p-l-15 p-r-15" type="text" name="state" placeholder="State / country">
</div>
<div class="size13 bo4 m-b-22">
<input class="sizefull s-text7 p-l-15 p-r-15" type="text" name="postcode" placeholder="Postcode / Zip">
</div>
<div class="size14 trans-0-4 m-b-10">
<!-- Button -->
<!--<button class="flex-c-m sizefull bg1 bo-rad-23 hov1 s-text1 trans-0-4">
Update Totals
</button>
</div>
-->
</div>
</div>
<!-- -->
<div class="flex-w flex-sb-m p-t-26 p-b-30">
<span class="m-text22 w-size19 w-full-sm">
{{ 'cart.general.subtotal' | t }}:
</span>
<span class="m-text21 w-size20 w-full-sm">
{{ cart.total_price | money }}
</span>
</div>
<div class="size15 trans-0-4">
<!-- Button -->
<button onclick="document.getElementById('cart_form').submit(); return false;" class="flex-c-m sizefull bg1 bo-rad-23 hov1 s-text1 trans-0-4">
{{ 'cart.general.proceed_checkout' | t }}
</button>
{% if additional_checkout_buttons %}
{{ content_for_additional_checkout_buttons }}
{% endif %}
</div>
</div>
</form>
{% else %}
<h1 class="page-heading">{{ 'cart.general.empty' | t }}</h1>
<p>{{ 'cart.general.continue_browsing_html' | t }}</p>
{% endif %}
</div>
</section>
{% unless settings.shipping_calculator == 'Disabled' %}
<script>
window.theme = window.theme || {};
theme.strings = {
shippingCalcSubmitButton: {{ settings.shipping_calculator_submit_button_label | default: 'Calculate shipping' | json }},
shippingCalcSubmitButtonDisabled: {{ settings.shipping_calculator_submit_button_label_disabled | default: 'Calculating...' | json }},
{% if customer %}shippingCalcCustomerIsLoggedIn: true,{% endif %}
shippingCalcMoneyFormat: {{ shop.money_with_currency_format | json }}
}
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.10/handlebars.min.js"></script>
<script src="/services/javascripts/countries.js"></script>
<script src="{{ 'shopify_common.js' | shopify_asset_url }}" defer="defer"></script>
{{ 'shipping-cart.js' | asset_url | script_tag }}
<script>
Shopify.Cart.ShippingCalculator.show( {
submitButton: theme.strings.shippingCalcSubmitButton,
submitButtonDisabled: theme.strings.shippingCalcSubmitButtonDisabled,
customerIsLoggedIn: theme.strings.shippingCalcCustomerIsLoggedIn,
moneyFormat: theme.strings.shippingCalcMoneyFormat
} );
</script>
{% endunless %}
You can find file cart.liquid in edit çode section left side of customize button in which we have theme files like layout template section etc you will find cart file there
No, I mean where in the cart file do I need to insert the code? At the bottom of the file or in a certain line?
you can replace cart.liquid fie from original theme you did install I would recommend!
Hi @sadie2022
Can you post a link to the site please?
Hard to diagnose this one without seeing it in action.
Thanks
Could you localize the issue?
Hi Sadie
Something up the chain looks like it's overriding the listener for that click and doing something else with it instead.
Try replacing in your cart.liquid, these lines:
<button class="remove s-text7 flex-c-m m-l-30 m-t-10 p-l-10 p-r-10 p-t-5 p-b-5 bo1 bo-rad-23 hov1 trans-0-4" data-key="{{ item.variant_id }}">
{{ 'cart.general.remove' | t }}
</button>
With these lines, you'll notice there's a new onclick attribute on the button that specifies a removal of that product, then refreshes the page:
<button onclick="cart.remove('{{ item.variant_id }}');window.reload();" class="remove s-text7 flex-c-m m-l-30 m-t-10 p-l-10 p-r-10 p-t-5 p-b-5 bo1 bo-rad-23 hov1 trans-0-4" data-key="{{ item.variant_id }}">
{{ 'cart.general.remove' | t }}
</button>
And come back to let us know whether that works or not?
The first 3 times I tried removing items from the cart, using your code it worked but now it doesn't! Do you have another idea of how to fix this?
Okay I just tried out adding a couple of products and then removing them and noticed that the code you provided ONLY works when only one product is in the cart
This is an accepted solution.
Hi @sadie2022
My apologies I used window instead of location and if we return false at the end it'll prevent other event listeners from firing.
So replace:
<button onclick="cart.remove('{{ item.variant_id }}');window.reload();" class="remove s-text7 flex-c-m m-l-30 m-t-10 p-l-10 p-r-10 p-t-5 p-b-5 bo1 bo-rad-23 hov1 trans-0-4" data-key="{{ item.variant_id }}">
{{ 'cart.general.remove' | t }}
</button>
with this code (notice the modified onclick attribute):
<button onclick="cart.remove('{{ item.variant_id }}');location.reload(); return false" class="remove s-text7 flex-c-m m-l-30 m-t-10 p-l-10 p-r-10 p-t-5 p-b-5 bo1 bo-rad-23 hov1 trans-0-4" data-key="{{ item.variant_id }}">
{{ 'cart.general.remove' | t }}
</button>
That should then work properly again?
Thank you very much. I will try this out and let you know if it worked out.
It worked out. A thousand thanks for solving this major issue and helping me out. I appreciate your help a lot thank you very much.
this answer is not working
Do you have another idea of how to fix this?
User | RANK |
---|---|
53 | |
48 | |
41 | |
28 | |
21 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023