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.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / class-wc-privacy-exporters.php
woocommerce / includes Last commit date
abstracts 6 years ago admin 6 years ago cli 6 years ago customizer 6 years ago data-stores 6 years ago emails 6 years ago export 6 years ago gateways 6 years ago import 6 years ago integrations 6 years ago interfaces 6 years ago legacy 6 years ago libraries 6 years ago log-handlers 6 years ago payment-tokens 6 years ago queue 7 years ago shipping 6 years ago shortcodes 6 years ago theme-support 6 years ago tracks 6 years ago traits 6 years ago walkers 8 years ago wccom-site 6 years ago widgets 6 years ago class-wc-ajax.php 6 years ago class-wc-api.php 6 years ago class-wc-auth.php 7 years ago class-wc-autoloader.php 6 years ago class-wc-background-emailer.php 6 years ago class-wc-background-updater.php 7 years ago class-wc-breadcrumb.php 7 years ago class-wc-cache-helper.php 6 years ago class-wc-cart-fees.php 6 years ago class-wc-cart-session.php 6 years ago class-wc-cart-totals.php 6 years ago class-wc-cart.php 6 years ago class-wc-checkout.php 6 years ago class-wc-cli.php 8 years ago class-wc-comments.php 6 years ago class-wc-countries.php 6 years ago class-wc-coupon.php 6 years ago class-wc-customer-download-log.php 8 years ago class-wc-customer-download.php 6 years ago class-wc-customer.php 7 years ago class-wc-data-exception.php 8 years ago class-wc-data-store.php 6 years ago class-wc-datetime.php 7 years ago class-wc-deprecated-action-hooks.php 8 years ago class-wc-deprecated-filter-hooks.php 7 years ago class-wc-discounts.php 6 years ago class-wc-download-handler.php 6 years ago class-wc-emails.php 6 years ago class-wc-embed.php 8 years ago class-wc-form-handler.php 6 years ago class-wc-frontend-scripts.php 6 years ago class-wc-geo-ip.php 8 years ago class-wc-geolite-integration.php 6 years ago class-wc-geolocation.php 6 years ago class-wc-https.php 8 years ago class-wc-install.php 6 years ago class-wc-integrations.php 6 years ago class-wc-log-levels.php 7 years ago class-wc-logger.php 6 years ago class-wc-meta-data.php 7 years ago class-wc-order-factory.php 6 years ago class-wc-order-item-coupon.php 7 years ago class-wc-order-item-fee.php 7 years ago class-wc-order-item-meta.php 7 years ago class-wc-order-item-product.php 6 years ago class-wc-order-item-shipping.php 7 years ago class-wc-order-item-tax.php 6 years ago class-wc-order-item.php 6 years ago class-wc-order-query.php 7 years ago class-wc-order-refund.php 8 years ago class-wc-order.php 6 years ago class-wc-payment-gateways.php 6 years ago class-wc-payment-tokens.php 6 years ago class-wc-post-data.php 6 years ago class-wc-post-types.php 7 years ago class-wc-privacy-background-process.php 8 years ago class-wc-privacy-erasers.php 6 years ago class-wc-privacy-exporters.php 6 years ago class-wc-privacy.php 6 years ago class-wc-product-attribute.php 7 years ago class-wc-product-download.php 6 years ago class-wc-product-external.php 8 years ago class-wc-product-factory.php 7 years ago class-wc-product-grouped.php 8 years ago class-wc-product-query.php 7 years ago class-wc-product-simple.php 6 years ago class-wc-product-variable.php 6 years ago class-wc-product-variation.php 7 years ago class-wc-query.php 6 years ago class-wc-rate-limiter.php 6 years ago class-wc-regenerate-images-request.php 7 years ago class-wc-regenerate-images.php 7 years ago class-wc-register-wp-admin-settings.php 8 years ago class-wc-rest-authentication.php 6 years ago class-wc-rest-exception.php 6 years ago class-wc-session-handler.php 6 years ago class-wc-shipping-rate.php 8 years ago class-wc-shipping-zone.php 6 years ago class-wc-shipping-zones.php 6 years ago class-wc-shipping.php 6 years ago class-wc-shortcodes.php 6 years ago class-wc-structured-data.php 6 years ago class-wc-tax.php 6 years ago class-wc-template-loader.php 6 years ago class-wc-tracker.php 6 years ago class-wc-validation.php 6 years ago class-wc-webhook.php 6 years ago class-woocommerce.php 6 years ago wc-account-functions.php 6 years ago wc-attribute-functions.php 6 years ago wc-cart-functions.php 6 years ago wc-conditional-functions.php 6 years ago wc-core-functions.php 6 years ago wc-coupon-functions.php 7 years ago wc-deprecated-functions.php 6 years ago wc-formatting-functions.php 6 years ago wc-notice-functions.php 6 years ago wc-order-functions.php 6 years ago wc-order-item-functions.php 6 years ago wc-page-functions.php 6 years ago wc-product-functions.php 6 years ago wc-rest-functions.php 6 years ago wc-stock-functions.php 6 years ago wc-template-functions.php 6 years ago wc-template-hooks.php 6 years ago wc-term-functions.php 6 years ago wc-update-functions.php 6 years ago wc-user-functions.php 6 years ago wc-webhook-functions.php 7 years ago wc-widget-functions.php 8 years ago
class-wc-privacy-exporters.php
438 lines
1 <?php
2 /**
3 * Personal data exporters.
4 *
5 * @since 3.4.0
6 * @package WooCommerce\Classes
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * WC_Privacy_Exporters Class.
13 */
14 class WC_Privacy_Exporters {
15 /**
16 * Finds and exports customer data by email address.
17 *
18 * @since 3.4.0
19 * @param string $email_address The user email address.
20 * @return array An array of personal data in name value pairs
21 */
22 public static function customer_data_exporter( $email_address ) {
23 $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
24 $data_to_export = array();
25
26 if ( $user instanceof WP_User ) {
27 $customer_personal_data = self::get_customer_personal_data( $user );
28 if ( ! empty( $customer_personal_data ) ) {
29 $data_to_export[] = array(
30 'group_id' => 'woocommerce_customer',
31 'group_label' => __( 'Customer Data', 'woocommerce' ),
32 'item_id' => 'user',
33 'data' => $customer_personal_data,
34 );
35 }
36 }
37
38 return array(
39 'data' => $data_to_export,
40 'done' => true,
41 );
42 }
43
44 /**
45 * Finds and exports data which could be used to identify a person from WooCommerce data associated with an email address.
46 *
47 * Orders are exported in blocks of 10 to avoid timeouts.
48 *
49 * @since 3.4.0
50 * @param string $email_address The user email address.
51 * @param int $page Page.
52 * @return array An array of personal data in name value pairs
53 */
54 public static function order_data_exporter( $email_address, $page ) {
55 $done = true;
56 $page = (int) $page;
57 $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
58 $data_to_export = array();
59 $order_query = array(
60 'limit' => 10,
61 'page' => $page,
62 'customer' => array( $email_address ),
63 );
64
65 if ( $user instanceof WP_User ) {
66 $order_query['customer'][] = (int) $user->ID;
67 }
68
69 $orders = wc_get_orders( $order_query );
70
71 if ( 0 < count( $orders ) ) {
72 foreach ( $orders as $order ) {
73 $data_to_export[] = array(
74 'group_id' => 'woocommerce_orders',
75 'group_label' => __( 'Orders', 'woocommerce' ),
76 'item_id' => 'order-' . $order->get_id(),
77 'data' => self::get_order_personal_data( $order ),
78 );
79 }
80 $done = 10 > count( $orders );
81 }
82
83 return array(
84 'data' => $data_to_export,
85 'done' => $done,
86 );
87 }
88
89 /**
90 * Finds and exports customer download logs by email address.
91 *
92 * @since 3.4.0
93 * @param string $email_address The user email address.
94 * @param int $page Page.
95 * @throws Exception When WC_Data_Store validation fails.
96 * @return array An array of personal data in name value pairs
97 */
98 public static function download_data_exporter( $email_address, $page ) {
99 $done = true;
100 $page = (int) $page;
101 $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
102 $data_to_export = array();
103 $downloads_query = array(
104 'limit' => 10,
105 'page' => $page,
106 );
107
108 if ( $user instanceof WP_User ) {
109 $downloads_query['user_id'] = (int) $user->ID;
110 } else {
111 $downloads_query['user_email'] = $email_address;
112 }
113
114 $customer_download_data_store = WC_Data_Store::load( 'customer-download' );
115 $customer_download_log_data_store = WC_Data_Store::load( 'customer-download-log' );
116 $downloads = $customer_download_data_store->get_downloads( $downloads_query );
117
118 if ( 0 < count( $downloads ) ) {
119 foreach ( $downloads as $download ) {
120 $data_to_export[] = array(
121 'group_id' => 'woocommerce_downloads',
122 /* translators: This is the headline for a list of downloads purchased from the store for a given user. */
123 'group_label' => __( 'Purchased Downloads', 'woocommerce' ),
124 'item_id' => 'download-' . $download->get_id(),
125 'data' => self::get_download_personal_data( $download ),
126 );
127
128 $download_logs = $customer_download_log_data_store->get_download_logs_for_permission( $download->get_id() );
129
130 foreach ( $download_logs as $download_log ) {
131 $data_to_export[] = array(
132 'group_id' => 'woocommerce_download_logs',
133 /* translators: This is the headline for a list of access logs for downloads purchased from the store for a given user. */
134 'group_label' => __( 'Access to Purchased Downloads', 'woocommerce' ),
135 'item_id' => 'download-log-' . $download_log->get_id(),
136 'data' => array(
137 array(
138 'name' => __( 'Download ID', 'woocommerce' ),
139 'value' => $download_log->get_permission_id(),
140 ),
141 array(
142 'name' => __( 'Timestamp', 'woocommerce' ),
143 'value' => $download_log->get_timestamp(),
144 ),
145 array(
146 'name' => __( 'IP Address', 'woocommerce' ),
147 'value' => $download_log->get_user_ip_address(),
148 ),
149 ),
150 );
151 }
152 }
153 $done = 10 > count( $downloads );
154 }
155
156 return array(
157 'data' => $data_to_export,
158 'done' => $done,
159 );
160 }
161
162 /**
163 * Get personal data (key/value pairs) for a user object.
164 *
165 * @since 3.4.0
166 * @param WP_User $user user object.
167 * @throws Exception If customer cannot be read/found and $data is set to WC_Customer class.
168 * @return array
169 */
170 protected static function get_customer_personal_data( $user ) {
171 $personal_data = array();
172 $customer = new WC_Customer( $user->ID );
173
174 if ( ! $customer ) {
175 return array();
176 }
177
178 $props_to_export = apply_filters(
179 'woocommerce_privacy_export_customer_personal_data_props',
180 array(
181 'billing_first_name' => __( 'Billing First Name', 'woocommerce' ),
182 'billing_last_name' => __( 'Billing Last Name', 'woocommerce' ),
183 'billing_company' => __( 'Billing Company', 'woocommerce' ),
184 'billing_address_1' => __( 'Billing Address 1', 'woocommerce' ),
185 'billing_address_2' => __( 'Billing Address 2', 'woocommerce' ),
186 'billing_city' => __( 'Billing City', 'woocommerce' ),
187 'billing_postcode' => __( 'Billing Postal/Zip Code', 'woocommerce' ),
188 'billing_state' => __( 'Billing State', 'woocommerce' ),
189 'billing_country' => __( 'Billing Country / Region', 'woocommerce' ),
190 'billing_phone' => __( 'Phone Number', 'woocommerce' ),
191 'billing_email' => __( 'Email Address', 'woocommerce' ),
192 'shipping_first_name' => __( 'Shipping First Name', 'woocommerce' ),
193 'shipping_last_name' => __( 'Shipping Last Name', 'woocommerce' ),
194 'shipping_company' => __( 'Shipping Company', 'woocommerce' ),
195 'shipping_address_1' => __( 'Shipping Address 1', 'woocommerce' ),
196 'shipping_address_2' => __( 'Shipping Address 2', 'woocommerce' ),
197 'shipping_city' => __( 'Shipping City', 'woocommerce' ),
198 'shipping_postcode' => __( 'Shipping Postal/Zip Code', 'woocommerce' ),
199 'shipping_state' => __( 'Shipping State', 'woocommerce' ),
200 'shipping_country' => __( 'Shipping Country / Region', 'woocommerce' ),
201 ),
202 $customer
203 );
204
205 foreach ( $props_to_export as $prop => $description ) {
206 $value = '';
207
208 if ( is_callable( array( $customer, 'get_' . $prop ) ) ) {
209 $value = $customer->{"get_$prop"}( 'edit' );
210 }
211
212 $value = apply_filters( 'woocommerce_privacy_export_customer_personal_data_prop_value', $value, $prop, $customer );
213
214 if ( $value ) {
215 $personal_data[] = array(
216 'name' => $description,
217 'value' => $value,
218 );
219 }
220 }
221
222 /**
223 * Allow extensions to register their own personal data for this customer for the export.
224 *
225 * @since 3.4.0
226 * @param array $personal_data Array of name value pairs.
227 * @param WC_Order $order A customer object.
228 */
229 $personal_data = apply_filters( 'woocommerce_privacy_export_customer_personal_data', $personal_data, $customer );
230
231 return $personal_data;
232 }
233
234 /**
235 * Get personal data (key/value pairs) for an order object.
236 *
237 * @since 3.4.0
238 * @param WC_Order $order Order object.
239 * @return array
240 */
241 protected static function get_order_personal_data( $order ) {
242 $personal_data = array();
243 $props_to_export = apply_filters(
244 'woocommerce_privacy_export_order_personal_data_props',
245 array(
246 'order_number' => __( 'Order Number', 'woocommerce' ),
247 'date_created' => __( 'Order Date', 'woocommerce' ),
248 'total' => __( 'Order Total', 'woocommerce' ),
249 'items' => __( 'Items Purchased', 'woocommerce' ),
250 'customer_ip_address' => __( 'IP Address', 'woocommerce' ),
251 'customer_user_agent' => __( 'Browser User Agent', 'woocommerce' ),
252 'formatted_billing_address' => __( 'Billing Address', 'woocommerce' ),
253 'formatted_shipping_address' => __( 'Shipping Address', 'woocommerce' ),
254 'billing_phone' => __( 'Phone Number', 'woocommerce' ),
255 'billing_email' => __( 'Email Address', 'woocommerce' ),
256 ),
257 $order
258 );
259
260 foreach ( $props_to_export as $prop => $name ) {
261 $value = '';
262
263 switch ( $prop ) {
264 case 'items':
265 $item_names = array();
266 foreach ( $order->get_items() as $item ) {
267 $item_names[] = $item->get_name() . ' x ' . $item->get_quantity();
268 }
269 $value = implode( ', ', $item_names );
270 break;
271 case 'date_created':
272 $value = wc_format_datetime( $order->get_date_created(), get_option( 'date_format' ) . ', ' . get_option( 'time_format' ) );
273 break;
274 case 'formatted_billing_address':
275 case 'formatted_shipping_address':
276 $value = preg_replace( '#<br\s*/?>#i', ', ', $order->{"get_$prop"}() );
277 break;
278 default:
279 if ( is_callable( array( $order, 'get_' . $prop ) ) ) {
280 $value = $order->{"get_$prop"}();
281 }
282 break;
283 }
284
285 $value = apply_filters( 'woocommerce_privacy_export_order_personal_data_prop', $value, $prop, $order );
286
287 if ( $value ) {
288 $personal_data[] = array(
289 'name' => $name,
290 'value' => $value,
291 );
292 }
293 }
294
295 // Export meta data.
296 $meta_to_export = apply_filters(
297 'woocommerce_privacy_export_order_personal_data_meta',
298 array(
299 'Payer first name' => __( 'Payer first name', 'woocommerce' ),
300 'Payer last name' => __( 'Payer last name', 'woocommerce' ),
301 'Payer PayPal address' => __( 'Payer PayPal address', 'woocommerce' ),
302 'Transaction ID' => __( 'Transaction ID', 'woocommerce' ),
303 )
304 );
305
306 if ( ! empty( $meta_to_export ) && is_array( $meta_to_export ) ) {
307 foreach ( $meta_to_export as $meta_key => $name ) {
308 $value = apply_filters( 'woocommerce_privacy_export_order_personal_data_meta_value', $order->get_meta( $meta_key ), $meta_key, $order );
309
310 if ( $value ) {
311 $personal_data[] = array(
312 'name' => $name,
313 'value' => $value,
314 );
315 }
316 }
317 }
318
319 /**
320 * Allow extensions to register their own personal data for this order for the export.
321 *
322 * @since 3.4.0
323 * @param array $personal_data Array of name value pairs to expose in the export.
324 * @param WC_Order $order An order object.
325 */
326 $personal_data = apply_filters( 'woocommerce_privacy_export_order_personal_data', $personal_data, $order );
327
328 return $personal_data;
329 }
330
331 /**
332 * Get personal data (key/value pairs) for a download object.
333 *
334 * @since 3.4.0
335 * @param WC_Order $download Download object.
336 * @return array
337 */
338 protected static function get_download_personal_data( $download ) {
339 $personal_data = array(
340 array(
341 'name' => __( 'Download ID', 'woocommerce' ),
342 'value' => $download->get_id(),
343 ),
344 array(
345 'name' => __( 'Order ID', 'woocommerce' ),
346 'value' => $download->get_order_id(),
347 ),
348 array(
349 'name' => __( 'Product', 'woocommerce' ),
350 'value' => get_the_title( $download->get_product_id() ),
351 ),
352 array(
353 'name' => __( 'User email', 'woocommerce' ),
354 'value' => $download->get_user_email(),
355 ),
356 array(
357 'name' => __( 'Downloads remaining', 'woocommerce' ),
358 'value' => $download->get_downloads_remaining(),
359 ),
360 array(
361 'name' => __( 'Download count', 'woocommerce' ),
362 'value' => $download->get_download_count(),
363 ),
364 array(
365 'name' => __( 'Access granted', 'woocommerce' ),
366 'value' => date( 'Y-m-d', $download->get_access_granted( 'edit' )->getTimestamp() ),
367 ),
368 array(
369 'name' => __( 'Access expires', 'woocommerce' ),
370 'value' => ! is_null( $download->get_access_expires( 'edit' ) ) ? date( 'Y-m-d', $download->get_access_expires( 'edit' )->getTimestamp() ) : null,
371 ),
372 );
373
374 /**
375 * Allow extensions to register their own personal data for this download for the export.
376 *
377 * @since 3.4.0
378 * @param array $personal_data Array of name value pairs to expose in the export.
379 * @param WC_Order $order An order object.
380 */
381 $personal_data = apply_filters( 'woocommerce_privacy_export_download_personal_data', $personal_data, $download );
382
383 return $personal_data;
384 }
385
386 /**
387 * Finds and exports payment tokens by email address for a customer.
388 *
389 * @since 3.4.0
390 * @param string $email_address The user email address.
391 * @param int $page Page.
392 * @return array An array of personal data in name value pairs
393 */
394 public static function customer_tokens_exporter( $email_address, $page ) {
395 $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
396 $data_to_export = array();
397
398 if ( ! $user instanceof WP_User ) {
399 return array(
400 'data' => $data_to_export,
401 'done' => true,
402 );
403 }
404
405 $tokens = WC_Payment_Tokens::get_tokens(
406 array(
407 'user_id' => $user->ID,
408 'limit' => 10,
409 'page' => $page,
410 )
411 );
412
413 if ( 0 < count( $tokens ) ) {
414 foreach ( $tokens as $token ) {
415 $data_to_export[] = array(
416 'group_id' => 'woocommerce_tokens',
417 'group_label' => __( 'Payment Tokens', 'woocommerce' ),
418 'item_id' => 'token-' . $token->get_id(),
419 'data' => array(
420 array(
421 'name' => __( 'Token', 'woocommerce' ),
422 'value' => $token->get_display_name(),
423 ),
424 ),
425 );
426 }
427 $done = 10 > count( $tokens );
428 } else {
429 $done = true;
430 }
431
432 return array(
433 'data' => $data_to_export,
434 'done' => $done,
435 );
436 }
437 }
438