Customer ID in carrier service callback api

Customer ID in carrier service callback api

sniper2804
Shopify Partner
406 25 68

Hi, 

 

We are building a custom shipping calculator app using the carrier service api for one of our clients. They want to offer free shipping for certain customers. 

 

But upon checking the carrier service request, I can see that no information about a customer is being sent, not even the customer id. 

 

Is there any way I can achieve this functionality?

Automate & bulk assign products to shipping profile: Auto Shipping Profiles: Shipr
Calculate accurate shipping rates: Shipping Calculator: ShipMagic
Hide, rename, reorder payment methods at checkout: Payment Customization: PayMix
Reply 1 (1)

Liam
Community Manager
3108 341 879

Hi Sniper2804,

 

As you've found when a customer goes through the Shopify checkout process and the system reaches out to the Carrier Service for shipping rates, the data included in the requests are typically related to the order itself (e.g., order contents, destination address) rather than information about the customer who is placing the order - which is why you're not seeing data like `customer_id`. 

 

As a work around, you could potentially store customer-specific shipping rules in a metafield (or a separate system) based on the customer ID, and then use that information when generating shipping rates within your app. However, this would not involve the Carrier Service API directly.

 

Here's an general approach on how it could work:

  1. When a customer logs in or otherwise interacts with your storefront, you can use the Storefront API or Admin API to fetch their customer ID and any other necessary information. This might be based on their tags, customer group, or other criteria.
  2. Save this information in a metafield associated with the customer or in your own separate system.
  3. When you are calculating shipping rates, you can refer back to this stored information to apply the correct rates based on the customer information.

Hope this helps!

Liam | Developer Advocate @ 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 Shopify.dev or the Shopify Web Design and Development Blog