Commit 76fdc6718d7 for woocommerce

commit 76fdc6718d7cef60664b61d6751ff7271a3769fb
Author: Praveen Kumar <71814083+PraveenKum11@users.noreply.github.com>
Date:   Thu Oct 22 19:50:24 2026 +0530

    Count customers who registered on the last day of the sales report range (#70127)

    The customer check in the legacy reports/sales endpoint compared registration dates with end_date, which is midnight at the start of the last day, so customers who registered later that day were dropped from every range.

    Fixes #33759.

diff --git a/plugins/woocommerce/changelog/33759-sales-report-customers-last-day b/plugins/woocommerce/changelog/33759-sales-report-customers-last-day
new file mode 100644
index 00000000000..bbdf437bea9
--- /dev/null
+++ b/plugins/woocommerce/changelog/33759-sales-report-customers-last-day
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Count customers who registered on the last day of the date range in the REST API sales report.
diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-report-sales-v1-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-report-sales-v1-controller.php
index cc6bb03e3e0..c8b91b2408e 100644
--- a/plugins/woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-report-sales-v1-controller.php
+++ b/plugins/woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-report-sales-v1-controller.php
@@ -112,8 +112,12 @@ class WC_REST_Report_Sales_V1_Controller extends WC_REST_Controller {

 		$customers = $users_query->get_results();

+		// end_date is midnight at the start of the last day, so the range ends one day later.
+		$range_end = strtotime( '+1 DAY', $this->report->end_date );
+
 		foreach ( $customers as $key => $customer ) {
-			if ( strtotime( $customer->user_registered ) < $this->report->start_date || strtotime( $customer->user_registered ) > $this->report->end_date ) {
+			$registered = strtotime( $customer->user_registered );
+			if ( $registered < $this->report->start_date || $registered >= $range_end ) {
 				unset( $customers[ $key ] );
 			}
 		}
diff --git a/plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version3/class-wc-rest-report-sales-controller-tests.php b/plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version3/class-wc-rest-report-sales-controller-tests.php
index 39097203a75..bd3a359afcd 100644
--- a/plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version3/class-wc-rest-report-sales-controller-tests.php
+++ b/plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version3/class-wc-rest-report-sales-controller-tests.php
@@ -228,4 +228,52 @@ class WC_REST_Report_Sales_Controller_Tests extends WC_REST_Unit_Test_Case {
 		$this->assertArrayHasKey( 'refunds', $bucket_schema['properties'], 'Per-period bucket should declare a refunds property.' );
 		$this->assertSame( 'string', $bucket_schema['properties']['refunds']['type'], 'refunds should be a string (decimal).' );
 	}
+
+	/**
+	 * Data provider for custom date ranges ending on 2024-03-15.
+	 *
+	 * @return array<string, array{string}>
+	 */
+	public function provider_custom_range_start(): array {
+		return array(
+			'single-day range' => array( '2024-03-15' ),
+			'multi-day range'  => array( '2024-03-10' ),
+		);
+	}
+
+	/**
+	 * @testdox Should count customers who registered at any time on the last day of a custom range ($date_min to 2024-03-15).
+	 * @dataProvider provider_custom_range_start
+	 *
+	 * @param string $date_min Start of the custom range.
+	 */
+	public function test_total_customers_includes_the_whole_last_day_of_a_custom_range( string $date_min ): void {
+		$registered_dates = array(
+			'2024-03-15 00:00:00',
+			'2024-03-15 12:30:00',
+			'2024-03-15 23:59:59',
+			'2024-03-16 00:00:00',
+		);
+		foreach ( $registered_dates as $registered ) {
+			$this->factory->user->create(
+				array(
+					'role'            => 'customer',
+					'user_registered' => $registered,
+				)
+			);
+		}
+
+		$request = new WP_REST_Request( 'GET', '/wc/v3/reports/sales' );
+		$request->set_param( 'date_min', $date_min );
+		$request->set_param( 'date_max', '2024-03-15' );
+
+		try {
+			$data = ( new WC_REST_Report_Sales_Controller() )->prepare_item_for_response( null, $request )->get_data();
+		} finally {
+			// setup_report() passes the custom range to WC_Admin_Report through $_GET.
+			unset( $_GET['start_date'], $_GET['end_date'] );
+		}
+
+		$this->assertSame( 3, $data['total_customers'], 'Customers registered during 2024-03-15 should be counted, and those registered on 2024-03-16 should not.' );
+	}
 }