0

I have a shopping website with limited products. I'm looking for a solution in which, if Order status is "Processing", then Products in that specific Order remains hide from the Shop and Search result, unless Order status changed to Completed. (which means product is back in shop for purchase).

Moreover, all products will be sold individually.

Max
  • 31
  • 5
  • @LoicTheAztec does this solution will work for me? [link]Auto restock products on specific order status changes in Woocommerce (https://stackoverflow.com/questions/48910150/auto-restock-products-on-specific-order-status-changes-in-woocommerce) – Max Sep 15 '20 at 08:09

1 Answers1

0

You can use woocommerce_order_status_changed hooks. Using these hook you will get 3 params called $old_status, $new_status and $order_id. Then you just check is $new_status is processing or not. if processing then gets the order using $order_id and then create a loop for line_items. For each line item, you will get product_id and check the product is publish or not. If Publish then just make the product in draft status, if not then just continue the loop.

Like the same procedure, you can also check for Completed status. If the status is completed just loop through the order items and make each product draft to publish.

Hope you understand. If not, then let me know. I will share the code snippet

Sabbir Ahmed
  • 141
  • 2