| @@ -790,9 +790,10 @@ | ||
| 790 | 790 | { |
| 791 | 791 | if (is_user_logged_in()) { |
| 792 | 792 | $wpUser = wp_get_current_user(); |
| 793 | 793 | $cart->user_id = get_current_user_id(); |
| 794 | - $customer = Customer::query()->where('email', wp_get_current_user()->user_email)->first(); | |
| 794 | + // The cart belongs to the account's linked customer, not to whichever record holds its email. | |
| 795 | + $customer = Customer::query()->where('user_id', $wpUser->ID)->orderBy('id', 'ASC')->first(); | |
| 795 | 796 | if ($customer) { |
| 796 | 797 | $cart->customer_id = $customer->id; |
| 797 | 798 | } |
| 798 | 799 | $cart->email = $wpUser->user_email; |