Hello,
As part of our store implementation, we are creating Orders through the Admin API. Our fulfillment team prints a UPS/USPS label from the Admin interface after selecting the calculated shipping rate. That all works wonderfully.
We're looking to capture the actual calculated shipping rate to account for our total costs.
However, even after the order is fulfilled, the `shipping_lines` array is null.
I'm hoping this is something simple that I'm missing, or there's some super secret way to get it.
Any ideas on how I can retrieve this data? Thanks so much in advance.
-Matt
Hey Matt,
Shipping labels are not currently exposed in the Orders API endpoint, I'm afraid. Just to clarify though, is it purely the shipping label price that you're trying to access for reporting reasons?
If so, there may be a workaround for you here via our Event API. It'll likely take some parsing in order to get the data you want programmatically, but if you were to use the event endpoint (ex. https://shop-name.myshopify.com/admin/orders/your_order_id/events.json) on an order you purchased a shipping label for, you should see a corresponding order event for that label purchase.
The event should have a 'verb' of "shipping_label_created_success" - and that event's 'message' would contain something like "You purchased a shipping label for $9.50 USD." as an example, giving you the price of the label that was purchased.
Hope that helps!
Hi Josh,
I just came across this post as I also need shipping cost for reporting purposes.
It would be great to add it on the order.shipping_lines[]
Also, regarding your work around. This verb is in the documentation. Is it safe to use?
And I also see no webhooks to subscribe to events? (only fulfillment events)
We managed to retrieve the shipping_label_created_success event.
We can parse the string but we are reluctant to doing so because any change in the text format would break the code.
Is it possible to change the event so that the amount is added to the arguments array property?
That would prevent parsing.
https://help.shopify.com/api/reference/events/event#arguments-property
@Inspire, it is possible to get the shipping cost. And, I'm sorry Josh doesn't seem to be able of helping. Use GraphQL and retrieve:
events(first:20) { edges { node { message attributeToUser } } }
... as part of order(). Then just parse the messages. Something like this:
for event in data["order"]["events"]["edges"]: e = event["node"] if(e["attributeToUser"]): m = e["message"] if "purchased a shipping label" in m: m = m[(m.find("$")+1):] endIndex = m.find(".", m.find(".")+1) m = m[:(endIndex)] deliveryCost = float(m) if m.isdigit(): deliveryEstimateComment = int(m)
@Josh, in the unlikely event that you read this, and even more unlikely event that you actually care (yes, that this point I'm quite cynical given that we've been asking for this for 2+ years). Please consider exposing the shipping labels. See my full explanation of why this is needed here: https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/urgently-need-a-solution-for-downloadi...
Subject | Author | Latest Post |
---|---|---|
Subject | Author | Posted |
---|---|---|
39m ago | ||
2 hours ago | ||
3 hours ago | ||
3 hours ago | ||
4 hours ago |
User | Count |
---|---|
257 | |
165 | |
134 | |
67 | |
38 |