Retrieving Shipping Costs via API

Inspire_Technol
Tourist
3 0 1

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

Replies 26 (26)
Josh
Shopify Staff
Shopify Staff
1134 82 213

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! 

Josh | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

ClementG
Shopify Partner
660 0 140

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)

ClementG
Shopify Partner
660 0 140

Now I'm wondering if I can use that endpoint to access other data not available in the 'normal' api.

Is it possible to get an exhaustive list of all verbs?

ClementG
Shopify Partner
660 0 140

Sorry for another question but do you have a sample json for a shipping_label_created_success?

Is it attached to the shop or to an order? If it's attached to a shop then I'm wondering how we can match it with an order....

ClementG
Shopify Partner
660 0 140

Another customer requested a report pulling shipping label costs.

Any improvement planned in this area would be very welcome!

ClementG
Shopify Partner
660 0 140

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

Johan_Land
Shopify Partner
14 0 11

@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...

 

 

 

Josh
Shopify Staff
Shopify Staff
1134 82 213

I do read this, and have been chatting with Clement directly outside of the forums. I have already logged a request to make this available outside of reading order events. 

Josh | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

ClementG
Shopify Partner
660 0 140

Still no update on this issue?

We get regular requests from merchants trying to report on their shipping cost.

BrandonSPX
Shopify Partner
35 0 17

Bumping this because we still need a resolution for this if it does not exist yet.

 

Pulling Freight costs (what we paid to the carriers) out of Shopify is absolutely critical for us and needs to be a part of the standard framework.

Jonathan-HA
Shopify Partner
224 10 67

+1 to make this data available in the Order API.  Just got another request for it from a customer of our app.

Co-Founder / Developer at Highview Apps
Our Shopify Apps: EZ Exporter | EZ Inventory | EZ Importer | EZ Notify | EZ Fulfill
LukeG
Excursionist
21 1 12

Any updates on this ?

AFerrara
Shopify Partner
12 1 4

Seems to be crickets from Shopify on this one, and now I'm stuck as a result as well as all the rest of the community.  This is basic stuff in a platform!  We are dying without this ability to easily retrieve our data.  

 

Status?  Anything?  Is it coming or is it a dead topic to Shopify?

Kristin_McCleme
Tourist
5 0 14

Hi Josh,

 

Is there a way to get this data from the Shopify Flow app?

Any update on when it will be available to get from the Orders API? 

We absolutely need this... please!

GoodfyLabs
Shopify Partner
61 0 8

Just to let thread still alive ....

 

Hope have something soon ... if is still no available ( I am not working on this right now) 

 

Best Regards 

William Alencar
GoodFy Labs
Brazilian Shopify Experts
Getting Satisfied Customers around the World
Skype : william.br1
wärting
New Member
1 0 0

Any updates?

ChangeRoom
Shopify Partner
4 0 2

Is there any update on this, this is quite important to build our app.

LukeG
Excursionist
21 1 12

I now there are quite a few people in here reading this.

 

Have you guys been successful fetching the shipping_label_created_success verb on the events endpoint ? ( It's not in the documentation as well. )

 

Even if I list all events in the collection there is now event with this verb.

 

Kind regards,

AFerrara
Shopify Partner
12 1 4

@LukeG the code below is a little snippet of C# that is getthing the rates back for me.  This one threw me because I wasn't  getting the value for *every* shipped order.  When I dug into it I found there are actually two that can get recorded.  Let's hope not three 😉

DataRow[] rows = eventsDS.Tables["events"].Select("verb = 'shipping_label_created_success' or verb = 'external_shipping_label_created_success'");