Help with Adding Shipping Fee to draftOrderCreate API

Hi everyone,

I’m calling the draftOrderCreate GraphQL Admin API and having trouble adding a shipping fee.
The draft order is created successfully when I exclude the shippingLines field from the input. However, when I include it, I receive the following error:

message: ‘Variable $input of type DraftOrderInput! was provided invalid value for shippingLines (Field is not defined on DraftOrderInput)’

Here is the input I’m using:

input: {
customerId: “gid://shopify/Customer/123456789”,
note: “”,
email: “test@test.com”,
taxExempt: false,
tags: [“Over Credit Limit”],
lineItems: [
{
title: “Custom product”,
originalUnitPrice: 14.99,
quantity: 5,
variantId: “gid://shopify/ProductVariant/123456789”
}
],
billingAddress: {
province: “ON”,
country: “CA”
},
shippingAddress: {
address1: “123 Main St”,
city: “Waterloo”,
province: “Ontario”,
country: “Canada”,
zip: “A1A 1A1”
},
shippingLines: {
title: “Standard Shipping”,
price: 29.8
}
}

Could someone please advise what I’m doing wrong or suggest the correct way to include a shipping fee?

Thanks in advance!

Hi @S_W

I have not tested the following, due to being on mobile.

I just checked the draftOrderCreate mutation in the docs, and it seems like the property is called shippingLine and not a plural version as in your snippet.

"shippingLine": {
   "priceWithCurrency": {
      "amount": 29.8,
      "currencyCode": "USD"
   },
   "title": "Standard shipping"
}

The price field is deprecated, AFAIK. You have to use priceWithCurrency.

Does it work if you use the above?

1 Like

Please use shippingLine

1 Like

Hi @curzey and @kyle_liu,

Thank you so much for your quick reply, and my apologies for the delayed response since I had limited access to a computer over the past few days.

It was a silly mistake on my part: I was using “shippingLines” instead of “shippingLine.” Once I corrected that, I was able to include the shipping fees successfully.

Thank you again for your kind and helpful support!