Set customer email in reports data if available (#51367)

* Set customer email in reports data if available.

* Add changelog

* Lint
This commit is contained in:
Miguel Pérez Pellicer 2024-09-16 22:45:47 +04:00 committed by Christopher Allford
parent c690dea84d
commit dfb0769c47
No known key found for this signature in database
GPG Key ID: 80E44C778F08A88E
2 changed files with 9 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Set customer email in reports if customer data is available

View File

@ -615,6 +615,11 @@ class DataStore extends ReportsDataStore implements DataStoreInterface {
if ( is_null( $customer_user ) ) {
$customer_user = new \WC_Customer( $user_id );
}
// Set email as customer email instead of Order Billing Email if we have a customer.
$data['email'] = $customer_user->get_email( 'edit' );
// Adding other relevant customer data.
$data['user_id'] = $user_id;
$data['username'] = $customer_user->get_username( 'edit' );
$data['date_registered'] = $customer_user->get_date_created( 'edit' ) ? $customer_user->get_date_created( 'edit' )->date( TimeInterval::$sql_datetime_format ) : null;