diff --git a/includes/class-wc-customer.php b/includes/class-wc-customer.php index 28bf919ed1d..6b2df5d8f02 100644 --- a/includes/class-wc-customer.php +++ b/includes/class-wc-customer.php @@ -100,7 +100,12 @@ class WC_Customer extends WC_Legacy_Customer { // If we have an ID, load the user from the DB. if ( $this->get_id() ) { - $this->data_store->read( $this ); + try { + $this->data_store->read( $this ); + } catch ( Exception $e ) { + $this->set_id( 0 ); + $this->set_object_read( true ); + } } else { $this->set_object_read( true ); } diff --git a/includes/data-stores/class-wc-customer-data-store.php b/includes/data-stores/class-wc-customer-data-store.php index 8471f22b7fa..09e50fea532 100644 --- a/includes/data-stores/class-wc-customer-data-store.php +++ b/includes/data-stores/class-wc-customer-data-store.php @@ -114,6 +114,7 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat * * @since 2.7.0 * @param WC_Customer + * @throws Exception */ public function read( &$customer ) { global $wpdb;