Check if there is a customer ID set before calling get_user_by()
This commit is contained in:
parent
818819d0ff
commit
37ca7faf2e
|
@ -140,10 +140,10 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat
|
|||
* @throws Exception If invalid customer.
|
||||
*/
|
||||
public function read( &$customer ) {
|
||||
$user_object = get_user_by( 'id', $customer->get_id() );
|
||||
$user_object = $customer->get_id() ? get_user_by( 'id', $customer->get_id() ) : false;
|
||||
|
||||
// User object is required.
|
||||
if ( ! $customer->get_id() || ! $user_object || empty( $user_object->ID ) ) {
|
||||
if ( ! $user_object || empty( $user_object->ID ) ) {
|
||||
throw new Exception( __( 'Invalid customer.', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue