Basic personal info lookup and dump
This commit is contained in:
parent
765ed9ccf0
commit
f1107e94e2
|
@ -55,8 +55,78 @@ class WC_Privacy {
|
|||
* @return array Array of personal data.
|
||||
*/
|
||||
public static function get_personal_data( $email ) {
|
||||
// Do something.
|
||||
return array();
|
||||
if ( ! is_email( $email ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$personal_data = array();
|
||||
|
||||
// Check if user has an ID in the DB to load stored personal data.
|
||||
$user = get_user_by( 'email', $email );
|
||||
if ( $user instanceof WP_User ) {
|
||||
$customer = new WC_Customer( $user->ID );
|
||||
if ( $customer ) {
|
||||
$personal_data['Billing First Name'] = $customer->get_billing_first_name();
|
||||
$personal_data['Billing Last Name'] = $customer->get_billing_last_name();
|
||||
$personal_data['Billing Company'] = $customer->get_billing_company();
|
||||
$personal_data['Billing Address 1'] = $customer->get_billing_address_1();
|
||||
$personal_data['Billing Address 2'] = $customer->get_billing_address_2();
|
||||
$personal_data['Billing City'] = $customer->get_billing_city();
|
||||
$personal_data['Billing Postal/Zip Code'] = $customer->get_billing_postcode();
|
||||
$personal_data['Billing State'] = $customer->get_billing_state();
|
||||
$personal_data['Billing Country'] = $customer->get_billing_country();
|
||||
$personal_data['Billing Phone'] = $customer->get_billing_phone();
|
||||
$personal_data['Shipping First Name'] = $customer->get_shipping_first_name();
|
||||
$personal_data['Shipping Last Name'] = $customer->get_shipping_last_name();
|
||||
$personal_data['Shipping Company'] = $customer->get_shipping_company();
|
||||
$personal_data['Shipping Address 1'] = $customer->get_shipping_address_1();
|
||||
$personal_data['Shipping Address 2'] = $customer->get_shipping_address_2();
|
||||
$personal_data['Shipping City'] = $customer->get_shipping_city();
|
||||
$personal_data['Shipping Postal/Zip Code'] = $customer->get_shipping_postcode();
|
||||
$personal_data['Shipping State'] = $customer->get_shipping_state();
|
||||
$personal_data['Shipping Country'] = $customer->get_shipping_country();
|
||||
$personal_data['Shipping Phone'] = $customer->get_shipping_phone();
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve all orders with billing email set to user's email.
|
||||
$orders = wc_get_orders( array(
|
||||
'billing_email' => $email,
|
||||
'limit' => -1,
|
||||
) );
|
||||
|
||||
if ( 0 < count( $orders ) ) {
|
||||
$personal_data['orders'] = array();
|
||||
foreach ( $orders as $order ) {
|
||||
$order_data = array(
|
||||
'Transaction ID' => $order->get_order_number(),
|
||||
'IP Address' => $order->get_customer_ip_address(),
|
||||
'User Agent' => $order->get_customer_user_agent(),
|
||||
'Billing First Name' => $order->get_billing_first_name(),
|
||||
'Billing Last Name' => $order->get_billing_last_name(),
|
||||
'Billing Company' => $order->get_billing_company(),
|
||||
'Billing Address 1' => $order->get_billing_address_1(),
|
||||
'Billing Address 2' => $order->get_billing_address_2(),
|
||||
'Billing City' => $order->get_billing_city(),
|
||||
'Billing Postal/Zip Code' => $order->get_billing_postcode(),
|
||||
'Billing State' => $order->get_billing_state(),
|
||||
'Billing Country' => $order->get_billing_country(),
|
||||
'Billing Phone' => $order->get_billing_phone(),
|
||||
'Shipping First Name' => $order->get_shipping_first_name(),
|
||||
'Shipping Last Name' => $order->get_shipping_last_name(),
|
||||
'Shipping Company' => $order->get_shipping_company(),
|
||||
'Shipping Address 1' => $order->get_shipping_address_1(),
|
||||
'Shipping Address 2' => $order->get_shipping_address_2(),
|
||||
'Shipping City' => $order->get_shipping_city(),
|
||||
'Shipping Postal/Zip Code' => $order->get_shipping_postcode(),
|
||||
'Shipping State' => $order->get_shipping_state(),
|
||||
'Shipping Country' => $order->get_shipping_country(),
|
||||
'Shipping Phone' => $order->get_shipping_phone(),
|
||||
);
|
||||
$personal_data['orders'][] = $order_data;
|
||||
}
|
||||
}
|
||||
return $personal_data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue