WC_Gateway_COD::process_payment
Process the payment and return the result.
Метод класса: WC_Gateway_COD{}
Хуки из метода
Возвращает
Массив.
Использование
$WC_Gateway_COD = new WC_Gateway_COD(); $WC_Gateway_COD->process_payment( $order_id );
- $order_id(int) (обязательный)
- Order ID.
Код WC_Gateway_COD::process_payment() WC Gateway COD::process payment WC 10.4.3
public function process_payment( $order_id ) {
$order = wc_get_order( $order_id );
if ( $order->get_total() > 0 ) {
/**
* Filter the order status for COD orders.
*
* @since 2.6.0
*
* @param string $order_status Default status for COD orders.
*/
$process_payment_status = apply_filters( 'woocommerce_cod_process_payment_order_status', $order->has_downloadable_item() ? OrderStatus::ON_HOLD : OrderStatus::PROCESSING, $order );
// Mark as processing or on-hold (payment won't be taken until delivery).
$order->update_status( $process_payment_status, __( 'Payment to be made upon delivery.', 'woocommerce' ) );
} else {
$order->payment_complete();
}
// Remove cart.
WC()->cart->empty_cart();
// Return thankyou redirect.
return array(
'result' => 'success',
'redirect' => $this->get_return_url( $order ),
);
}