WordPress at Your Fingertips
function is not described

WC_Privacy_Exporters::order_data_exporter() public WC 3.4.0

Finds and exports data which could be used to identify a person from WooCommerce data associated with an email address.

Orders are exported in blocks of 10 to avoid timeouts.

{} 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::order_data_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::order_data_exporter() WC 5.8.0

public static function order_data_exporter( $email_address, $page ) {
	$done           = true;
	$page           = (int) $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();
	$order_query    = array(
		'limit'    => 10,
		'page'     => $page,
		'customer' => array( $email_address ),
	);

	if ( $user instanceof WP_User ) {
		$order_query['customer'][] = (int) $user->ID;
	}

	$orders = wc_get_orders( $order_query );

	if ( 0 < count( $orders ) ) {
		foreach ( $orders as $order ) {
			$data_to_export[] = array(
				'group_id'          => 'woocommerce_orders',
				'group_label'       => __( 'Orders', 'woocommerce' ),
				'group_description' => __( 'User&#8217;s WooCommerce orders data.', 'woocommerce' ),
				'item_id'           => 'order-' . $order->get_id(),
				'data'              => self::get_order_personal_data( $order ),
			);
		}
		$done = 10 > count( $orders );
	}

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