Create a order using existing products in my shopify with a api

Hi, i want to make a order using json api, but if i want to add products it auto makes a new product. So how do i still make a order using json api but with existing products in my shopify store so i dont have to mannually put all the information.

Hi @DionCosina :waving_hand:

Using Admin GraphQL API, we can use the draftOrderCreate mutation and pass ProductVariant.id as a input variable under line items to load the existing product into the order:

mutation draftOrderCreate($input: DraftOrderInput!) {
  draftOrderCreate(input: $input) {
    draftOrder {
      id
    }
  }
}

{ // input variables
    "input": {
        "lineItems": [{
            "variantId": "gid://shopify/ProductVariant/12345",
            "quantity": 1
        }]
    }
}

Then the resulting DraftOrder.id can be used with the draftOrderComplete mutation to create the order:

mutation {
  draftOrderComplete(id: "gid://shopify/DraftOrder/67890") {
    draftOrder {
      order{
          id
      }
    }
  }
}

Similarly in Admin REST API, we can create a new DraftOrder then complete the DraftOrder as well.

Hope that helps!

Hi @Umiko ,

thanks for your explanation. I’m still not absolutely sure how to handle this. I’m in the same position as @DionCosina right now. I’m looking for a way to create order through the Shopify API without creating new products.

Is there any way to do this using simple JSON requests?

Kind regards,

Niklas

I am also trying to do something similar. I am also looking for a flow of how an order is created and what needs to happen to make it all the way through to payment using the shopify payment system.