Add to cart api broken image and null title issue

Shopify Partner
11 0 3

Hi, I have a backend API that creates a variant against a product and returns its variant_id. 


On the Shopify theme side. I'm calling my backend API and adding the variant_id(received in API response) to the cart. The variant_id is successfully added to the cart but shows a broken image, title, and 0.00 for the price the first time. and on reload it shows the image and title correctly. The flow works fine mainly but sometimes it shows the described error.



Add to cart code:
type: 'POST',
url: '/cart/add.js',
dataType: 'json',
data: {
"quantity": 1,
"id": variantId,
properties: {
'items': variantsInfo
success: function (success) {

var cartContents = fetch(window.Shopify.routes.root + 'cart.js')
.then(response => response.json())
.then(data => { console.log(data) });
Replies 0 (0)