Solved

Custom Shipping Rates

czupet
Shopify Partner
9 0 0

Shopify has the ability to get shipping rates from several carriers (USPS, UPS, FedEx, DHL), but not from a custom carrier, I need the ability to get rates from a fulfillment center, I want to use fulfillment's rates without them sharing their credentials to (UPS, USPS, FedEx, DHL).

I want Shopify to be able to call an API, get the rates from the fulfilment center and display those rates to a customer instead of the rates from USPS, UPS FedEx, DHL, but I want those rates to appear to the customer as if those rates are coming from those carriers. 

 

So the customer would still be able to select the carrier (UPS, USPS, FedEx, DHL), but the carrier's rates are coming from the fulfillment center instead of the carriers.  So the customer requests the rates, Shopify calls fulfillment center's API, fulfillment calls the carrier's API, retrieves the rates, and sends those rates to Shopify and Shopify displays those rates to the customer.

 

What is the best way to accomplish this?  Is this even possible? Do I have to hire a Shopify programmer to do this? 

 

Thank You

 

Peter

Accepted Solutions (2)

olivert
Explorer
51 12 19

This is an accepted solution.

Hi Peter, 

Yep you can do that, 

I have this same situation, where we use a 3rd Party Logistics company for fulfillment, and they get nicer rates with carriers. 

and they will not share their Carrier API keys as it's a 3rd party. 

 

Have a look at setting up a custom carrier service:

