Shopify API Orders And Draft Orders Endpoints Treat Price Differently?

Viewed 55

When submitting to the Orders API endpoint the specified price is respected and reflected in the order. When submitting to the Draft Orders API endpoint the specified price is replaced with the Shopify variant product price.

Is there any way to get the API respect the specified price when submitting a draft order? I'd prefer to use the Draft Order endpoint so I can manually review orders. Also it seems to play better with customer addresses.

The JSON below still results in an order with the default pricing of the variant.

{
"draft_order": {
    "line_items": [{
        "title": "LGD-120-NZ",
        "variant_id": 42605886111893,
        "price": "123.00",
        "taxable": true,
        "quantity": 2
    }],
    "customer": {
        "id": 6427023835285
    },
    "inventory_behaviour": "decrement_obeying_policy",
    "order.fulfillment_status": "null",
    "send_receipt": "false",
    "financial_status": "authorized",       
    "use_customer_default_address": true
}

}

1 Answers

You are experiencing the difference between an existing product and a custom product. An existing product has a variantId and you are providing that. Therefore you need only complement your setting with a quantity. There is no need for you to provide a price or sku or other details. Shopify uses the existing inventory setup. So be careful and minimize what you provide as data.

If you want to adjust the price of a variant, you are able to do that by discounting the line item. You can use an amount or percentage. So just do the math and you'll see your draft is correctly priced.

If you want to just sell something with any old price, no matter, then don't provide a variantId, and Shopify will create a draft with whatever details you do provide that make sense. Yes, you'll lose inventory management, but you'll sell the thing with custom prices.

It seems the only techniques you'll be applying here are thus:

  • create an appropriate line item discount to achieve your desired price
  • remove superfluous or extra details not needed to create correct orders
Related