Change order status when order has backorder items in it
问题 In WooCommerce, How to change the on-hold order status to something else, if this order has back-ordered items in it? I have tried to use a custom function hooked in woocommerce_order_status_on-hold action hook without success. Can anyone help me on this issue? Thanks. 回答1: function mysite_hold($order_id) { $order = new WC_Order($order_id); $items = $order->get_items(); $backorder = FALSE; foreach ($items as $item) { if ($item['Backordered']) { $backorder = TRUE; break; } } if($backorder){