WordPress at Your Fingertips
function is not described

WC_Privacy_Exporters::customer_tokens_exporter() public WC 3.4.0

Finds and exports payment tokens by email address for a customer.

{} It's a method of the class: WC_Privacy_Exporters{}

No Hooks.

Return

Array. An array of personal data in name value pairs

Usage

$result = WC_Privacy_Exporters::customer_tokens_exporter( $email_address, $page );
$email_address(string) (required)
The user email address.
$page(int) (required)
Page.

Changelog

Since 3.4.0 Introduced.

Code of WC_Privacy_Exporters::customer_tokens_exporter() WC 5.7.1

public static function customer_tokens_exporter( $email_address, $page ) {
	$user           = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
	$data_to_export = array();

	if ( ! $user instanceof WP_User ) {
		return array(
			'data' => $data_to_export,
			'done' => true,
		);
	}

	$tokens = WC_Payment_Tokens::get_tokens(
		array(
			'user_id' => $user->ID,
			'limit'   => 10,
			'page'    => $page,
		)
	);

	if ( 0 < count( $tokens ) ) {
		foreach ( $tokens as $token ) {
			$data_to_export[] = array(
				'group_id'          => 'woocommerce_tokens',
				'group_label'       => __( 'Payment Tokens', 'woocommerce' ),
				'group_description' => __( 'User&#8217;s WooCommerce payment tokens data.', 'woocommerce' ),
				'item_id'           => 'token-' . $token->get_id(),
				'data'              => array(
					array(
						'name'  => __( 'Token', 'woocommerce' ),
						'value' => $token->get_display_name(),
					),
				),
			);
		}
		$done = 10 > count( $tokens );
	} else {
		$done = true;
	}

	return array(
		'data' => $data_to_export,
		'done' => $done,
	);
}