WC_Payment_Gateways::get_available_payment_gateways
Get available gateways for checkout.
This should be used when displaying the available gateways/payment methods to the user, not in the WP admin or REST API contexts where there is no WC session. This is because the logic that hooks into the available gateways filter may try to rely on the existence of a WC session - a valid thing to do, and cause fatal errors when the session is not available.
Метод класса: WC_Payment_Gateways{}
Хуки из метода
Возвращает
WC_Payment_Gateway[]. The available payment gateways.
Использование
$WC_Payment_Gateways = new WC_Payment_Gateways(); $WC_Payment_Gateways->get_available_payment_gateways();
Код WC_Payment_Gateways::get_available_payment_gateways() WC Payment Gateways::get available payment gateways WC 11.3.0
public function get_available_payment_gateways() {
$_available_gateways = array();
foreach ( $this->payment_gateways as $gateway ) {
if ( $gateway->is_available() ) {
if ( ! is_add_payment_method_page() ) {
$_available_gateways[ $gateway->id ] = $gateway;
} elseif ( $gateway->supports( PaymentGatewayFeature::ADD_PAYMENT_METHOD ) || $gateway->supports( PaymentGatewayFeature::TOKENIZATION ) ) {
$_available_gateways[ $gateway->id ] = $gateway;
}
}
}
return array_filter( (array) apply_filters( 'woocommerce_available_payment_gateways', $_available_gateways ), array( $this, 'filter_valid_gateway_class' ) );
}