Add a shipping method with the Order API

Solved

Add a shipping method with the Order API

JoesIdeas
Shopify Partner
2325 211 616

Can you add a shipping method with the REST Order API?

Example:
1) An order comes in without a shipping method
2) I want to add a shipping method and update the order

Here's an example I tried (using the shopify_app gem):

order = ShopifyAPI::Order.find(2264716673078)
order.shipping_lines = [
  {
    custom: true,
    price: "0.00",
    title: "Free shipping"
  }
]
puts order.shipping_lines # This shows that the order object is updated correctly

order.save # Saves successfully

puts order.shipping_lines # After saving the order, the shipping_lines field is back to empty []

 

Any idea how to add a shipping method to an existing order with the API?

• Creator of Order Automator (automate tagging, fulfillment, Amazon, notifications + more)
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Figure Out Why You're Not Getting Sales
Accepted Solution (1)

_JB
Shopify Staff (Retired)
836 100 223

This is an accepted solution.

Hey @JoesIdeas,

It's not currently possible to add or modify an existing order's shipping_lines, but you may be able to use our new order editing API to achieve a similar result. This API allows you to add or modify the line_items on an order, so this could allow you to add a custom line_item to charge for shipping. You'll need to read through the docs to make sure this works for your use case, and don't hesitate to reach back out if there are any questions.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 2 (2)

_JB
Shopify Staff (Retired)
836 100 223

This is an accepted solution.

Hey @JoesIdeas,

It's not currently possible to add or modify an existing order's shipping_lines, but you may be able to use our new order editing API to achieve a similar result. This API allows you to add or modify the line_items on an order, so this could allow you to add a custom line_item to charge for shipping. You'll need to read through the docs to make sure this works for your use case, and don't hesitate to reach back out if there are any questions.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

zainmirza60
Shopify Partner
33 0 3

Yes we can edit the order with graphQL with order lineitems but I am looking more up from this like remove shipping line items and edit shipping line items and discount assign to order if we want. Please help us. Is this possible graphQL API