woocommerce_valid_order_statuses_for_cancel

woocommerce_valid_order_statuses_for_cancel

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: filter

See hook in core

Displaying hooks found in version: woocommerce.8.7.0

apply_filters('woocommerce_valid_order_statuses_for_cancel') is found 2 times:

  • /includes/class-wc-form-handler.php line 757
    			$order_key        = wp_unslash( $_GET['order'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
    			$order_id         = absint( $_GET['order_id'] );
    			$order            = wc_get_order( $order_id );
    			$user_can_cancel  = current_user_can( 'cancel_order', $order_id );
    			$order_can_cancel = $order->has_status( apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) );
    			$redirect         = isset( $_GET['redirect'] ) ? wp_unslash( $_GET['redirect'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
    
    			if ( $user_can_cancel && $order_can_cancel && $order->get_id() === $order_id && hash_equals( $order->get_order_key(), $order_key ) ) {
    
    				// Cancel the order + restore stock.
    				WC()->session->set( 'order_awaiting_payment', false );
    
  • /includes/wc-account-functions.php line 301
    	if ( ! $order->needs_payment() ) {
    		unset( $actions['pay'] );
    	}
    
    	if ( ! in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ), true ) ) {
    		unset( $actions['cancel'] );
    	}
    
    	return apply_filters( 'woocommerce_my_account_my_orders_actions', $actions, $order );
    }