How can I calculate shipping price through my own API?

How can I calculate shipping price through my own API?

webnikita
Shopify Partner
2 0 0

Hello, when creating an order, I need to calculate the shipping price according to my logic, through my api, how can I do this?

Replies 4 (4)

sniper2804
Shopify Partner
406 25 68

Checkout Carrier Calculated Shipping (CCS) in Shopify
https://shopify.dev/docs/api/admin-rest/2023-01/resources/carrierservice

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
webnikita
Shopify Partner
2 0 0

That is, I create an endpoint (I accept it), I process everything and give the response, will this be taken into account when ordering an order and during checkout?

sniper2804
Shopify Partner
406 25 68

Yes. Exactly. 
Be mindful that you need CCS to be enabled on your store for this to work. 
Check this document on how you can get CCS activated: https://help.shopify.com/en/manual/shipping/setting-up-and-managing-your-shipping/enabling-shipping-...

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

remy727
Shopify Partner
44 2 26
# Shipping lines format
shipping_lines = [{
  title: your_shipping_title,
  price: your_shipping_line_price,
  code: your_shipping_code,
  source: your_shipping_line_source
}]

# Example
shipping_lines = [{
  title: "Standard Shipping",
  price: 10.0, # if you want free shipping, you can set this as 0
  code: "Standard Shipping",
  source: "shopify"
}]

# Create order using Shopify API
payload = {
  # other fields
  shipping_lines: shipping_lines
}

ShopifyAPI::Order.create(payload)
Looking for a Shopify App developer? Please contact me at [email protected]