wc_get_account_saved_payment_methods_list_item_cc

Controls the output for credit cards on the my account page.

Description

(array) wc_get_account_saved_payment_methods_list_item_cc( (array) $item, (WC_Payment_Token) $payment_token ); 

Returns (array)

Filtered item

Parameters (2)

0. $item (array)
Individual list item from woocommerce_saved_payment_methods_list
1. $payment_token (WC_Payment_Token)
The payment token associated with this method entry

Usage

  1. if ( !function_exists( 'wc_get_account_saved_payment_methods_list_item_cc' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-account-functions.php'; 
  3.  
  4. // Individual list item from woocommerce_saved_payment_methods_list 
  5. $item = array(); 
  6.  
  7. // The payment token associated with this method entry 
  8. $payment_token = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_get_account_saved_payment_methods_list_item_cc($item, $payment_token); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-account-functions.php  
  1. function wc_get_account_saved_payment_methods_list_item_cc( $item, $payment_token ) { 
  2. if ( 'cc' !== strtolower( $payment_token->get_type() ) ) { 
  3. return $item; 
  4.  
  5. $card_type = $payment_token->get_card_type(); 
  6. $item['method']['last4'] = $payment_token->get_last4(); 
  7. $item['method']['brand'] = ( ! empty( $card_type ) ? ucfirst( $card_type ) : esc_html__( 'Credit card', woocommerce ) ); 
  8. $item['expires'] = $payment_token->get_expiry_month() . '/' . substr( $payment_token->get_expiry_year(), -2 ); 
  9.  
  10. return $item;