Add a shipping method with the Order API

Solved
JoesIdeas
Shopify Expert
1791 158 475

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 (app to save time + automate tasks, monitor orders, tag, fulfill, FBA)
• Shopify developer for +10 years
• Contributor on the Speed Boostr blog
• Guy who likes to help people
Accepted Solution (1)

Accepted Solutions
_JB
Shopify Staff
Shopify Staff
836 100 218

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
Shopify Staff
836 100 218

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
18 0 1

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