cancel_order - take no action if already cancelled.
This commit is contained in:
parent
7b639d45c7
commit
f09db7a537
|
@ -503,7 +503,9 @@ class WC_Form_Handler {
|
|||
$order_can_cancel = in_array( $order->status, apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ) ) );
|
||||
$redirect = $_GET['redirect'];
|
||||
|
||||
if ( $user_can_cancel && $order_can_cancel && $order->id == $order_id && $order->order_key == $order_key && wp_verify_nonce( $_GET['_wpnonce'], 'woocommerce-cancel_order' ) ) {
|
||||
if ( $order->status == 'cancelled' ) {
|
||||
// Already cancelled - take no action
|
||||
} elseif ( $user_can_cancel && $order_can_cancel && $order->id == $order_id && $order->order_key == $order_key && wp_verify_nonce( $_GET['_wpnonce'], 'woocommerce-cancel_order' ) ) {
|
||||
|
||||
// Cancel the order + restore stock
|
||||
$order->cancel_order( __('Order cancelled by customer.', 'woocommerce' ) );
|
||||
|
|
Loading…
Reference in New Issue