Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
mini cart not update while i'm adding to cart the product. but when refreshing the page it will update the minicart on the product. where I need to check the files.
Solved! Go to the solution
This is an accepted solution.
Hi @suresh-prevaj
Can you tell me which theme you are having this issue and URL of the store.
This is an accepted solution.
This is an accepted solution.
Hi @suresh-prevaj
Upon checking i found that the product page is made with page builder app, That's why the cart is not working.
This is an accepted solution.
Hi @suresh-prevaj
You can use the below code to refresh the cart
<script>
document.addEventListener("DOMContentLoaded", function() {
$('.gp-button-base').on('click',function(){
setTimeout(function() {
jQuery.getJSON('/cart.js', function(cart) {
let cartData = cart.items;
document.dispatchEvent(new CustomEvent('cart:build' , {bubbles: true}));
document.dispatchEvent(new CustomEvent('cart:refresh', {
bubbles: true,
detail: cartData
}));
});
}, 1000);
});
});
</script>
This is an accepted solution.
Hi @suresh-prevaj
Can you tell me which theme you are having this issue and URL of the store.
This is an accepted solution.
https://www.darkhorsecoffeecompany.com/
theme : DHCC
This is an accepted solution.
Hi @suresh-prevaj
Upon checking i found that the product page is made with page builder app, That's why the cart is not working.
yes. i got this. is there any possible to refresh the cart after add to cart. on the js.
This is an accepted solution.
Hi @suresh-prevaj
You can use the below code to refresh the cart
<script>
document.addEventListener("DOMContentLoaded", function() {
$('.gp-button-base').on('click',function(){
setTimeout(function() {
jQuery.getJSON('/cart.js', function(cart) {
let cartData = cart.items;
document.dispatchEvent(new CustomEvent('cart:build' , {bubbles: true}));
document.dispatchEvent(new CustomEvent('cart:refresh', {
bubbles: true,
detail: cartData
}));
});
}, 1000);
});
});
</script>
for this code i'm using on the console. but it doesn't work. or how can i use the above mentioned code. also where i to place this code. js code
the code doesn't update the cart. it's running while clicking the addtocart. Is there any alternative code. please let me know.
@Huptech-Web wrote:Hi @suresh-prevaj
You can use the below code to refresh the cart
<script>
document.addEventListener("DOMContentLoaded", function() {
$('.gp-button-base').on('click',function(){
setTimeout(function() {
jQuery.getJSON('/cart.js', function(cart) {
let cartData = cart.items;
document.dispatchEvent(new CustomEvent('cart:build' , {bubbles: true}));
document.dispatchEvent(new CustomEvent('cart:refresh', {
bubbles: true,
detail: cartData
}));
});
}, 1000);
});
});
</script>
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024