Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
Hi,
I hope you are doing great!
I am facing an issue with the cart line item since yesterday.
While adding a product to the cart page with product properties using Ajax API call "/cart/add.js"
It was working fine since yesterday and Now it is not showing price and product image in the line item of cart page cart.
When I redirect customer to cart page after clicking add to cart button and get response in success callback of the jQuery Ajax. I am getting lineitem with missing image ,zero price and after refresh this cart page again it will show the cart item properly.
Below is the code of ajax cart api if you want to test this scenario.
var productProperties = {};
productProperties['first'] ='first';
productProperties['Second'] = 'Second';
productProperties['test'] = 'test';
var productData = { quantity: 1,
id: , 12345678 // add your shop variant id here.
properties: productProperties
};
var url = "/cart/add.js";
$.ajax({
type: "POST",
url: url,
data: productData,
dataType: "json",
success: function (response) {
if(response.status==200){
window.location.href = '/cart';
}
}, error: function (response) {
console.log('error');
}
});
Sometimes it works fine and sometimes it not working.
I need your help on this issue. It will be great if you find some time and reply on this thread.
Looking forward to hearing from you soon.
Thanks in advance.