Automattic\WooCommerce\Internal\Orders

PaymentInfo::get_card_info()public staticWC 1.0

Get info about the card used for payment on an order.

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

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

Возвращает

Массив.

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

$result = PaymentInfo::get_card_info( $order ): array;
$order(WC_Abstract_Order) (обязательный)
The order in question.

Код PaymentInfo::get_card_info() WC 9.5.1

public static function get_card_info( WC_Abstract_Order $order ): array {
	$method = $order->get_payment_method();

	if ( 'woocommerce_payments' === $method ) {
		$info = self::get_wcpay_card_info( $order );
	} else {
		/**
		 * Filter to allow payment gateways to provide payment card info for an order.
		 *
		 * @since 9.5.0
		 *
		 * @param array|null        $info  The card info.
		 * @param WC_Abstract_Order $order The order.
		 */
		$info = apply_filters( 'wc_order_payment_card_info', array(), $order );

		if ( ! is_array( $info ) ) {
			$info = array();
		}
	}

	$defaults = array(
		'payment_method' => $method,
		'brand'          => '',
		'icon'           => '',
		'last4'          => '',
	);
	$info     = wp_parse_args( $info, $defaults );

	if ( empty( $info['icon'] ) ) {
		$info['icon'] = self::get_card_icon( $info['brand'] );
	}

	return $info;
}