WC_Checkout::process_order_without_payment
Process an order that doesn't require payment.
Method of the class: WC_Checkout{}
Hooks from the method
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->process_order_without_payment( $order_id );
- $order_id(int) (required)
- Order ID.
Changelog
| Since 3.0.0 | Introduced. |
WC_Checkout::process_order_without_payment() WC Checkout::process order without payment code WC 10.7.0
protected function process_order_without_payment( $order_id ) {
$order = wc_get_order( $order_id );
$order->payment_complete();
wc_empty_cart();
wc_log_order_step(
'[Shortcode #6B] Order processed without payment',
array(
'order_object' => $order,
'redirected' => ! wp_doing_ajax() ? 'yes' : 'no',
),
true
);
if ( ! wp_doing_ajax() ) {
wp_safe_redirect(
apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', $order->get_checkout_order_received_url(), $order )
);
exit;
}
wp_send_json(
array(
'result' => 'success',
'redirect' => apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', $order->get_checkout_order_received_url(), $order ),
)
);
}