Engaging with the Shopify Cart using API

Jentsch
Shopify Partner
27 0 3

Hi, 

 

We have a use case where we'd like to update a customers cart after they've engaged with an app. This requires two way integration between the app and the users cart. The user may or may not be logged in when that interaction happens.

 

There is also a graphQL cart functionality: https://shopify.dev/api/examples/cart  but is there something similar with REST or is graphQL the only way?

 

Thanks, 

Jake

Replies 4 (4)

awwdam
Shopify Staff
249 42 36

Hey @Jentsch,

Just wanted to help clarify here based on the link shared. The Cart API is one of our Storefront APIs, which is only available in GraphQL. There are some great resources for getting started with GraphQL and the Storefront API that I have linked below.

Storefront API Docs
Querying Data - Guide,
Storefront API Learning Kit. 

Cheers!

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Jentsch
Shopify Partner
27 0 3

Hey @awwdam 

 

Thanks for the reply. Time to learn GraphQL!

 

While not directly related to the question - is there ways to query carts that are active? I can see a get cart query but that requires supplying a cartid. What ways are there to query all ''active'' carts? Happy to be pointed in the right direction and read, I just can't see this in the documentation. 

 

Thanks, 

Jake

thomasbaart
Tourist
3 0 1

I'm running into exactly the same situation, but have trouble locating resources for it. Did you manage to find a solution in the meantime?

Jentsch
Shopify Partner
27 0 3

Hey @thomasbaart 

 

Honestly, I kinda abandoned this project lol but just finished learning & upgrading from REST to graph. 

 

having another quick look it doesn't look like there is a way to poll existing carts with the storefront API and I guess this makes sense because if your using the storefront API you want to create a storefront right and in that case a cart "shouldn't" magically be created which might mean it gets created from a button or something in which case the mutation starts. 

 

But again, I am very far from a dev so someone else might have different experiences!

 

Let me know how you go

 

Thanks!