Add a shipping method with the Order API

Solved
Highlighted
Shopify Expert
808 67 188

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?

Founder of Speed Boostr (Shopify optimization and dev agency).
Creator of Theme Scientist (A/B testing app).
Creator of Order Automator (app that auto tags + fulfills orders, send emails).
Creator of Tip Jar (add a tip button to your store).
Creator of Shopify Analyzer (free performance analysis tool).
My team also builds custom apps and automated solutions.
Enjoy the adventure!
0 Likes
Highlighted
Shopify Staff
Shopify Staff
587 72 130

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 | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes