Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.
Solved

draftOrderCalculate - adding custom shipping rate no longer works

Saso-WD
Shopify Partner
26 1 12

When performing GraphQL mutation draftOrderCalculate  and trying to add custom shipping rate, the result just chooses one of the available shipping rates and ignores the shippingLineInput.

This used to work at one point. Any ideas what happened?


Our Input Variable:

(
    [billingAddress] => Array
        (
            [address1] => REDACTED
            [address2] => 
            [city] => South Portland
            [company] => 
            [country] => US
            [firstName] => REDACTED
            [lastName] => REDACTED
            [phone] => 
            [province] => Maine
            [provinceCode] => 
            [zip] => 04106-5903
        )

    [lineItems] => Array
        (
            [0] => Array
                (
                    [variantId] => gid://shopify/ProductVariant/xxxxxxxxxx
                    [quantity] => 1
                    [appliedDiscount] => Array
                        (
                            [valueType] => PERCENTAGE
                            [value] => 30
                            [title] => HOLIDAY30
                        )

                )

            [1] => Array
                (
                    [variantId] => gid://shopify/ProductVariant/xxxxxxxxxxx
                    [quantity] => 1
                    [appliedDiscount] => Array
                        (
                            [valueType] => PERCENTAGE
                            [value] => 30
                            [title] => HOLIDAY30
                        )

                )

        )

    [shippingAddress] => Array
        (
            [address1] => REDACTED
            [address2] => 
            [city] => South Portland
            [company] => 
            [country] => US
            [firstName] => REDACTED
            [lastName] => REDACTED
            [phone] => 
            [province] => Maine
            [provinceCode] => 
            [zip] => 04106-5903
        )

    [purchasingEntity] => Array
        (
            [customerId] => gid://shopify/Customer/xxxxxxxxxx
        )

    [email] => email@example.com
  

    [shippingLine] => Array
        (
            [price] => 4.99
            [shippingRateHandle] => custom_test_rate
            [title] => Custom Shipping Rate
        )

)

And this is what we get in response for the shippingLine

 [shippingLine] => stdClass Object
                (
                    [title] => Standard Shipping (3-7 business days)
                    [shippingRateHandle] => 0cb26d702c142a6d292e4c1b59e9ed4c
                    [originalPriceSet] => stdClass Object
                        (
                            [presentmentMoney] => stdClass Object
                                (
                                    [amount] => 25.98
                                )

                        )

                    [discountedPriceSet] => stdClass Object
                        (
                            [presentmentMoney] => stdClass Object
                                (
                                    [amount] => 25.98
                                )

                        )

                )

 

[x-request-id] => 6e5330bb-8f2c-4998-b0d0-583d3a644af6
Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1244 201 440

This is an accepted solution.

Hey @Saso-WD

 

Thanks for following up on this. Taking a look at your variables, I can see that you're including information in the handle fields. 

 

For custom Shipping rates you'll need to set the handle as Null or leave it out entirely for it to be added properly to the order. 

This is explained more clearly in our REST documentation, and could definitely be made more clear in our GraphQL docs (I've submitted feedback to our documentation team). 

 

I don't want to ignore your comment about our support availability either. Just for context, anytime you have identified an issue or suspected issue, definitely reach out to our Partner or Plus support teams (just be sure to contact logged in through the store or partner account where the issue has been noticed) and we will for sure take a look. In your email, be sure to provide the impacted app and store, API endpoints and version you're using, documents you've consulted, and examples of your request with the request ID and timestamps (pretty much as you've posted here). The more information you can provide related to the issue and how we can replicate can help make sure the proper teams are consulted and help you get a quicker resolution by eliminating additional back and forth. 

 

For dev questions that are more solution based (how-to, what am I missing) the forums remain a great place for that as it allows the community to help out and ensures a valuable resource for other developers that have similar questions. 

 

I hope that helps! Have a great rest of your week. 

 

- Kyle G. 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 3 (3)

Saso-WD
Shopify Partner
26 1 12

It's just great how Shopify doesn't have API support, even for Plus stores, they just tell you to ask here but nobody bothers to reply.

ShopifyDevSup
Shopify Staff
1244 201 440

This is an accepted solution.

Hey @Saso-WD

 

Thanks for following up on this. Taking a look at your variables, I can see that you're including information in the handle fields. 

 

For custom Shipping rates you'll need to set the handle as Null or leave it out entirely for it to be added properly to the order. 

This is explained more clearly in our REST documentation, and could definitely be made more clear in our GraphQL docs (I've submitted feedback to our documentation team). 

 

I don't want to ignore your comment about our support availability either. Just for context, anytime you have identified an issue or suspected issue, definitely reach out to our Partner or Plus support teams (just be sure to contact logged in through the store or partner account where the issue has been noticed) and we will for sure take a look. In your email, be sure to provide the impacted app and store, API endpoints and version you're using, documents you've consulted, and examples of your request with the request ID and timestamps (pretty much as you've posted here). The more information you can provide related to the issue and how we can replicate can help make sure the proper teams are consulted and help you get a quicker resolution by eliminating additional back and forth. 

 

For dev questions that are more solution based (how-to, what am I missing) the forums remain a great place for that as it allows the community to help out and ensures a valuable resource for other developers that have similar questions. 

 

I hope that helps! Have a great rest of your week. 

 

- Kyle G. 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Saso-WD
Shopify Partner
26 1 12

Thank you  @ShopifyDevSup (Kyle) for responding, that solved the issue. Next time I'll check the REST API docs as well. I see now that GraphQL docs are sometimes not very clear.