WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Privacy_Erasers::customer_data_eraser() WC 3.4.0

Finds and erases customer data by email address.

Это метод класса: WC_Privacy_Erasers

Возвращает

Массив. An array of personal data in name value pairs

Использование

$var = WC_Privacy_Erasers::customer_data_eraser( $email_address, $page );
$email_address(строка) (обязательный)
The user email address.
$page(число) (обязательный)
Page.

Список изменений

С версии 3.4.0 Введена.

Код WC Privacy Erasers::customer data eraser: woocommerce/includes/class-wc-privacy-erasers.php WC 3.7.0

<?php
public static function customer_data_eraser( $email_address, $page ) {
	$response = array(
		'items_removed'  => false,
		'items_retained' => false,
		'messages'       => array(),
		'done'           => true,
	);

	$user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.

	if ( ! $user instanceof WP_User ) {
		return $response;
	}

	$customer = new WC_Customer( $user->ID );

	if ( ! $customer ) {
		return $response;
	}

	$props_to_erase = apply_filters( 'woocommerce_privacy_erase_customer_personal_data_props', array(
		'billing_first_name'  => __( 'Billing First Name', 'woocommerce' ),
		'billing_last_name'   => __( 'Billing Last Name', 'woocommerce' ),
		'billing_company'     => __( 'Billing Company', 'woocommerce' ),
		'billing_address_1'   => __( 'Billing Address 1', 'woocommerce' ),
		'billing_address_2'   => __( 'Billing Address 2', 'woocommerce' ),
		'billing_city'        => __( 'Billing City', 'woocommerce' ),
		'billing_postcode'    => __( 'Billing Postal/Zip Code', 'woocommerce' ),
		'billing_state'       => __( 'Billing State', 'woocommerce' ),
		'billing_country'     => __( 'Billing Country', 'woocommerce' ),
		'billing_phone'       => __( 'Phone Number', 'woocommerce' ),
		'billing_email'       => __( 'Email Address', 'woocommerce' ),
		'shipping_first_name' => __( 'Shipping First Name', 'woocommerce' ),
		'shipping_last_name'  => __( 'Shipping Last Name', 'woocommerce' ),
		'shipping_company'    => __( 'Shipping Company', 'woocommerce' ),
		'shipping_address_1'  => __( 'Shipping Address 1', 'woocommerce' ),
		'shipping_address_2'  => __( 'Shipping Address 2', 'woocommerce' ),
		'shipping_city'       => __( 'Shipping City', 'woocommerce' ),
		'shipping_postcode'   => __( 'Shipping Postal/Zip Code', 'woocommerce' ),
		'shipping_state'      => __( 'Shipping State', 'woocommerce' ),
		'shipping_country'    => __( 'Shipping Country', 'woocommerce' ),
	), $customer );

	foreach ( $props_to_erase as $prop => $label ) {
		$erased = false;

		if ( is_callable( array( $customer, 'get_' . $prop ) ) && is_callable( array( $customer, 'set_' . $prop ) ) ) {
			$value = $customer->{"get_$prop"}( 'edit' );

			if ( $value ) {
				$customer->{"set_$prop"}( '' );
				$erased = true;
			}
		}

		$erased = apply_filters( 'woocommerce_privacy_erase_customer_personal_data_prop', $erased, $prop, $customer );

		if ( $erased ) {
			/* Translators: %s Prop name. */
			$response['messages'][]    = sprintf( __( 'Removed customer "%s"', 'woocommerce' ), $label );
			$response['items_removed'] = true;
		}
	}

	$customer->save();

	/**
	 * Allow extensions to remove data for this customer and adjust the response.
	 *
	 * @since 3.4.0
	 * @param array    $response Array resonse data. Must include messages, num_items_removed, num_items_retained, done.
	 * @param WC_Order $order A customer object.
	 */
	return apply_filters( 'woocommerce_privacy_erase_personal_data_customer', $response, $customer );
}