Cancel Order API => Not restocking quantity to the product

Umang_Dhanuka
New Member
4 0 0
Hello,

 

1. We want to cancel an order through the REST API and restock the quantities of all the products in that order.

2. When we call the cancel order API, the order is getting canceled.

3. But the products are not getting restocked.

 

Here is the json we are passing to the API:

/admin/api/2019-04/orders/#{order_id}/cancel.json
{  
   "amount":"1730",
   "email":true,
   "reason":"customer",
   "restock":true,
   "refund":{  
      "note":"Could not confirm order - API",
      "shipping":{  
         "full_refund":true
      },
      "refund_line_items":[  
         {  
            "line_item_id":2233138282573,
            "quantity":2,
            "restock_type":"cancel",
            "location_id":453551161421
         }
      ],
      "transactions":[  
         {  
            "parent_id":1245466886221,
            "kind":"refund",
            "gateway":"cash_on_delivery"
         }
      ]
   }
}

Please note when we view the order on Shopify, it says the line item has been restocked, but the actual product has not been restocked.

0 Likes
kristo_ox
New Member
4 0 0

H i

0 Likes
Umang_Dhanuka
New Member
4 0 0
Nope. Still pending for us.
0 Likes
JoesIdeas
Shopify Expert
1241 111 309

I was unable to restock cancelled orders as well, then got it to work by adding it as a parameter on the cancel action like this:

 

 

order.cancel(restock: true)


(Using the shopify_api gem).

 

 

It looks like restock property is now deprecated though:

https://help.shopify.com/en/api/reference/orders/order#cancel-2019-10

 

I wonder if Shopify recommends a different approach now?

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

Hi,

 

The restock works for me in this case:

1.  set void on transaction /admin/api/2020-01/orders/#{order_id}/transactions.json

{'kind': 'void'}

 

2. in /admin/api/2020-01/orders/#{order_id}/cancel.json set:

{'reason' : 'declined',  'restock' : true}
 
 
2. 
 
0 Likes