WC_Shortcode_Checkout::get_order_preselected_gateway │ private static │ WC 11.3.0

Get the gateway to pre-select on the pay page, when it should differ from the default selection.

A merchant assigns the method when creating an order in admin, so that assignment is the pre-selection. Orders placed through checkout carry the method the shopper picked, so those keep the default selection.

Метод класса: WC_Shortcode_Checkout{}

Хуков нет.

Возвращает

WC_Payment_Gateway|null.

Использование

$result = WC_Shortcode_Checkout::get_order_preselected_gateway( $order, $available_gateways );
$order(WC_Order) (обязательный)
Order being paid for.
$available_gateways(WC_Payment_Gateway[]) (обязательный)
Gateways available on the pay page, keyed by gateway ID.

Список изменений

С версии 11.3.0 Введена.

Код WC_Shortcode_Checkout::get_order_preselected_gateway() WC 11.3.0

private static function get_order_preselected_gateway( WC_Order $order, array $available_gateways ) {
	if ( ! $order->is_created_via( 'admin' ) ) {
		return null;
	}

	$payment_method = $order->get_payment_method();

	return $payment_method && isset( $available_gateways[ $payment_method ] ) ? $available_gateways[ $payment_method ] : null;
}