#48459 coupon email restrictions fix (#48488)

* Create customer object from user object to fetch emails in try-catch.

* Add changefile(s) from automation for the following project(s): woocommerce

* 48459 Replace $check_emails array values with user_email.

* Update plugins/woocommerce/changelog/48488-48459-coupon-email-restriction-fix

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
This commit is contained in:
Estian 2024-06-25 16:32:57 +02:00 committed by GitHub
parent 00f7420f81
commit 858231c238
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fixed a bug causing account email not to be taken in consideration for coupon validation when a customer has a different billing email set.

View File

@ -970,7 +970,7 @@ class WC_Discounts {
}
$user = wp_get_current_user();
$check_emails = array( $user->get_billing_email(), $user->get_email() );
$check_emails = array( $user->user_email );
if ( $this->object instanceof WC_Cart ) {
$check_emails[] = $this->object->get_customer()->get_billing_email();