Make a Cart Using Admin API From App Backend

I am developing a Shopify app with the Remix template. My app provides a theme app extension with an input form.

Then a user submit some date through that form. Based on submitted data from the app backend I am calling Admin API to get products. Now I want to create a cart for the user.

From what I understood in the Docs:

  1. I cannot use Storefront API to make a cart because it is not a custom storefront, I just get a request from a Shopify store. It is all happening inside the Shopify.

  2. As well I cannot use Ajax API, because I make the API call for products from the App Backend. While Ajax API is to extend themes, not for Apps.

So only Admin API is left to make a cart.

In Admin API Docs for Cart object I see only “cartTransformCreate” mutation. Which involves using Function API.

Is there an example anywhere how to just create a cart using “cartTransformCreate” mutation (without product bundles)?
Is using “cartTransformCreate” mutation right way to create a cart? Or there is another easier way?

Thank you for any help.

Here is the announce that I may use Storefront API for an app:

https://shopify.dev/changelog/storefront-api-is-now-available-to-non-channel-apps

Does it work as well for Public Apps (distributed through the App Store )?

Hi @angpro

Did you ever find a solution. I am trying to send data from a form inside my theme extension app to my remix based Admin app?

I have set up the form and it displays perfectly in my online store, but I don’t understand how I send anything to my admin app?

Maybe I should just make an XHR request, using fetch(), to POST data, to a route in my admin app?

But I have a feeling this would trigger a CORS problem, because my admin app is on a different domain to the online store.

Well, the parent URL is on the same domain, but the admin app is actually contained within an IFRAME that is pointing to a static NGROK sub domain.

I was thinking that maybe I could create an APP PROXY, like:

Online store URL [theme extension app]

sandbanks-test.myshopify.com/pages/test-1

Admin app IFRAME URL:

alien-amazed-lab.ngrok-free.app/app

But, I am not sure that you can create an APP PROXY for theme extension apps, which apparently, are not real apps, so don’t have their own URL?

Or can I change the:

Access-Control-Allow-Origin

In my Remix admin app? Maybe somewhere in the shopify.server.js