Add a shipping method with the Order API

Solved
JoesIdeas
Shopify Expert
1241 111 309

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 experts, theme customization, custom app development).
Creator of Shopify Analyzer (first performance analysis tool for Shopify sites, free for the Shopify community).
Creator of Order Automator (auto tag orders and customers + auto fulfillment + more automations).
More apps: Theme Scientist (A/B testing), Tip Jar (add a tip button), File Optimizer (optimize CSS, JS, Liquid).
0 Likes
_JB
Shopify Staff
Shopify Staff
809 95 176

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? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
zainmirza60
New Member
5 0 0

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

0 Likes