What's your biggest current challenge? Have your say in Community Polls along the right column.

Dawn theme reload cart on quantity update

Solved

Dawn theme reload cart on quantity update

Rich_Woodward
Shopify Partner
10 0 5

Hi,

 

I'm upgrading a site to Shopify 2.0 and I need to reload the Cart page in the Dawn theme when the quantity is changed.

 

Reason: I currently disable the checkout button and add a message if the cart value is less than £100:

<button type="submit" id="checkout" class="cart__checkout-button button" name="checkout" {% if customer.tags contains 'wholesale' and cart_price < 10000 %} disabled{% endif %} form="cart">
{% if customer.tags contains 'wholesale' and cart_price < 10000 %}
  <p>Minimum Wholesale Order is &pound;100.00. To view the check out button please increase your order value.</p>
{% endif %}

 

In Dawn, because the cart total is dynamically updated when the quantity is changed, the above liquid scripts don't run. 

 

Solution anyone?

 

Thank you!

Accepted Solution (1)

SheetalZadfiya
Explorer
70 15 19

This is an accepted solution.

Hello @Rich_Woodward ,

 

Go to Assets => Cart.js and add the below code inside updateLiveRegions function,

 

window.location.reload();

 

image-20220607-105223.png

 

Next, Go to Sections > main-cart-footer and add your script.

image-20220607-105551.png

 

I hope it helps you.

 

Happy Coding!!

If our answer is helpful then please feel free to Like and Accept it as solution!
Hire our Shopify Developers for all your small & big needs:
New Store Development | Custom Theme Development | Site Speed Optimization
Email: hello@mintyourstore.com | Instagram: @mintyourstore

View solution in original post

Replies 4 (4)

SheetalZadfiya
Explorer
70 15 19

This is an accepted solution.

Hello @Rich_Woodward ,

 

Go to Assets => Cart.js and add the below code inside updateLiveRegions function,

 

window.location.reload();

 

image-20220607-105223.png

 

Next, Go to Sections > main-cart-footer and add your script.

image-20220607-105551.png

 

I hope it helps you.

 

Happy Coding!!

If our answer is helpful then please feel free to Like and Accept it as solution!
Hire our Shopify Developers for all your small & big needs:
New Store Development | Custom Theme Development | Site Speed Optimization
Email: hello@mintyourstore.com | Instagram: @mintyourstore
Rich_Woodward
Shopify Partner
10 0 5

Thank you very much for the solution - works perfectly for my needs. 

Mike5241
Explorer
57 0 12

Thanks a lot SheetalZadfiya, it works great!

NJPB
Visitor
1 0 0

Hi

Would adding the code:

window.location.reload();

Enable the cart to reload when the customer changes the quantities in the cart. Currently when a customer makes an adjustment, the cart doesn't update the totals including the discounts for volume purchases. If the customer simply refreshes the page it works well but I don't want the customers to have to refresh and it automatically updates when they make the changes.

 

Thanks in advance