jquery - Update Shopify cart product list using AJAX -


i have 'ajaxified' cart on shopify, when click 'add cart' button on product page, price updates in top right hand corner of screen , product added cart without page refresh.

when click price in top right hand corner, reveals dropdown showing products in basket (it shows product - image, url, price & quantity).

however, when click 'add cart' list of products not update until refresh page.

how list refresh (or how add product list in ajax request)??

i have tried adding 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 cart table rows , cells, not know how call correct variables product.****. have tried liquid ({{ product.title }}) variables these not work me.

i tried use cart.item, cart.product cart.product_title, cart. referenced in code already, broke script.

does know how refresh form without page refresh after button clicked (this perfect!), or how add products using route i've started down above?

so i've figured out going wrong, trying call cart.title should have been cartitem.title. looped these in jquery each.

here's full code:

$.each(cart.items, function(index, cartitem) {    $("#dropdown-cart").append('<tr><td><a href="'+cartitem.url+'" class="dropdown-product-image"><img src="'+cartitem.image+'" alt="product image"/></a></td><td class="restrain-width"><a href="'+cartitem.url+'" class="small">'+cartitem.quantity+' '+cartitem.title+'</a></td><td class="text-right"><span class="small">'+(shopify.formatmoney(cartitem.line_price, "{{ shop.money_format | remove: "'" | remove: '"' }}"))+'</span></td></tr>'); }); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -