What is the correct way to shippingLine with shippingRateHandle and title with predefined delivery?

What is the correct way to shippingLine with shippingRateHandle and title with predefined delivery?

madfcat
Shopify Partner
4 0 0

First of all, it was crazy hard to even understand what is `shippingRateHandle`. After using this query:

 

 

query MyQuery {
  orders(first: 150) {
    nodes {
      shippingLines(first: 100) {
        nodes {
          shippingRateHandle
          title
          code
        }
      }
      name
    }
  }
}

 

 

 

 

I at least got the understanding of how shippingRateHandle can look like created from admin panel. The docs just do not give you any understanding (
https://shopify.dev/docs/api/admin-graphql/2025-01/mutations/draftOrderCreate 
https://shopify.dev/docs/api/admin-graphql/2025-01/input-objects/ShippingLineInput
😞

 

 

 

 

          "shippingLines": {
            "nodes": [
              {
                "shippingRateHandle": "shopify-PostNord-17.00",
                "title": "PostNord",
                "code": "PostNord"
              }
            ]
          },
          "name": "#1001"

 

 

 

 


How can you set the delivery method to the one predefined in the shopify admin?
It always falls back to the PostNord in my case which has the smallest price. There is definitely a bug! It does not make sense. It only works without `shippingRateHandle` with creating shipping on the fly. But I need to create shippings using predefined methods in the admin. How can it be done?

My graphQL mutation :

 

 

 

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

 

 

 

 

Variables:

 

 

 

  "input": {
	"email": "my@email.com",
	"shippingLine": {
		"title": "FedEx",
		"shippingRateHandle": "shopify-FedEx-19.00",
		"priceWithCurrency": {
			"amount": 19,
			"currencyCode": "EUR"
		}
	},
	"tags": [
	"Standard"
	],
	"lineItems": [
	{
		"variantId": "gid://shopify/ProductVariant/12345678890",
		"quantity": 1
	}
	],
	"shippingAddress": {
	"firstName": "US User name",
	"lastName": "US User surname",
	"city": "New York",
	"address1": "5th Avenue 200, Empire State Building",
	"address2": "",
	"countryCode": "US",
	"provinceCode": "NY",
	"zip": "10118",
	"phone": "+1 212-234-5678"
	},
	"visibleToCustomer": false
	}

 

 

 

 

 
It also never updates from draftOrderUpdate (https://shopify.dev/docs/api/admin-graphql/2025-01/mutations/draftOrderUpdate)

 

 

 

mutation MyQuery($id: ID!, $input: DraftOrderInput!) {
  draftOrderUpdate(id: $id, input: $input) {
    draftOrder {
      shippingLine {
        carrierIdentifier
        code
        custom
        id
        shippingRateHandle
        title
        source
      }
    }
  }
}

 

 

 

 

Variables:

 

 

 

{
  "id": "gid://shopify/DraftOrder/1234567890",
  "input": {
	"shippingLine": {
            "priceWithCurrency": {
              "amount": "19.00",
              "currencyCode": "EUR"
            },
            "title": "FedEx",
            "shippingRateHandle": "shopify-FedEx-19.00"
    }
  }
}

 

 

 

 



I have my method defined like these:
Screenshot 2025-02-10 at 21.34.18.png

How can you set the delivery method to the one predefined in the shopify admin? The APIs are broken.
Why is Shopify APIs so buggy and counter-intuitive?

Replies 0 (0)