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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 7 years ago admin 7 years ago api 7 years ago blocks 7 years ago cli 7 years ago customizer 7 years ago data-stores 7 years ago emails 7 years ago export 7 years ago gateways 7 years ago import 7 years ago interfaces 7 years ago legacy 7 years ago libraries 7 years ago log-handlers 7 years ago payment-tokens 7 years ago queue 7 years ago shipping 7 years ago shortcodes 7 years ago theme-support 7 years ago tracks 7 years ago walkers 7 years ago widgets 7 years ago class-wc-ajax.php 7 years ago class-wc-api.php 7 years ago class-wc-auth.php 7 years ago class-wc-autoloader.php 7 years ago class-wc-background-emailer.php 7 years ago class-wc-background-updater.php 7 years ago class-wc-breadcrumb.php 7 years ago class-wc-cache-helper.php 7 years ago class-wc-cart-fees.php 7 years ago class-wc-cart-session.php 7 years ago class-wc-cart-totals.php 7 years ago class-wc-cart.php 7 years ago class-wc-checkout.php 7 years ago class-wc-cli.php 7 years ago class-wc-comments.php 7 years ago class-wc-countries.php 7 years ago class-wc-coupon.php 7 years ago class-wc-customer-download-log.php 7 years ago class-wc-customer-download.php 7 years ago class-wc-customer.php 7 years ago class-wc-data-exception.php 7 years ago class-wc-data-store.php 7 years ago class-wc-datetime.php 7 years ago class-wc-deprecated-action-hooks.php 7 years ago class-wc-deprecated-filter-hooks.php 7 years ago class-wc-discounts.php 7 years ago class-wc-download-handler.php 7 years ago class-wc-emails.php 7 years ago class-wc-embed.php 7 years ago class-wc-form-handler.php 7 years ago class-wc-frontend-scripts.php 7 years ago class-wc-geo-ip.php 7 years ago class-wc-geolite-integration.php 7 years ago class-wc-geolocation.php 7 years ago class-wc-https.php 7 years ago class-wc-install.php 7 years ago class-wc-integrations.php 7 years ago class-wc-log-levels.php 7 years ago class-wc-logger.php 7 years ago class-wc-meta-data.php 7 years ago class-wc-order-factory.php 7 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 7 years ago class-wc-order-item-shipping.php 7 years ago class-wc-order-item-tax.php 7 years ago class-wc-order-item.php 7 years ago class-wc-order-query.php 7 years ago class-wc-order-refund.php 7 years ago class-wc-order.php 7 years ago class-wc-payment-gateways.php 7 years ago class-wc-payment-tokens.php 7 years ago class-wc-post-data.php 7 years ago class-wc-post-types.php 7 years ago class-wc-privacy-background-process.php 7 years ago class-wc-privacy-erasers.php 7 years ago class-wc-privacy-exporters.php 7 years ago class-wc-privacy.php 7 years ago class-wc-product-attribute.php 7 years ago class-wc-product-download.php 7 years ago class-wc-product-external.php 7 years ago class-wc-product-factory.php 7 years ago class-wc-product-grouped.php 7 years ago class-wc-product-query.php 7 years ago class-wc-product-simple.php 7 years ago class-wc-product-variable.php 7 years ago class-wc-product-variation.php 7 years ago class-wc-query.php 7 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 7 years ago class-wc-session-handler.php 7 years ago class-wc-shipping-rate.php 7 years ago class-wc-shipping-zone.php 7 years ago class-wc-shipping-zones.php 7 years ago class-wc-shipping.php 7 years ago class-wc-shortcodes.php 7 years ago class-wc-structured-data.php 7 years ago class-wc-tax.php 7 years ago class-wc-template-loader.php 7 years ago class-wc-tracker.php 7 years ago class-wc-validation.php 7 years ago class-wc-webhook.php 7 years ago class-woocommerce.php 7 years ago wc-account-functions.php 7 years ago wc-attribute-functions.php 7 years ago wc-cart-functions.php 7 years ago wc-conditional-functions.php 7 years ago wc-core-functions.php 7 years ago wc-coupon-functions.php 7 years ago wc-deprecated-functions.php 7 years ago wc-formatting-functions.php 7 years ago wc-notice-functions.php 7 years ago wc-order-functions.php 7 years ago wc-order-item-functions.php 7 years ago wc-page-functions.php 7 years ago wc-product-functions.php 7 years ago wc-rest-functions.php 7 years ago wc-stock-functions.php 7 years ago wc-template-functions.php 7 years ago wc-template-hooks.php 7 years ago wc-term-functions.php 7 years ago wc-update-functions.php 7 years ago wc-user-functions.php 7 years ago wc-webhook-functions.php 7 years ago wc-widget-functions.php 7 years ago
class-wc-privacy-exporters.php
425 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( 'woocommerce_privacy_export_customer_personal_data_props', array(
179 'billing_first_name' => __( 'Billing First Name', 'woocommerce' ),
180 'billing_last_name' => __( 'Billing Last Name', 'woocommerce' ),
181 'billing_company' => __( 'Billing Company', 'woocommerce' ),
182 'billing_address_1' => __( 'Billing Address 1', 'woocommerce' ),
183 'billing_address_2' => __( 'Billing Address 2', 'woocommerce' ),
184 'billing_city' => __( 'Billing City', 'woocommerce' ),
185 'billing_postcode' => __( 'Billing Postal/Zip Code', 'woocommerce' ),
186 'billing_state' => __( 'Billing State', 'woocommerce' ),
187 'billing_country' => __( 'Billing Country', 'woocommerce' ),
188 'billing_phone' => __( 'Phone Number', 'woocommerce' ),
189 'billing_email' => __( 'Email Address', 'woocommerce' ),
190 'shipping_first_name' => __( 'Shipping First Name', 'woocommerce' ),
191 'shipping_last_name' => __( 'Shipping Last Name', 'woocommerce' ),
192 'shipping_company' => __( 'Shipping Company', 'woocommerce' ),
193 'shipping_address_1' => __( 'Shipping Address 1', 'woocommerce' ),
194 'shipping_address_2' => __( 'Shipping Address 2', 'woocommerce' ),
195 'shipping_city' => __( 'Shipping City', 'woocommerce' ),
196 'shipping_postcode' => __( 'Shipping Postal/Zip Code', 'woocommerce' ),
197 'shipping_state' => __( 'Shipping State', 'woocommerce' ),
198 'shipping_country' => __( 'Shipping Country', 'woocommerce' ),
199 ), $customer );
200
201 foreach ( $props_to_export as $prop => $description ) {
202 $value = '';
203
204 if ( is_callable( array( $customer, 'get_' . $prop ) ) ) {
205 $value = $customer->{"get_$prop"}( 'edit' );
206 }
207
208 $value = apply_filters( 'woocommerce_privacy_export_customer_personal_data_prop_value', $value, $prop, $customer );
209
210 if ( $value ) {
211 $personal_data[] = array(
212 'name' => $description,
213 'value' => $value,
214 );
215 }
216 }
217
218 /**
219 * Allow extensions to register their own personal data for this customer for the export.
220 *
221 * @since 3.4.0
222 * @param array $personal_data Array of name value pairs.
223 * @param WC_Order $order A customer object.
224 */
225 $personal_data = apply_filters( 'woocommerce_privacy_export_customer_personal_data', $personal_data, $customer );
226
227 return $personal_data;
228 }
229
230 /**
231 * Get personal data (key/value pairs) for an order object.
232 *
233 * @since 3.4.0
234 * @param WC_Order $order Order object.
235 * @return array
236 */
237 protected static function get_order_personal_data( $order ) {
238 $personal_data = array();
239 $props_to_export = apply_filters( 'woocommerce_privacy_export_order_personal_data_props', array(
240 'order_number' => __( 'Order Number', 'woocommerce' ),
241 'date_created' => __( 'Order Date', 'woocommerce' ),
242 'total' => __( 'Order Total', 'woocommerce' ),
243 'items' => __( 'Items Purchased', 'woocommerce' ),
244 'customer_ip_address' => __( 'IP Address', 'woocommerce' ),
245 'customer_user_agent' => __( 'Browser User Agent', 'woocommerce' ),
246 'formatted_billing_address' => __( 'Billing Address', 'woocommerce' ),
247 'formatted_shipping_address' => __( 'Shipping Address', 'woocommerce' ),
248 'billing_phone' => __( 'Phone Number', 'woocommerce' ),
249 'billing_email' => __( 'Email Address', 'woocommerce' ),
250 ), $order );
251
252 foreach ( $props_to_export as $prop => $name ) {
253 $value = '';
254
255 switch ( $prop ) {
256 case 'items':
257 $item_names = array();
258 foreach ( $order->get_items() as $item ) {
259 $item_names[] = $item->get_name() . ' x ' . $item->get_quantity();
260 }
261 $value = implode( ', ', $item_names );
262 break;
263 case 'date_created':
264 $value = wc_format_datetime( $order->get_date_created(), get_option( 'date_format' ) . ', ' . get_option( 'time_format' ) );
265 break;
266 case 'formatted_billing_address':
267 case 'formatted_shipping_address':
268 $value = preg_replace( '#<br\s*/?>#i', ', ', $order->{"get_$prop"}() );
269 break;
270 default:
271 if ( is_callable( array( $order, 'get_' . $prop ) ) ) {
272 $value = $order->{"get_$prop"}();
273 }
274 break;
275 }
276
277 $value = apply_filters( 'woocommerce_privacy_export_order_personal_data_prop', $value, $prop, $order );
278
279 if ( $value ) {
280 $personal_data[] = array(
281 'name' => $name,
282 'value' => $value,
283 );
284 }
285 }
286
287 // Export meta data.
288 $meta_to_export = apply_filters( 'woocommerce_privacy_export_order_personal_data_meta', array(
289 'Payer first name' => __( 'Payer first name', 'woocommerce' ),
290 'Payer last name' => __( 'Payer last name', 'woocommerce' ),
291 'Payer PayPal address' => __( 'Payer PayPal address', 'woocommerce' ),
292 'Transaction ID' => __( 'Transaction ID', 'woocommerce' ),
293 ) );
294
295 if ( ! empty( $meta_to_export ) && is_array( $meta_to_export ) ) {
296 foreach ( $meta_to_export as $meta_key => $name ) {
297 $value = apply_filters( 'woocommerce_privacy_export_order_personal_data_meta_value', $order->get_meta( $meta_key ), $meta_key, $order );
298
299 if ( $value ) {
300 $personal_data[] = array(
301 'name' => $name,
302 'value' => $value,
303 );
304 }
305 }
306 }
307
308 /**
309 * Allow extensions to register their own personal data for this order for the export.
310 *
311 * @since 3.4.0
312 * @param array $personal_data Array of name value pairs to expose in the export.
313 * @param WC_Order $order An order object.
314 */
315 $personal_data = apply_filters( 'woocommerce_privacy_export_order_personal_data', $personal_data, $order );
316
317 return $personal_data;
318 }
319
320 /**
321 * Get personal data (key/value pairs) for a download object.
322 *
323 * @since 3.4.0
324 * @param WC_Order $download Download object.
325 * @return array
326 */
327 protected static function get_download_personal_data( $download ) {
328 $personal_data = array(
329 array(
330 'name' => __( 'Download ID', 'woocommerce' ),
331 'value' => $download->get_id(),
332 ),
333 array(
334 'name' => __( 'Order ID', 'woocommerce' ),
335 'value' => $download->get_order_id(),
336 ),
337 array(
338 'name' => __( 'Product', 'woocommerce' ),
339 'value' => get_the_title( $download->get_product_id() ),
340 ),
341 array(
342 'name' => __( 'User email', 'woocommerce' ),
343 'value' => $download->get_user_email(),
344 ),
345 array(
346 'name' => __( 'Downloads remaining', 'woocommerce' ),
347 'value' => $download->get_downloads_remaining(),
348 ),
349 array(
350 'name' => __( 'Download count', 'woocommerce' ),
351 'value' => $download->get_download_count(),
352 ),
353 array(
354 'name' => __( 'Access granted', 'woocommerce' ),
355 'value' => date( 'Y-m-d', $download->get_access_granted( 'edit' )->getTimestamp() ),
356 ),
357 array(
358 'name' => __( 'Access expires', 'woocommerce' ),
359 'value' => ! is_null( $download->get_access_expires( 'edit' ) ) ? date( 'Y-m-d', $download->get_access_expires( 'edit' )->getTimestamp() ) : null,
360 ),
361 );
362
363 /**
364 * Allow extensions to register their own personal data for this download for the export.
365 *
366 * @since 3.4.0
367 * @param array $personal_data Array of name value pairs to expose in the export.
368 * @param WC_Order $order An order object.
369 */
370 $personal_data = apply_filters( 'woocommerce_privacy_export_download_personal_data', $personal_data, $download );
371
372 return $personal_data;
373 }
374
375 /**
376 * Finds and exports payment tokens by email address for a customer.
377 *
378 * @since 3.4.0
379 * @param string $email_address The user email address.
380 * @param int $page Page.
381 * @return array An array of personal data in name value pairs
382 */
383 public static function customer_tokens_exporter( $email_address, $page ) {
384 $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
385 $data_to_export = array();
386
387 if ( ! $user instanceof WP_User ) {
388 return array(
389 'data' => $data_to_export,
390 'done' => true,
391 );
392 }
393
394 $tokens = WC_Payment_Tokens::get_tokens( array(
395 'user_id' => $user->ID,
396 'limit' => 10,
397 'page' => $page,
398 ) );
399
400 if ( 0 < count( $tokens ) ) {
401 foreach ( $tokens as $token ) {
402 $data_to_export[] = array(
403 'group_id' => 'woocommerce_tokens',
404 'group_label' => __( 'Payment Tokens', 'woocommerce' ),
405 'item_id' => 'token-' . $token->get_id(),
406 'data' => array(
407 array(
408 'name' => __( 'Token', 'woocommerce' ),
409 'value' => $token->get_display_name(),
410 ),
411 ),
412 );
413 }
414 $done = 10 > count( $tokens );
415 } else {
416 $done = true;
417 }
418
419 return array(
420 'data' => $data_to_export,
421 'done' => $done,
422 );
423 }
424 }
425