Orders cancel.json Restock Deprecated

Solved
dwbott
Tourist
4 1 0

Part of my plugin's ecosystem is cancelling orders whenever an action happens outside of Shopify. In order to accomplish that we're calling the Rest API's cancel.json method for the specific order in question. For a while I thought that the restocking of inventory was just an automated thing that happened when the order was cancelled before payment but we now have a merchant who is using our plugin and complaining that the restocking isn't happening for orders cancelled by our API call. 

After looking at the API documentation again, the cancel.json method notes that the "restock" parameter has been deprecated. What should be done now that this parameter is deprecated? Is another API call required to restock the inventory? If there a setting in the store that can be updated? 

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 237

Please refer to this thread which discusses this -->https://stackoverflow.com/questions/60606840/how-to-cancel-and-restock-order-using-shopify-api. Hope this helps!

0 Likes
dwbott
Tourist
4 1 0

Cancellation is being called before the payment has been taken so I would assume that would affect the ability of the refund method. Am I wrong?

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 237

Here's another link that might shed some light --> https://community.shopify.com/c/Technical-Q-A/Cancel-Order-API-gt-Not-restocking-quantity-to-the-pro.... Although the last comment wasn't marked as a solution...

0 Likes
dwbott
Tourist
4 1 0

I had already read that thread but there wasn't a solution in it either and the last comment who stated they got it to work was using the property which is marked as deprecated by Shopify's API. 

0 Likes
dwbott
Tourist
4 1 0

This is an accepted solution.

For anyone who comes across this in the future, though the API documentation states that the "restock" property of Order's cancel.json method is deprecated, the property DOES still function as you would expect. I assume at whatever point they do decide to actually fully deprecate it, they will release some actual instructions on what to do to restock items. 

So again, for now, if you need to cancel and restock, just call the cancel.json method with:

{
    "restock": true
}

 

0 Likes
JoesIdeas
Shopify Expert
1305 118 339

Note for anyone using the restock: true property, it doesn't work well with stores with multiple location because it doesn't always restock the correct location. My guess is that instead of restocking to the assigned location, it restocks to the priority location.

Would be nice if Shopify kept this property and had it restock correctly, it's a useful property and saves us from having to make multiple API calls to restock an order after cancelling.

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
phelanjo
New Member
1 0 0

I can cancel orders and restock products using separate API calls (one to cancel the order, and one to restock the products using InventoryLevel), but when I look in the Admin:

phelanjo_0-1614281571973.png

It makes it appear that inventory was manually added/removed, and doesn't tie it to an order (like on line 3), and in the actual Order, it doesn't show that it was restocked like it used to:

phelanjo_2-1614282361855.png

To remedy this, I tried using the Refund API, but we don't use Shopify's Checkout to process payment for some orders (long story), and those orders don't have a refund (in Shopify, at least). When I used the Refund API to restock items using the "restock_type" option in "refund_line_items", a Shopify Refund object is returned, "refund(None)", which is understandable because there is no actual refund, and no items are restocked.

I guess my question is, is there a different way to restock items after cancelling an order that will mimic the deprecated "restock" parameter functionality?

0 Likes