Calculate shipping rates for built in carriers

Highlighted
Shopify Partner
11 0 0

Hi!
The situation is the store has a paid account and shopify can calculate price based rate and USPS rates on checkout page. But I want to do the same thing in my app. I can use shipping api for price and weight based shipping rates only.

Is there any way to calculate shipping rates for built in carriers like DHL, UPS, USPS.

 Is there any api for built in carriers?

0 Likes
Highlighted
Shopify Partner
11 0 0

any ideas?

0 Likes
Highlighted
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 124

Hi @miholeus ,

 

This would depend on where your app was running. If it was running on the Shopify online storefront, you could use the AJAX Cart API to hit the endpoint of "GET /cart/shipping_rates.json" and get all the calculated shipping rate values that would appear in the Checkout:

 

https://shopify.dev/docs/themes/ajax-api/reference/cart#get-cart-shipping_rates-json

https://shopify.dev/docs/themes/ajax-api/getting-started

 

If your app is an embedded app installed on the store's Admin or a private app using the Admin API, then I do not believe there is anyway to get these calculated shipping rate values for the carriers of DHL, UPS, USPS, etc.. I believe your app would have to have its own integration with each of these companies in order to calculate the shipping rates via an API connection.

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Shopify Partner
11 0 0

Hi @hassain ,

Thanks for an answer. If I make my own integration, the shipping amount will be different, right?

I know that Shopify has its own preferences if you make shipping via carriers. It depends on the plan the shop owner has.

And you give different discounts for each plan.

Is there a way to get that percentages for discounts?

 

Question #2:

I'm using draft orders in my app.

What kind of shipping line for carriers do I have to pass during draft order creation if I use cart rates API "/cart/shipping_rates.json"?
Should it be just "handle" property or "custom"=true is a must attribute if I use carriers shipping?

0 Likes
Highlighted
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 124

Hi @miholeus ,

 

For #2, you cannot use the Ajax Cart API with Draft Orders. The Ajax Cart API can only be used from the front-end of the Shopify online storefront website, whereas Draft Orders can only be made through the Shopify Admin webpage for the store or through the Admin API

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Shopify Partner
11 0 0

Hi @hassain , yes I know that draft orders can be created via Admin API.

I can calculate shipping via ajax cart api, then pass the handle on a backend during order creation.

Do I need to pass custom=true property in a shipping line for a draft order in that case or handle/price would be enough?

 

0 Likes
Highlighted
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 124

Thanks for the clarification @miholeus 

 

Since you are getting legitimate shipping rates with real shipping handles, I do not believe that you need to set custom=true in your shipping line. Custom shipping lines, according the documentation, are only for when you have a "title" and "price" but "handle" is set to null. So if you have a non-null "handle" field, then you do not need to set the shipping line as custom

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes