Unable to create shipping line in draftorder using GraphQL

snameofficial
New Member
1 0 0

Hello,

I have been using Shopify's REST API for a while but it's beginning to outlive it's usefulness as we scale, I recently tried to switch to the Graph QL API as adviced but I am unable to create shipping lines which I was able to do via the REST API.

 

My draftordercreate input  looks like this

{
  "input": {
    "email": "...",
    "shippingAddress": {.... },
    "billingAddress": {...},
    "tags": "...",
    "shippingLine": [
      {
        "price": "10.50",
        "shippingRateHandle": "Hingeto",
        "title": "Shipping"
      }
    ],
    "customAttributes": [
      {
        "key": "Retailer Name",
        "value": "..."
      }
    ],
    "lineItems": [
      {
        "variantId": "gid://shopify/ProductVariant/xxxxxxx",
        "quantity": 1,
        "appliedDiscount": {
          "amount": 0,
          "value": 0,
          "valueType": "FIXED_AMOUNT"
        }
      },
      {
        "variantId": "gid://shopify/ProductVariant/xxxxxx",
        "quantity": 1,
        "appliedDiscount": {
          "amount": 0,
          "value": 0,
          "valueType": "FIXED_AMOUNT"
        }
      }
    ]
  }
}

This successfully creates a draft order but when I view the order the shipping_lines is an empty array. I should also point out that it was SHippingLines [] for Rest but ShippingLine {} for GrapghQL

0 Likes
Josh
Shopify Staff
Shopify Staff
1131 82 194

Hey @snameofficial , 

 

Is the shipping rate that you're passing in one that is available on your shop, or a custom rate? 

 

If it's a custom rate, try to pass a shippingRateHandle that is a blank string instead (or just no shippingRateHandle field at all) and see if the shippingLine appears on your new draft. Even if it isn't a custom rate that you're passing in, I would suggest giving this a try as it would then indicate that it's probably the handle causing problems.

timd_mackey
Shopify Partner
49 1 18

I ran into the same issue today. Using the shippingRateHandle causes the draft order to be created with the custom shipping line missing. Removing shippingRateHandle allows the draft order to be created correctly with the custom shipping line intact.

0 Likes