vtex / vtex.js

VTEX SDK for JavaScript
MIT License
120 stars 52 forks source link

cart not being update after adding item #85

Open Matanelc opened 2 years ago

Matanelc commented 2 years ago

below I have POC snippet that adds the item to the cart (load all deps and then call add to cart). item was added but it's not causing the cart to reload and you will see that item was added on the next refresh is there any way to trigger the refresh without reloading the page? im trying to create thrid party app. function loadJS(file) { var jsElm = document.createElement("script"); jsElm.type = "application/javascript"; jsElm.src = file; document.body.appendChild(jsElm); }

loadJS("https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js") loadJS("https://io.vtex.com.br/vtex.js/2.0.0/vtex.min.js")

var item = { id: 355027, quantity: 1, seller: "1", } vtexjs.checkout .getOrderForm() .then(function(orderForm) { console.log(orderForm) vtexjs.checkout.addToCart([item], null, "1").done(function(orderForm) { alert("Item added!") console.log(orderForm) }) })