WC_Order::get_cancel_order_url
Generates a URL so that a customer can cancel their (unpaid - pending) order.
Method of the class: WC_Order{}
Hooks from the method
Returns
String.
Usage
$WC_Order = new WC_Order(); $WC_Order->get_cancel_order_url( $redirect );
- $redirect(string)
- Redirect URL.
Default:''
WC_Order::get_cancel_order_url() WC Order::get cancel order url code WC 10.5.0
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(
add_query_arg(
array(
'cancel_order' => 'true',
'order' => $this->get_order_key(),
'order_id' => $this->get_id(),
'redirect' => $redirect,
),
$this->get_cancel_endpoint()
),
'woocommerce-cancel_order'
),
$this,
$redirect
);
}