Automattic\WooCommerce\Internal\Admin\Settings

PaymentProviders::get_payment_gateways()publicWC 1.0

Get the payment gateways for the settings page.

We apply the same actions and logic that the non-React Payments settings page uses to get the gateways. This way we maintain backwards compatibility.

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

Хуки из метода

Возвращает

Массив. The payment gateway objects list.

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

$PaymentProviders = new PaymentProviders();
$PaymentProviders->get_payment_gateways( $exclude_shells ): array;
$exclude_shells(true|false)
Whether to exclude "shell" gateways that are not intended for display.
По умолчанию: true

Код PaymentProviders::get_payment_gateways() WC 9.6.1

public function get_payment_gateways( bool $exclude_shells = true ): array {
	if ( ! is_null( $this->payment_gateways_memo ) ) {
		$payment_gateways = $this->payment_gateways_memo;
	} else {

		// We don't want to output anything from the action. So we buffer it and discard it.
		// We just want to give the payment extensions a chance to adjust the payment gateways list for the settings page.
		// This is primarily for backwards compatibility.
		ob_start();
		/**
		 * Fires before the payment gateways settings fields are rendered.
		 *
		 * @since 1.5.7
		 */
		do_action( 'woocommerce_admin_field_payment_gateways' );
		ob_end_clean();

		// Get all payment gateways, ordered by the user.
		$payment_gateways = WC()->payment_gateways()->payment_gateways;

		// Store the entire payment gateways list for later use.
		$this->payment_gateways_memo = $payment_gateways;
	}

	// Remove "shell" gateways that are not intended for display.
	// We consider a gateway to be a "shell" if it has no WC admin title or description.
	if ( $exclude_shells ) {
		$payment_gateways = array_filter(
			$payment_gateways,
			function ( $gateway ) {
				return ! empty( $gateway->get_method_title() ) || ! empty( $gateway->get_method_description() );
			}
		);
	}

	return $payment_gateways;
}