diff --git a/plugins/woocommerce/changelog/pr-40275 b/plugins/woocommerce/changelog/pr-40275 new file mode 100644 index 00000000000..059d3898b13 --- /dev/null +++ b/plugins/woocommerce/changelog/pr-40275 @@ -0,0 +1,4 @@ +Significance: minor +Type: enhancement + +Add order instance and redirect URL arguments to woocommerce_get_cancel_order_url and woocommerce_get_cancel_order_url_raw filters diff --git a/plugins/woocommerce/includes/class-wc-order.php b/plugins/woocommerce/includes/class-wc-order.php index f3550ec7beb..cb4940f3280 100644 --- a/plugins/woocommerce/includes/class-wc-order.php +++ b/plugins/woocommerce/includes/class-wc-order.php @@ -1802,6 +1802,15 @@ class WC_Order extends WC_Abstract_Order { * @return string */ public function get_cancel_order_url( $redirect = '' ) { + /** + * Filter the URL to cancel the order in the frontend. + * + * @since 2.2.0 + * + * @param string $url + * @param WC_Order $order Order data. + * @param string $redirect Redirect URL. + */ return apply_filters( 'woocommerce_get_cancel_order_url', wp_nonce_url( @@ -1815,7 +1824,9 @@ class WC_Order extends WC_Abstract_Order { $this->get_cancel_endpoint() ), 'woocommerce-cancel_order' - ) + ), + $this, + $redirect ); } @@ -1826,6 +1837,15 @@ class WC_Order extends WC_Abstract_Order { * @return string The unescaped cancel-order URL. */ public function get_cancel_order_url_raw( $redirect = '' ) { + /** + * Filter the raw URL to cancel the order in the frontend. + * + * @since 2.2.0 + * + * @param string $url + * @param WC_Order $order Order data. + * @param string $redirect Redirect URL. + */ return apply_filters( 'woocommerce_get_cancel_order_url_raw', add_query_arg( @@ -1837,7 +1857,9 @@ class WC_Order extends WC_Abstract_Order { '_wpnonce' => wp_create_nonce( 'woocommerce-cancel_order' ), ), $this->get_cancel_endpoint() - ) + ), + $this, + $redirect ); }