WC_Order::get_cancel_order_url PHP Method

get_cancel_order_url() public method

Generates a URL so that a customer can cancel their (unpaid - pending) order.
public get_cancel_order_url ( string $redirect = '' ) : string
$redirect string
return string
    public function get_cancel_order_url($redirect = '')
    {
        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'));
    }

Usage Example

 public function generate_form($order_id)
 {
     $order = new WC_Order($order_id);
     $order_name = __('Order No. ') . $order_id;
     $args = array('receiver' => $this->wallet_number, 'formcomment' => $this->formcomment, 'short-dest' => $order_name, 'quickpay-form' => 'shop', 'targets' => $order_name, 'sum' => $order->order_total, 'paymentType' => 'AC', 'label' => $order_id);
     $paypal_args = apply_filters('woocommerce_robokassa_args', $args);
     $args_array = array();
     foreach ($args as $key => $value) {
         $args_array[] = '<input type="hidden" name="' . esc_attr($key) . '" value="' . esc_attr($value) . '" />';
     }
     return '<form action="' . esc_url($this->url) . '" method="POST" class="order_actions">' . "\n" . implode("\n", $args_array) . '<input type="submit" class="button alt" value="' . __('Pay') . '" /> <a class="button cancel" href="' . $order->get_cancel_order_url() . '">' . __('Cancel Order') . '</a>' . "\n" . '</form>';
 }
All Usage Examples Of WC_Order::get_cancel_order_url
WC_Order