Оплата

Ваш кошик порожній.

add_action( 'woocommerce_order_status_changed', 'daily_cancel_unpaid_orders', 10, 4 ); function daily_cancel_unpaid_orders( $order_id, $old_status, $new_status, $order ) { // Enable the process to be executed daily if( in_array( $new_status, array('processing', 'completed') ) && get_option( 'unpaid_orders_daily_process' ) < time() ) : $days_delay = 1; // <=== SET the delay (number of days to wait before cancelation) $one_day = 24 * 60 * 60; $today = strtotime( date('Y-m-d') ); // Get unpaid orders (5 days old) $unpaid_orders = (array) wc_get_orders( array( 'limit' => -1, 'status' => 'pending', 'date_created' => '<' . ( $today - ($days_delay * $one_day) ), ) ); if ( sizeof($unpaid_orders) > 0 ) { $cancelled_text = __("The order was cancelled due to no payment from customer.", "woocommerce"); // Loop through WC_Order Objects foreach ( $unpaid_orders as $unpaid_order ) { $order->update_status( 'cancelled', $cancelled_text ); } } // Schedule the process to the next day (executed once restriction) update_option( 'unpaid_orders_daily_process', $today + $one_day ); endif; }