Bug: GraphQL and REST Admin API do not reflect removal of shipping from order

Solved

Bug: GraphQL and REST Admin API do not reflect removal of shipping from order

samherrmann
Shopify Partner
2 0 0

When removing a shipping line from an order through the Shopify admin UI, both the GraphQL and the REST admin API do not reflect the change correctly. Here are the reproduction steps:

 

1. Through the admin UI, create a new order and add a custom shipping option by clicking the "Add shipping or delivery" link. For example, add a shipping option named "Delivery" with a price of $20.00:
samherrmann_0-1710719022085.png


2. After the order is created, click "Edit" on the order and then "Edit shipping". Remove the previously added shipping item:
samherrmann_2-1710719622024.png
samherrmann_3-1710719707369.png

Save the change by clicking the "Update order" button. Observe that the shipping item was successfully removed from the order.



3. Query the order through the GraphQL API:

 

query {
  order(id: "gid://shopify/Order/<order_id>") {
    totalShippingPriceSet {
      shopMoney {
        amount
      }
    }
    shippingLines(first: 10) {
      nodes {
        originalPriceSet {
          shopMoney {
            amount
          }
        } 
      }
    }
  }
}​

 

 

Replace <order_id> with the ID of the order created in step 1.

4. Observe the GraphQL response:

 

{
  "data": {
    "order": {
      "totalShippingPriceSet": {
        "shopMoney": {
          "amount": "20.0"
        }
      },
      "shippingLines": {
        "nodes": []
      }
    }
  }
}​

 

 

Note that the shippingLines field was updated correctly, but the totalShippingPriceSet field still contains an amount of $20.00, which is not correct.

5. Let's now query the order through the REST API:

curl -X GET "https://<store_id>.myshopify.com/admin/api/2024-01/orders/<order_id>.json?status=any" -H "X-Shopify-Access-Token: <access_token>"

Replace <store_id>, <order_id>, and <access_token> with their values.

6. Observe the REST response:

 

{
  "order": {
    // ...
    "total_shipping_price_set": {
      "shop_money": {
        "amount": "20.00",
        "currency_code": "CAD"
      },
      "presentment_money": {
        "amount": "20.00",
        "currency_code": "CAD"
      }
    },
    // ...
    "shipping_lines": [
      {
        // ...
        "discounted_price": "20.00",
        "discounted_price_set": {
          "shop_money": {
            "amount": "20.00",
            "currency_code": "CAD"
          },
          "presentment_money": {
            "amount": "20.00",
            "currency_code": "CAD"
          }
        },
        "phone": null,
        "price": "20.00",
        "price_set": {
          "shop_money": {
            "amount": "20.00",
            "currency_code": "CAD"
          },
          "presentment_money": {
            "amount": "20.00",
            "currency_code": "CAD"
          }
        },
        // ...
      }
    ]
  }
}​

 

 

Note that both the total_shipping_price_set and the shipping_lines field still contain the shipping amount that was removed in step 2.

I hope this bug report attracts the eyes of someone at Shopify. Let me know if you need any other information.

 

 

 

 

 

 

 

 

Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1453 238 511

This is an accepted solution.

Hi @samherrmann - I was able to do a bit of digging into this on our end and can confirm the above is expected behaviour. Removed shipping lines will always be included in REST Order resource payloads (a bit more info in this changelog here). As of API version 2024-04 though, we have added an is_removed attribute which does delineate a removed shipping line. 

I was also able to get in touch with our product team who is responsible for the Shipping/Order resource and they confirmed that the total_shipping_price_set field returning the value of the removed shipping fee is also expected behaviour, as it follows the logic of the total_price_set field which displays the full value for an order, including all funds that were returned, removed product values, product edits, etc. 

I have passed along a request for a shipping price related field/resource that reflects the behaviour of the current_total_price field, where it only displays the value of an order after any removals have been subtracted (essentially displaying what the merchant would see in the admin as the "total" value for an edited order), I can't guarantee when/if this will be implemented, but I can confirm we do have developer eyes on this issue.

Hope this helps. 

Al | Shopify Developer Support

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 2 (2)

ShopifyDevSup
Shopify Staff
1453 238 511

This is an accepted solution.

Hi @samherrmann - I was able to do a bit of digging into this on our end and can confirm the above is expected behaviour. Removed shipping lines will always be included in REST Order resource payloads (a bit more info in this changelog here). As of API version 2024-04 though, we have added an is_removed attribute which does delineate a removed shipping line. 

I was also able to get in touch with our product team who is responsible for the Shipping/Order resource and they confirmed that the total_shipping_price_set field returning the value of the removed shipping fee is also expected behaviour, as it follows the logic of the total_price_set field which displays the full value for an order, including all funds that were returned, removed product values, product edits, etc. 

I have passed along a request for a shipping price related field/resource that reflects the behaviour of the current_total_price field, where it only displays the value of an order after any removals have been subtracted (essentially displaying what the merchant would see in the admin as the "total" value for an edited order), I can't guarantee when/if this will be implemented, but I can confirm we do have developer eyes on this issue.

Hope this helps. 

Al | Shopify Developer Support

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

Bjorn_Forsberg_
Shopify Partner
303 4 70

Thanks so much for this info @ShopifyDevSup and for passing on that information. May I suggest this info is added to the "Release notes" for the 2024-04 API version? https://shopify.dev/docs/api/release-notes/2024-04

 

Many thanks again!

Bjorn

Bjorn Forsberg | FORSBERG+two | Award-winning Shopify Apps since 2011