Automattic\WooCommerce\StoreApi\Utilities
PaymentUtils::include_token_id_with_payment_methods
Callback for woocommerce_payment_methods_list_item filter to add token id to the generated list.
Method of the class: PaymentUtils{}
No Hooks.
Returns
Array. The list item with the token id added.
Usage
$result = PaymentUtils::include_token_id_with_payment_methods( $list_item, $token );
- $list_item(array) (required)
- The current list item for the saved payment method.
- $token(WC_Token) (required)
- The token for the current list item.
PaymentUtils::include_token_id_with_payment_methods() PaymentUtils::include token id with payment methods code WC 10.8.1
public static function include_token_id_with_payment_methods( $list_item, $token ) {
$list_item['tokenId'] = $token->get_id();
$brand = ! empty( $list_item['method']['brand'] ) ?
strtolower( $list_item['method']['brand'] ) :
'';
if ( ! empty( $brand ) && esc_html__( 'Credit card', 'woocommerce' ) !== $brand ) {
$list_item['method']['brand'] = wc_get_credit_card_type_label( $brand );
}
return $list_item;
}