WC_Privacy_Exporters::customer_tokens_exporter( string $email_address, int $page )

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


Description Description


Parameters Parameters

$email_address

(Required) The user email address.

$page

(Required) Page.


Top ↑

Return Return

(array) An array of personal data in name value pairs


Top ↑

Source Source

File: includes/class-wc-privacy-exporters.php

	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,
		);
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.4.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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