ustomer->get_last_name(); if ( empty( $first_name ) ) { $first_name = $customer->get_billing_first_name(); } if ( empty( $last_name ) ) { $last_name = $customer->get_billing_last_name(); } $last_active = $customer->get_meta( 'wc_last_active', true, 'edit' ); $data = array( 'user_id' => $user_id, 'username' => $customer->get_username( 'edit' ), 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $customer->get_email( 'edit' ), 'city' => $customer->get_billing_city( 'edit' ), 'state' => $customer->get_billing_state( 'edit' ), 'postcode' => $customer->get_billing_postcode( 'edit' ), 'country' => $customer->get_billing_country( 'edit' ), 'date_registered' => $customer->get_date_created( 'edit' ) ? $customer->get_date_created( 'edit' )->date( TimeInterval::$sql_datetime_format ) : null, 'date_last_active' => $last_active ? gmdate( 'Y-m-d H:i:s', $last_active ) : null, ); $format = array( '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', ); $customer_id = self::get_customer_id_by_user_id( $user_id ); if ( $customer_id ) { // Preserve customer_id for existing user_id. $data['customer_id'] = $customer_id; $format[] = '%d'; } $results = $wpdb->replace( self::get_db_table_name(), $data, $format ); /** * Fires when customser's reports are updated. * * @param int $customer_id Customer ID. * @since 4.0.0 */ do_action( 'woocommerce_analytics_update_customer', $customer_id ); ReportsCache::invalidate(); return $results; } /** * Update the database if the "last active" meta value was changed. * Function expects to be hooked into the `added_user_meta` and `updated_user_meta` actions. * * @param int $meta_id ID of updated metadata entry. * @param int $user_id ID of the user being updated. * @param string $meta_key Meta key being updated. */ public static function update_registered_customer_via_last_active( $meta_id, $user_id, $meta_key ) { if ( 'wc_last_active' === $meta_key ) { self::update_registered_customer( $user_id ); } } /** * Check if a user ID is a valid customer or other user role with past orders. * * @param int $user_id User ID. * @return bool */ protected static function is_valid_customer( $user_id ) { $user = new \WP_User( $user_id ); if ( (int) $user_id !== $user->ID ) { return false; } /** * Filter the customer roles, used to check if the user is a customer. * * @param array List of customer roles. * @since 4.0.0 */ $customer_roles = (array) apply_filters( 'woocommerce_analytics_customer_roles', array( 'customer' ) ); if ( empty( $user->roles ) || empty( array_intersect( $user->roles, $customer_roles ) ) ) { return false; } return true; } /** * Delete a customer lookup row. * * @param int $customer_id Customer ID. */ public static function delete_customer( $customer_id ) { global $wpdb; $customer_id = (int) $customer_id; $num_deleted = $wpdb->delete( self::get_db_table_name(), array( 'customer_id' => $customer_id ) ); if ( $num_deleted ) { /** * Fires when a customer is deleted. * * @param int $order_id Order ID. * @since 4.0.0 */ do_action( 'woocommerce_analytics_delete_customer', $customer_id ); ReportsCache::invalidate(); } } /** * Delete a customer lookup row by WordPress User ID. * * @param int $user_id WordPress User ID. */ public static function delete_customer_by_user_id( $user_id ) { global $wpdb; if ( (int) $user_id < 1 || doing_action( 'wp_uninitialize_site' ) ) { // Skip the deletion. return; } $user_id = (int) $user_id; $num_deleted = $wpdb->delete( self::get_db_table_name(), array( 'user_id' => $user_id ) ); if ( $num_deleted ) { ReportsCache::invalidate(); } } /** * Anonymize the customer data for a single order. * * @internal * @param int|WC_Order $order Order instance or ID. * @return void */ public static function anonymize_customer( $order ) { global $wpdb; if ( ! is_object( $order ) ) { $order = wc_get_order( absint( $order ) ); } $customer_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$wpdb->prefix}wc_order_stats WHERE order_id = %d", $order->get_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, 'deleted@site.invalid', $deleted_text, $deleted_text, $deleted_text, $customer_id, ) ) ); // If the customer row was anonymized, flush the cache. if ( $updated ) { ReportsCache::invalidate(); } } /** * Initialize query objects. */ protected function initialize_queries() { $this->clear_all_clauses(); $table_name = self::get_db_table_name(); $this->subquery = new SqlQuery( $this->context . '_subquery' ); $this->subquery->add_sql_clause( 'from', $table_name ); $this->subquery->add_sql_clause( 'select', "{$table_name}.customer_id" ); $this->subquery->add_sql_clause( 'group_by', "{$table_name}.customer_id" ); } }
Fatal error: Uncaught Error: Class "Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore" not found in /home/site/wwwroot/wp-content/plugins/woocommerce/src/Internal/Admin/Schedulers/CustomersScheduler.php:30 Stack trace: #0 /home/site/wwwroot/wp-content/plugins/woocommerce/src/Admin/ReportsSync.php(24): Automattic\WooCommerce\Internal\Admin\Schedulers\CustomersScheduler::init() #1 /home/site/wwwroot/wp-content/plugins/woocommerce/src/Internal/Admin/FeaturePlugin.php(176): Automattic\WooCommerce\Admin\ReportsSync::init() #2 /home/site/wwwroot/wp-content/plugins/woocommerce/src/Internal/Admin/FeaturePlugin.php(109): Automattic\WooCommerce\Internal\Admin\FeaturePlugin->includes() #3 /home/site/wwwroot/wp-content/plugins/woocommerce/src/Internal/Admin/FeaturePlugin.php(92): Automattic\WooCommerce\Internal\Admin\FeaturePlugin->on_plugins_loaded() #4 /home/site/wwwroot/wp-content/plugins/woocommerce/src/Admin/Composer/Package.php(65): Automattic\WooCommerce\Internal\Admin\FeaturePlugin->init() #5 [internal function]: Automattic\WooCommerce\Admin\Composer\Package::init() #6 /home/site/wwwroot/wp-content/plugins/woocommerce/src/Packages.php(291): call_user_func(Array) #7 /home/site/wwwroot/wp-content/plugins/woocommerce/src/Packages.php(89): Automattic\WooCommerce\Packages::initialize_packages() #8 /home/site/wwwroot/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Packages::on_init('') #9 /home/site/wwwroot/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #10 /home/site/wwwroot/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #11 /home/site/wwwroot/wp-settings.php(578): do_action('plugins_loaded') #12 /home/site/wwwroot/wp-config.php(113): require_once('/home/site/wwwr...') #13 /home/site/wwwroot/wp-load.php(50): require_once('/home/site/wwwr...') #14 /home/site/wwwroot/wp-blog-header.php(13): require_once('/home/site/wwwr...') #15 /home/site/wwwroot/index.php(17): require('/home/site/wwwr...') #16 {main} thrown in /home/site/wwwroot/wp-content/plugins/woocommerce/src/Internal/Admin/Schedulers/CustomersScheduler.php on line 30

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the woocommerce domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/site/wwwroot/wp-includes/functions.php on line 6121