Automattic\WooCommerce\Internal\ShopperLists\Privacy

Privacy::export_datapublicWC 1.0

Export every stored shopper list for the user matching the given email.

Method of the class: Privacy{}

No Hooks.

Returns

array{data: array<int, array<string, mixed>>, done: bool}.

Usage

$Privacy = new Privacy();
$Privacy->export_data( $email_address ): array;
$email_address(string) (required)
Email address the request applies to.

Privacy::export_data() code WC 11.1.1

public function export_data( string $email_address ): array {
	$user = get_user_by( 'email', $email_address );
	if ( ! $user instanceof \WP_User ) {
		return array(
			'data' => array(),
			'done' => true,
		);
	}

	$user_id    = (int) $user->ID;
	$controller = wc_get_container()->get( ShopperListsController::class );
	$data       = array();

	foreach ( $controller->get_supported_slugs() as $slug ) {
		$list = ShopperList::get_by_slug_raw( $slug, $user_id );
		if ( ! $list || ! $list->get_items() ) {
			continue;
		}

		$group_id    = self::GROUP_ID_PREFIX . $slug;
		$group_label = sprintf(
			/* translators: %s: shopper-list slug. */
			__( 'Shopper List: %s', 'woocommerce' ),
			$slug
		);
		foreach ( $list->get_items() as $item ) {
			$data[] = array(
				'group_id'    => $group_id,
				'group_label' => $group_label,
				'item_id'     => $item->get_key(),
				'data'        => self::item_export_rows( $item ),
			);
		}
	}

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