The "hold stock (minutes)" functionality of woocommerce is not working properly with Woocommerce stock manager, disabling this plugin is not a possibility for us.
My intention is to send the pending orders to canceled after 5 minutes.
Here is my code attempt:
function wc_cancel_pending_orders() {
if ( ! $order_id )
return;
$order = wc_get_order( $order_id );
$prod_date = $order->order_date;
$date_object = $order->order_date;
$date_object->modify('+5 minutes ');
$prod_is_new = (strtotime($prod_date) >= strtotime($date_object->format('Y-m-d')));
if ($prod_is_new) {
if( $order->has_status( 'pending' ) ) {
$order->update_status( 'cancelled' );
}
} else {
return;
}
}
add_action( 'woocommerce_order_status_changed', 'wc_cancel_pending_orders' );
But it is not giving me results, any suggestions or corrections in this code?