I have 'Ajaxified' my cart on Shopify, when I click the 'Add to cart' button on a product page, the price updates in the top right hand corner of the screen and the product is added to the cart without a page refresh.
When you click the price in the top right hand corner, it reveals a dropdown showing you what products are in your basket (It shows product - image, url, price & quantity).
However, when you click 'Add to cart' this list of products does not update until you refresh the page.
How do I get this list to refresh (or how do I add the product to the list in the AJAX request)??
I have tried adding this into the ajaxify cart module (https://raw.githubusercontent.com/carolineschnapp/ajaxify-cart/master/ajaxify-cart.liquid):
$.getJSON(_config.shopifyAjaxCartURL, function(cart) {
$("#dropdown-cart").append('<tr><td><a href="'+PRODUCT.URL+'" class="dropdown-product-image"><img src="'+PRODUCT.IMAGE+'" alt="'+PRODUCT.DESCRIPTION+'" /></a></td><td class="restrain-width"><a href="'+PRODUCT.URL+'" class="small">PRODUCT.NAME</a></td><td class="text-right"><span class="small">PRODUCT.QUANTITY</span></td></tr>');
});
This updates the cart with the table rows and cells, but I do not know how to call the correct variables for PRODUCT.****
. I have tried liquid ({{ product.title }}
) variables but these do not work for me.
I also tried to use cart.item
, cart.product
cart.product_title
, as cart.
is referenced in the code already, but this just broke the script.
Does anyone know how to simply refresh this form without a page refresh after the button is clicked (this would be perfect!), or how to add products using the route i've started down above?
cart.title
(in the question you linked to they callcart.item_count
for example) but then it errors, I just wanted to know if i'm using the wrong naming convention or something, or if i'm completely off the mark. – Jon Kyte