Automattic\WooCommerce\Internal\Orders
PaymentInfo::get_card_info
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() PaymentInfo::get card info WC 10.4.2
public static function get_card_info( WC_Abstract_Order $order ): array {
$method = $order->get_payment_method();
/**
* 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();
}
// Fallback for WooPayments.
if ( empty( $info ) && 'woocommerce_payments' === $method ) {
$info = self::get_wcpay_card_info( $order );
}
$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;
}