WC_Privacy_Exporters::get_customer_personal_data( WP_User $user )
Get personal data (key/value pairs) for a user object.
Description Description
Parameters Parameters
- $user
-
(Required) user object.
Return Return
(array)
Source Source
File: includes/class-wc-privacy-exporters.php
protected static function get_customer_personal_data( $user ) {
$personal_data = array();
$customer = new WC_Customer( $user->ID );
if ( ! $customer ) {
return array();
}
$props_to_export = apply_filters(
'woocommerce_privacy_export_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 / Region', '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 / Region', 'woocommerce' ),
),
$customer
);
foreach ( $props_to_export as $prop => $description ) {
$value = '';
if ( is_callable( array( $customer, 'get_' . $prop ) ) ) {
$value = $customer->{"get_$prop"}( 'edit' );
}
$value = apply_filters( 'woocommerce_privacy_export_customer_personal_data_prop_value', $value, $prop, $customer );
if ( $value ) {
$personal_data[] = array(
'name' => $description,
'value' => $value,
);
}
}
/**
* Allow extensions to register their own personal data for this customer for the export.
*
* @since 3.4.0
* @param array $personal_data Array of name value pairs.
* @param WC_Order $order A customer object.
*/
$personal_data = apply_filters( 'woocommerce_privacy_export_customer_personal_data', $personal_data, $customer );
return $personal_data;
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.4.0 | Introduced. |