Hi there,
The problem is that when a product is added to the page and I have another tab open with my cart that the page itself doesn’t update the quantity or the new product, but it all works if I do it manually, like subtracting etc, or when I refresh the page, but I want it to go automatically like when a product is being added it gets automatically updated in the background, I have searched different topics and most people are suggesting Ajax etc but I don’t want to reconfigure my whole code to a simple process as this, I’ve searched around and tried some different methods but somehow it does skip other factors and I’m kinda stuck with this code, like I can’t figure it out anymore, I’ve changed the code multiple times already:
Code that I’ve placed in theme.js at the bottom**;**
theme.UpdateRefresh = (function() {
var refresh = document.getElementsByClassName('.product-form .product-form-product-template');
var test = ('[data-product-form]');
$('btn product-form__cart-submit').click(function() {
location.reload();
});
function update()
{
url: '/cart/add'
dataType: 'json'
}
return { update:update}
}) ();
product-template.liquid
{{ 'general.accessibility.error' | t }}
{% include 'icon-error' %}
{{ 'products.product.quantity_minimum_message' | t }}
I then placed theme.UpdateRefresh.update() in the AddToCart section so it gets executed but it doesn’t work because I don’t know what’s wrong anymore, keep in mind that I’m learning and trying to figure out things a lot in order to process it and gain some knowledge in the subject,
Thanks for reading this I appreciate it.
Edit: added product-template.liquid code.