FROM CACHE - en_header

Js Buy SDK - add product to checkout

59 6 9

Hi fellow Shopifiers and Admins

The question I have is about adding a product to a checkout created with the Buy Sdk for Javascript.

I've noticed that the ID of the product in the checkout is different than the one before adding the product to the checkout.

Has anyone else experienced this and if so, is this normal behaviour?

I am adding a product to the checkout and may want to remove it later based on certain conditions, ie remove a delivery fee if the subtotal price is more than a certain threshold.

Is there a way to preserve the id when adding a product to checkout?

I am currently going through the lineItem array and checking against a custom attribute to identify the delivery fee in the checkout.

Replies 2 (2)
New Member
1 0 0

the difference is probably -> one is the product_id, the other is the variant_id which is used for checkout. 

Shopify Partner
67 12 16

The IDs for resources in the Storefront API are base 64 encoded. You can decode/encode as needed fairly easily, I use the shopify-gid library for convenience.