Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Custom Carrier Service - Get product properties?

Custom Carrier Service - Get product properties?

newbie_01
Shopify Partner
34 0 13

I'm starting to test my own carrier service for calculating shipping rates.

The request includes SOME details of the products in the cart, but it would be nice to have more.

There is a 'properties' entry that shows up empty. Would it be possible to include a metafield there? or a list of locations with stock?

 

I could make a list of product IDs and query the API, but would prefer to avoid an extra trip back and forth.

 

Thanks

Replies 10 (10)

jtaylormatchles
Shopify Partner
45 1 15

Are you setting product properties (even if hidden) on any of your products? It will be empty unless you are using it.

newbie_01
Shopify Partner
34 0 13

Oh... this refers to CART (line item) properties, not PRODUCT properties. Now I get it, somewhat.

From what I gather, to load a product metafield into a cart property I'd have to add an input into the product from by editing the theme liquid template?

jtaylormatchles
Shopify Partner
45 1 15

If you're referencing "metafields" as a proper Shopify object (Metafield (shopify.dev)) you'd have to query the API for that inside your carrier service implementation. 

That will be the easiest way to do it. 

Metafields aren't available (last I checked) in the product ajax api. So if you were to do it from the liquid side, you'd have to set a js variable to the metafield value using liquid when the page is rendered, and then when added to cart, push that into a line item property. That's a little messy, but can work. 


newbie_01
Shopify Partner
34 0 13

Yes, it's too messy, and the value passes through the client computer, even if hidden.

 

From my limited testing with the carrier service, the query always includes the main store address as ship-from, even if the item is only stored at another location. To calculate shipping costs I'll have to implement my own logic to find out where the order is actually shipping from.

My app will have to do its own api queries to gather the data needed for that.

 

Thanks for your help!

jtaylormatchles
Shopify Partner
45 1 15

A lot of that is going to depend on how you've set up your shipping profiles. In my case, anything that uses my custom carrier service (for LTL freight) is all under one shipping profile, and all comes from the same fulfillment location. So, not sure about that one because I didn't need anything more advanced.

newbie_01
Shopify Partner
34 0 13

Not sure if it's better to start spinning different profiles, or to query the api to find out the ship location with my own logic. Will investigate. You have given me a lot to think about. Thanks!

jtaylormatchles
Shopify Partner
45 1 15

Just remember that anything you do in your service needs to respond within a certain amount of time. Be quick with it. For what I do, I synchronize the data I need into some lookup tables. Big anti-pattern, but sometimes it's what you do to have to be fast.

MSHANI
Visitor
1 0 0

Yes, it's possible to include a metafile in the 'properties' entry or a list of locations with stock to provide more details about the products in the cart. This would help streamline the process and avoid the need for an extra API query.

Thomas47
Shopify Partner
58 0 12

Were you able to accomplish this so that no additional calls were necessary at checkout? 

newbie_01
Shopify Partner
34 0 13

No. The info you get in the original call is limited. If you need product details you must query the api on the spot or keep your own database somewhere else.