https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/carrierservice?api[versio...

You can setup a webhook to your 3PL or whichever other service's API if any. 

Keep in mind Shopify requires a specific response JSON format to work.

I've found it's easier to create your own web service using AWS Lambda or Google Cloud Functions etc, 

and direct your Shopify webhook to that. 

Then you can route all your requests through that, and make sure it's in the correct format both too and from your 3rd party.

 

Another option, would be to use the app Bespoke Shipping. 

This app is great, but is unable to call a custom API endpoint. 

You are limited to the carriers they currently integrate with. 

 

You can also put your own hard-coded logic in there if that helps.

https://parcelintelligence.com.au/cs/documentation/#/integrations?id=carrier-integrations

View solution in original post

olivert
Explorer
51 12 19

This is an accepted solution.

Yep so you use the api to create a CarrierService

Part of creating a carrier service is specifying the callback URL (callback_url)

This is the url shopify will call when it wants to get rates from the carrier. It'll fire off a POST to that url when it wants rates from that carrier.

The response from that call is used to populate the shipping options.  

Link below.

You want to setup your special carrier and get shopify to use it when getting shipping options.

https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/carrierservice?api[versio...

 

View solution in original post

Replies 11 (11)

olivert
Explorer
51 12 19

This is an accepted solution.

Hi Peter, 

Yep you can do that, 

I have this same situation, where we use a 3rd Party Logistics company for fulfillment, and they get nicer rates with carriers. 

and they will not share their Carrier API keys as it's a 3rd party. 

 

Have a look at setting up a custom carrier service:

https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/carrierservice?api[versio...

You can setup a webhook to your 3PL or whichever other service's API if any. 

Keep in mind Shopify requires a specific response JSON format to work.

I've found it's easier to create your own web service using AWS Lambda or Google Cloud Functions etc, 

and direct your Shopify webhook to that. 

Then you can route all your requests through that, and make sure it's in the correct format both too and from your 3rd party.

 

Another option, would be to use the app Bespoke Shipping. 

This app is great, but is unable to call a custom API endpoint. 

You are limited to the carriers they currently integrate with. 

 

You can also put your own hard-coded logic in there if that helps.

https://parcelintelligence.com.au/cs/documentation/#/integrations?id=carrier-integrations

czupet
Shopify Partner
9 0 0

The webhook integration sounds very interesting.

Are you able to display rates from 3PL, but as USPS, UPS, FedEx... to a customer. So it looks like the rates are coming directly from the carriers and not from 3PL?  I have never seen how that looks like to a customer in the Shopify store, only the standard rates or free shipping.

 

Thank You

 

Peter

olivert
Explorer
51 12 19

Yep Shopify will display whatever is returned from your web service.

With your web server that's processing these requests just make sure to return the service_name "USPS", "UPS"  "Custom Shipment" etc

You can see in the "Response Fields" section of the CarrierService.

 

from the docs:

service_name: The name of the rate, which customers see at checkout. For example: Expedited Mail.

 

You can call it whatever you'd like.

czupet
Shopify Partner
9 0 0

Do you know where I can find documentaton on these Webhooks for getting and displaing rates?

I've found these, but none of them look like the right ones.

https://shopify.dev/docs/admin-api/rest/reference/events/webhook?api[version]=2020-04

olivert
Explorer
51 12 19

This is an accepted solution.

Yep so you use the api to create a CarrierService

Part of creating a carrier service is specifying the callback URL (callback_url)

This is the url shopify will call when it wants to get rates from the carrier. It'll fire off a POST to that url when it wants rates from that carrier.

The response from that call is used to populate the shipping options.  

Link below.

You want to setup your special carrier and get shopify to use it when getting shipping options.

https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/carrierservice?api[versio...

 

czupet
Shopify Partner
9 0 0

Thanks a gain.

pgiri
Visitor
1 0 0

Hello, 

I am new to Shopify. Is it possible to use this feature(ttps://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/carrierservice?api[version]=2020-04) in Shopify basic plan if we paid annually?

 

Thanks!

Stonesoft
Shopify Partner
2 0 0

Hey Olivert,

 

I've got most of this working:

  • I have created a custom carrier using an access token generated from the Apps section of my store.
  • The Carrier shows up in the admin settings
  • The webhook is hitting my endpoint and I can log the expected data

The issue I am having is that when I try to return the rates to Shopify, they don't show up as 'Services' in the admin settings; nor in the checkout process.

 

I've done the following to help troubleshooting:

  • Slightly change the address to prevent caching during troubleshooting.
  • Copy/pasted the response object provided by their documentation (Also verified I properly converted to JSON)
  • Verified that my SSL cert was legit using a few 3rd party services (I had read that this was the issue for a someone else with my reported issue)
  • Spoke with general, partner and some kind of technical support from Shopify, with no clear answer or direction.
  • Searched the forums and internet for over 4 hours.
  • Followed steps to a few other tutorials to get this to work, in their various languages exactly as they advised.
  • Scrapped my development shop and started over from the top.
  • Ensured I had the correct permissions for the app scope, then added all permissions.
  • Checked the github page for this API (per Shopify's recommendation) https://github.com/Shopify/shipping-fulfillment-app; only to find that others have reported my problem ~10 years ago with no answer.

 

"Keep in mind Shopify requires a specific response JSON format to work."

I can't seem to find anything in their documentation that touches on that. Unless you mean the examples they provide in the docs, which are definitely not working for me. Could you point me in that direction maybe?  I'm getting to my wits end here, any help would be greatly appreciated!

Jebert94
Shopify Partner
1 0 0

@Stonesoft Did you ever figure out what your issue was?

Stonesoft
Shopify Partner
2 0 0

@Jebert94,
I did, as it turns out the framework I was using was altering the response format in a way that Shopify didn't like.  This line here,

"Keep in mind Shopify requires a specific response JSON format to work.";

was exactly the problem.  In my case the response was being wrapped with a format that conforms to jsonrpc.  When Shopify says it needs a specific response JSON format to work you need to follow their example exactly.  Any deviation from that will not work.  Make sure you monitor exactly what is being returned and ensure that the body of the response looks exactly like the Shopify examples in their API documentation.

YOD_Solutions
Shopify Partner
200 22 29

I know this is an old post and you have probably resolved this. 🙂  I have just to add to other people who might have a similar issue. We have recently launched a shipping rate app, JsRates, that lets you write your own shipping rules using JavaScript. One of the rich features of JsRates is it enables you make calls to third-party API endpoint; therefore, you can easily integrate rates from any third-party carrier.

Founder @ JsRates: Custom Shipping Rates
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more about JsRates visit the JsRates home page or JsRates documentation
- Find JsRates on Shopify app store