shipping_lines object versus custom carrier selection object

Liquidator3358
Explorer
44 1 15

Hey guys,

 

When you create a carrier programmatically through the customer carrier-calculated shipping, the format is like this:

{
  "service_name": quotes.carrier.carrierName.toUpperCase(),
  "service_code": "ON",
  "total_price": quotes.totalCharge * 100,
  "description": `ID: ${quotes.quoteId}, Minimum Transit Days: ${quotes.transit.minimumTransitDays}`,
  "currency": 'USD',
}

This is what will be displayed at checkout when the user is selecting their carrier.

 

But my question has to do with retrieving that same information through the shipping_lines array (array of objects) and what data matches what.  Will the same key/values be found within the shipping_lines collection or will it be under a different set of key/values.  If they are different, where can I find the proper object structure?

Replies 2 (2)

ShopifyDevSup
Shopify Staff
1246 201 442

Hey @Liquidator3358 - you're right that the information would be found through the shipping_lines array as part of the order resource. Once a customer's order is processed at checkout, an order object is created that retains the shipping information for the carrier associated with the fulfillment for that order. 

There's a bit more detail here in our docs in terms of how this works when you're attempting to retrieve specific order information, but you would want to look for the related properties under the shipping_lines array:

 



These properties present in the shipping_lines array would not be titled the same as the parameters set up in your callback function's JSON file, but many of the values of the properties would match. For instance, the title field in the shipping_lines array corresponds to the service_name field in the callback JSON file you created when you set up the carrier service. Hope this helps - let us know if we can clarify anything on our end. 

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

Liquidator3358
Explorer
44 1 15

Hey @ShopifyDevSup ,

 

Thanks for getting back to me and I assumed that was the case but my main point of interest was the conversion between the description field within the carrier selected rates and the shipping_lines objects.  Do you happen to know which would be the description?  From the documentation, I was assuming it would be the code field.  Can you verify that?

 

I am passing shipping rate IDs from another 3PL within the description and I will have to parse it out within a webhook handler when an order is created - it is vital to my processing.

 

Thanks again!