Commit f78f03831dd for woocommerce

commit f78f03831ddd88eafd7d9999b5ecaf6af6726422
Author: Peter Petrov <peter.petrov89@gmail.com>
Date:   Wed Aug 19 14:36:18 2026 +0300

    Move role column to end of customers report CSV export (#67843)

    * Move role column to end of customers report CSV export

    * Drop changelog entry superseded by the one in #67653

    * Restore changelog entry as an empty comment-only entry to satisfy CI

    * Assert role stays the last column in prepared CSV export rows

diff --git a/plugins/woocommerce/changelog/move-customers-csv-role-column-to-end b/plugins/woocommerce/changelog/move-customers-csv-role-column-to-end
new file mode 100644
index 00000000000..a2555354bd5
--- /dev/null
+++ b/plugins/woocommerce/changelog/move-customers-csv-role-column-to-end
@@ -0,0 +1,5 @@
+Significance: patch
+Type: tweak
+Comment: Amends unreleased #67653 (CSV Role column order); its changelog entry already describes the shipped behavior.
+
+
diff --git a/plugins/woocommerce/src/Admin/API/Reports/Customers/Controller.php b/plugins/woocommerce/src/Admin/API/Reports/Customers/Controller.php
index 236f607fb66..1b673ccea04 100644
--- a/plugins/woocommerce/src/Admin/API/Reports/Customers/Controller.php
+++ b/plugins/woocommerce/src/Admin/API/Reports/Customers/Controller.php
@@ -754,7 +754,6 @@ class Controller extends GenericController implements ExportableInterface {
 		$export_columns = array(
 			'name'            => __( 'Name', 'woocommerce' ),
 			'username'        => __( 'Username', 'woocommerce' ),
-			'role'            => __( 'Role', 'woocommerce' ),
 			'last_active'     => __( 'Last Active', 'woocommerce' ),
 			'registered'      => __( 'Sign Up', 'woocommerce' ),
 			'email'           => __( 'Email', 'woocommerce' ),
@@ -767,6 +766,7 @@ class Controller extends GenericController implements ExportableInterface {
 			'postcode'        => __( 'Postal Code', 'woocommerce' ),
 			'billing_phone'   => __( 'Billing Phone', 'woocommerce' ),
 			'shipping_phone'  => __( 'Shipping Phone', 'woocommerce' ),
+			'role'            => __( 'Role', 'woocommerce' ),
 		);

 		/**
@@ -791,7 +791,6 @@ class Controller extends GenericController implements ExportableInterface {
 		$export_item = array(
 			'name'            => $item['name'],
 			'username'        => $item['username'],
-			'role'            => $item['role'] ?? '',
 			'last_active'     => $item['date_last_active'],
 			'registered'      => $item['date_registered'],
 			'email'           => $item['email'],
@@ -804,6 +803,7 @@ class Controller extends GenericController implements ExportableInterface {
 			'postcode'        => $item['postcode'],
 			'billing_phone'   => $item['billing_phone'] ?? '',
 			'shipping_phone'  => $item['shipping_phone'] ?? '',
+			'role'            => $item['role'] ?? '',
 		);

 		/**
diff --git a/plugins/woocommerce/tests/legacy/unit-tests/woocommerce-admin/api/reports-customers.php b/plugins/woocommerce/tests/legacy/unit-tests/woocommerce-admin/api/reports-customers.php
index 7dbe140c5ac..0e386ea709a 100644
--- a/plugins/woocommerce/tests/legacy/unit-tests/woocommerce-admin/api/reports-customers.php
+++ b/plugins/woocommerce/tests/legacy/unit-tests/woocommerce-admin/api/reports-customers.php
@@ -257,11 +257,13 @@ class WC_Admin_Tests_API_Reports_Customers extends WC_REST_Unit_Test_Case {
 		$export_columns = $controller->get_export_columns();
 		$this->assertArrayHasKey( 'role', $export_columns, 'CSV export should include a role column' );
 		$this->assertEquals( 'Role', $export_columns['role'] );
+		$this->assertSame( 'role', array_key_last( $export_columns ), 'Role must stay the last CSV column so positional consumers of the pre-existing columns are unaffected' );

 		$export_roles_by_user_id = array();
 		foreach ( $reports as $report ) {
 			$export_item = $controller->prepare_item_for_export( $report );
 			$export_roles_by_user_id[ (int) $report['user_id'] ] = $export_item['role'];
+			$this->assertSame( 'role', array_key_last( $export_item ), 'Role must stay the last column in prepared export rows, matching the header order' );
 		}

 		$this->assertEquals( 'Editor, Shop manager', $export_roles_by_user_id[ $editor_id ], 'CSV export should carry the role value' );