Skip to content

Commit d063056

Browse files
Fix Stripe customer creation with no email (#4599)
* Fallback to billing email when user email is empty * Add changelog entries * Initialize $email variable closer to where it's used * Fix changelog entry position --------- Co-authored-by: daledupreez <[email protected]>
1 parent 96946ae commit d063056

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Tweak - Small improvements to e2e tests
1212
* Fix - Fix unnecessary Stripe API calls when rendering subscription details
1313
* Add - Adds a new action (`wc_stripe_webhook_received`) to allow additional actions to be taken for webhook notifications from Stripe
14+
* Fix - Allow checkout for logged-in users without an email in their account when a billing email is provided
1415

1516
= 9.8.1 - 2025-08-15 =
1617
* Fix - Remove connection type requirement from PMC sync migration attempt

includes/class-wc-stripe-customer.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,18 @@ protected function generate_customer_request( $args = [] ) {
169169
$billing_last_name = get_user_meta( $user->ID, 'last_name', true );
170170
}
171171

172+
$email = $user->user_email;
173+
174+
// If the user email is not set, use the billing email.
175+
if ( empty( $email ) ) {
176+
$email = $this->get_billing_data_field( 'billing_email', $args );
177+
}
178+
172179
// translators: %1$s First name, %2$s Second name, %3$s Username.
173180
$description = sprintf( __( 'Name: %1$s %2$s, Username: %3$s', 'woocommerce-gateway-stripe' ), $billing_first_name, $billing_last_name, $user->user_login );
174181

175182
$defaults = [
176-
'email' => $user->user_email,
183+
'email' => $email,
177184
'description' => $description,
178185
];
179186

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,6 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
121121
* Tweak - Small improvements to e2e tests
122122
* Fix - Fix unnecessary Stripe API calls when rendering subscription details
123123
* Add - Adds a new action (`wc_stripe_webhook_received`) to allow additional actions to be taken for webhook notifications from Stripe
124+
* Fix - Allow checkout for logged-in users without an email in their account when a billing email is provided
124125

125126
[See changelog for full details across versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).

0 commit comments

Comments
 (0)