Dev Resources

  • Home
  • Reference
  • BuddyX Theme
  • Functions
  • Hooks
  • Classes
Filter by type:
Search
Browse: Home / Reference / Functions / wc_get_account_saved_payment_methods_list_item_cc()

wc_get_account_saved_payment_methods_list_item_cc( array $item, WC_Payment_Token $payment_token )

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

Contents

  • Description
    • Parameters
    • Return
    • Source
    • Changelog
  • User Contributed Notes

Description #Description


Parameters #Parameters

$item

(Required) Individual list item from woocommerce_saved_payment_methods_list.

$payment_token

(Required) The payment token associated with this method entry.


Top ↑

Return #Return

(array) Filtered item.


Top ↑

Source #Source

File: includes/wc-account-functions.php

function wc_get_account_saved_payment_methods_list_item_cc( $item, $payment_token ) {
	if ( 'cc' !== strtolower( $payment_token->get_type() ) ) {
		return $item;
	}

	$card_type               = $payment_token->get_card_type();
	$item['method']['last4'] = $payment_token->get_last4();
	$item['method']['brand'] = ( ! empty( $card_type ) ? ucfirst( $card_type ) : esc_html__( 'Credit card', 'woocommerce' ) );
	$item['expires']         = $payment_token->get_expiry_month() . '/' . substr( $payment_token->get_expiry_year(), -2 );

	return $item;
}

Expand full source code Collapse full source code


Top ↑

Changelog #Changelog

Changelog
Version Description
2.6 Introduced.

Top ↑

User Contributed Notes #User Contributed Notes

You must log in before being able to contribute a note or feedback.

Proudly powered by WordPress