WC_Order::get_checkout_payment_url PHP Method

get_checkout_payment_url() public method

Generates a URL so that a customer can pay for their (unpaid - pending) order. Pass 'true' for the checkout version which doesn't offer gateway choices.
public get_checkout_payment_url ( boolean $on_checkout = false ) : string
$on_checkout boolean
return string
    public function get_checkout_payment_url($on_checkout = false)
    {
        $pay_url = wc_get_endpoint_url('order-pay', $this->get_id(), wc_get_page_permalink('checkout'));
        if ('yes' == get_option('woocommerce_force_ssl_checkout') || is_ssl()) {
            $pay_url = str_replace('http:', 'https:', $pay_url);
        }
        if ($on_checkout) {
            $pay_url = add_query_arg('key', $this->get_order_key(), $pay_url);
        } else {
            $pay_url = add_query_arg(array('pay_for_order' => 'true', 'key' => $this->get_order_key()), $pay_url);
        }
        return apply_filters('woocommerce_get_checkout_payment_url', $pay_url, $this);
    }

Usage Example

 /**
  * Process the payment field and redirect to checkout/pay page.
  *
  * @param $order_id
  * @return array
  */
 function process_payment($order_id)
 {
     $order = new WC_Order($order_id);
     // Persist the payment method, bank name and emi months as private custom fields.
     update_post_meta($order->id, '_pz_payment_method', mysql_real_escape_string($_POST['pz_payment_method']));
     //update_post_meta($order->id, '_pz_bank_name', mysql_real_escape_string($_POST['pz_bank_name']));
     //update_post_meta($order->id, '_pz_emi_months', mysql_real_escape_string($_POST['pz_emi_months']));
     // Redirect to checkout/pay page
     return array('result' => 'success', 'redirect' => add_query_arg('order', $order->id, add_query_arg('key', $order->order_key, $order->get_checkout_payment_url(true))));
 }
All Usage Examples Of WC_Order::get_checkout_payment_url
WC_Order