How can I manipulate a checkout created with the Storefront API using cart.js when in checkout flow?

Highlighted
New Member
4 0 0

We're on Plus and have a customized checkout.liquid wherein we offer an in-checkout product upsell. This works by using cart.js endpoints to add the product/variant to cart. However, we noticed when creating and redirecting to checkouts created using the Storefront API, cart.js still updates the *main site cart* and not the checkout cart (i.e. line items).

I don't see in the docs how to change the checkout/cart contents for the *current* checkout. Any insight is appreciated.

0 Likes
Highlighted
Shopify Staff
Shopify Staff
78 8 11

Hey @kyleparade!

Have you looked at the the checkoutLineItemsReplace (/Add/Remove/Update) mutations in the Storefront API yet?

Callum | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
New Member
4 0 0
Hey there. Not quite what I was asking. My question was how I can
manipulate the cart/checkout present when you visit our site. The API
created checkout is a different checkout. The API docs aren’t clear how to
target one or the other.

0 Likes
Highlighted
New Member
4 0 0

Any ideas? This is specifically to be able to manipulate the cart/checkout you would access by browsing our storefront, *not* a checkout created via API. The cart.js blocks cross origin requests even from a subdomain of our store, so that won't work. Looking forward to your reply.

0 Likes
Highlighted
Shopify Staff
Shopify Staff
78 8 11

Hey @kyleparade,

I don't believe this is possible. Check out this similar forum thread: https://community.shopify.com/c/Shopify-APIs-SDKs/How-do-I-use-the-AJAX-API-in-a-headless-Shopify-Re...

 

Callum | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes