Automattic\WooCommerce\StoreApi\Utilities

AgenticCheckoutUtils::get_agentic_commerce_gatewaypublic staticWC 1.0

Get the agentic commerce payment gateway from available gateways.

Finds the first gateway that supports agentic commerce and has the required methods.

Method of the class: AgenticCheckoutUtils{}

No Hooks.

Returns

\WC_Payment_Gateway|null. The agentic commerce gateway or null if not found.

Usage

$result = AgenticCheckoutUtils::get_agentic_commerce_gateway( $available_gateways );
$available_gateways(array) (required)
Array of available payment gateways.

AgenticCheckoutUtils::get_agentic_commerce_gateway() code WC 10.4.3

public static function get_agentic_commerce_gateway( $available_gateways ) {
	if ( empty( $available_gateways ) ) {
		return null;
	}

	foreach ( $available_gateways as $gateway ) {
		if ( $gateway->supports( \Automattic\WooCommerce\Enums\PaymentGatewayFeature::AGENTIC_COMMERCE )
			&& method_exists( $gateway, 'get_agentic_commerce_provider' )
			&& method_exists( $gateway, 'get_agentic_commerce_payment_methods' )
		) {
			return $gateway;
		}
	}

	return null;
}