Automattic\WooCommerce\Blocks\BlockTypes

PaymentMethodIcons::get_other_payment_method_iconsprivateWC 1.0

Get other payment method icons from available gateways.

Method of the class: PaymentMethodIcons{}

No Hooks.

Returns

Array. Other payment method icons.

Usage

// private - for code of main (parent) class only
$result = $this->get_other_payment_method_icons();

PaymentMethodIcons::get_other_payment_method_icons() code WC 10.3.6

private function get_other_payment_method_icons() {
	$available_gateways    = WC()->payment_gateways->get_available_payment_gateways();
	$other_payment_methods = array();

	if ( empty( $available_gateways ) ) {
		return $other_payment_methods;
	}

	foreach ( $available_gateways as $gateway ) {
		if ( 'yes' === $gateway->enabled ) {
			if ( 'woocommerce_payments' === $gateway->id ) {
				continue;
			}

			$icon_url = '';
			if ( is_callable( array( $gateway, 'get_icon_url' ) ) ) {
				$icon_url = $gateway->get_icon_url();
			}
			if ( ! empty( $icon_url ) ) {
				$other_payment_methods[] = array(
					'name' => $gateway->get_title(),
					'icon' => $icon_url,
				);
			}
		}
	}

	usort(
		$other_payment_methods,
		function ( $a, $b ) {
			return strcmp( $a['name'], $b['name'] );
		}
	);

	return $other_payment_methods;
}