Automattic\WooCommerce\Admin\API\Reports\Customers
DataStore::anonymize_customer()
Anonymize the customer data for a single order.
Method of the class: DataStore{}
No Hooks.
Return
null
. Nothing (null).
Usage
$result = DataStore::anonymize_customer( $order_id );
- $order_id(int) (required)
- Order id.
DataStore::anonymize_customer() DataStore::anonymize customer code WC 9.3.3
public static function anonymize_customer( $order_id ) { global $wpdb; $customer_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$wpdb->prefix}wc_order_stats WHERE order_id = %d", $order_id ) ); if ( ! $customer_id ) { return; } // Long form query because $wpdb->update rejects [deleted]. $deleted_text = __( '[deleted]', 'woocommerce' ); $updated = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}wc_customer_lookup SET user_id = NULL, username = %s, first_name = %s, last_name = %s, email = %s, country = '', postcode = %s, city = %s, state = %s WHERE customer_id = %d", array( $deleted_text, $deleted_text, $deleted_text, '[email protected]', $deleted_text, $deleted_text, $deleted_text, $customer_id, ) ) ); // If the customer row was anonymized, flush the cache. if ( $updated ) { ReportsCache::invalidate(); } }