Commit 917d492649c for woocommerce

commit 917d492649c6bdf50c846a203917e2dccec448cc
Author: Poli Gilad <83961704+poligilad-auto@users.noreply.github.com>
Date:   Mon May 18 18:48:12 2026 +0200

    Polish shipping fields in the product edit drawer (#65127)

    * Register a settings entity in the WooCommerce Blocks entities module

    Adds a `('root', 'settings')` entity backed by the v4 REST API
    (`/wc/v4/settings`) and registers it globally via the `wc-entities`
    script. This lets admin clients call `useEntityRecord( 'root', 'settings',
    '<group>' )` to read store settings through core-data instead of one-off
    `apiFetch` calls.

    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

    * Reorder shipping fields in the product edit drawer

    Move the dimension row to Length, Width, Height and place Weight on its
    own row below. Collapses the previous per-type DIMENSIONS_FORM_FIELD and
    PARENT_DIMENSIONS_FORM_FIELD into a single shared definition used by
    simple, variation, and variable product configs.

    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

    * add comment

    * fix dimension fields order

    ---------

    Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
    Co-authored-by: Luigi Teschio <gigitux@gmail.com>

diff --git a/packages/js/experimental-products-app/changelog/reorder-shipping-fields b/packages/js/experimental-products-app/changelog/reorder-shipping-fields
new file mode 100644
index 00000000000..89e423fa815
--- /dev/null
+++ b/packages/js/experimental-products-app/changelog/reorder-shipping-fields
@@ -0,0 +1,4 @@
+Significance: minor
+Type: update
+
+Reorder shipping fields in the product edit drawer to Length, Width, Height in a row with Weight below.
diff --git a/packages/js/experimental-products-app/src/product-edit/utils.test.ts b/packages/js/experimental-products-app/src/product-edit/utils.test.ts
index d0dc9219ffc..51acec43d61 100644
--- a/packages/js/experimental-products-app/src/product-edit/utils.test.ts
+++ b/packages/js/experimental-products-app/src/product-edit/utils.test.ts
@@ -395,10 +395,10 @@ describe( 'product edit utils', () => {
 				'tags',
 				'featured',
 				'shipping_class',
-				'weight',
 				'length',
 				'width',
 				'height',
+				'weight',
 			] );
 			expectFieldsHidden( fieldIds, [
 				'price',
@@ -1113,9 +1113,9 @@ describe( 'product edit utils', () => {
 						{
 							id: 'dimensions',
 							layout: { type: 'row' },
-							children: [ 'weight', 'length', 'width' ],
+							children: [ 'length', 'width', 'height' ],
 						},
-						'height',
+						'weight',
 					],
 				},
 			] );
@@ -1278,7 +1278,7 @@ describe( 'product edit utils', () => {
 					children: [
 						'shipping_class',
 						{
-							id: 'parent-dimensions',
+							id: 'dimensions',
 							layout: { type: 'row' },
 							children: [ 'length', 'width', 'height' ],
 						},
@@ -1336,9 +1336,9 @@ describe( 'product edit utils', () => {
 						{
 							id: 'dimensions',
 							layout: { type: 'row' },
-							children: [ 'weight', 'length', 'width' ],
+							children: [ 'length', 'width', 'height' ],
 						},
-						'height',
+						'weight',
 					],
 				},
 			] );
diff --git a/packages/js/experimental-products-app/src/product-edit/utils.ts b/packages/js/experimental-products-app/src/product-edit/utils.ts
index 129cff13a88..ca64cfc5246 100644
--- a/packages/js/experimental-products-app/src/product-edit/utils.ts
+++ b/packages/js/experimental-products-app/src/product-edit/utils.ts
@@ -84,17 +84,9 @@ const PRODUCT_EDIT_FIELD_IDS = [
 	'linked_products_count',
 ] as const;

-const DIMENSION_GROUP_FIELD_IDS = [ 'weight', 'length', 'width' ] as const;
-
 const DIMENSIONS_FORM_FIELD: ProductEditFormField = {
 	id: 'dimensions',
 	layout: { type: 'row' as const },
-	children: [ ...DIMENSION_GROUP_FIELD_IDS ],
-};
-
-const PARENT_DIMENSIONS_FORM_FIELD: ProductEditFormField = {
-	id: 'parent-dimensions',
-	layout: { type: 'row' as const },
 	children: [ 'length', 'width', 'height' ],
 };

@@ -151,7 +143,7 @@ const SIMPLE_PRODUCT_EDIT_FORM_FIELDS = [
 	createProductEditFormGroup(
 		'shipping-fields',
 		__( 'Shipping', 'woocommerce' ),
-		[ 'shipping_class', DIMENSIONS_FORM_FIELD, 'height' ]
+		[ 'shipping_class', DIMENSIONS_FORM_FIELD, 'weight' ]
 	),
 ] satisfies ProductEditFormField[];

@@ -184,7 +176,7 @@ const VARIATION_PRODUCT_EDIT_FORM_FIELDS = [
 	createProductEditFormGroup(
 		'shipping-fields',
 		__( 'Shipping', 'woocommerce' ),
-		[ 'shipping_class', DIMENSIONS_FORM_FIELD, 'height' ]
+		[ 'shipping_class', DIMENSIONS_FORM_FIELD, 'weight' ]
 	),
 ] satisfies ProductEditFormField[];

@@ -210,7 +202,7 @@ const VARIABLE_PRODUCT_EDIT_FORM_FIELDS = [
 	createProductEditFormGroup(
 		'shipping-fields',
 		__( 'Shipping', 'woocommerce' ),
-		[ 'shipping_class', PARENT_DIMENSIONS_FORM_FIELD, 'weight' ]
+		[ 'shipping_class', DIMENSIONS_FORM_FIELD, 'weight' ]
 	),
 ] satisfies ProductEditFormField[];

diff --git a/plugins/woocommerce/changelog/register-settings-entity b/plugins/woocommerce/changelog/register-settings-entity
new file mode 100644
index 00000000000..7d43c2dc2a7
--- /dev/null
+++ b/plugins/woocommerce/changelog/register-settings-entity
@@ -0,0 +1,4 @@
+Significance: minor
+Type: add
+
+Register a settings entity in the WooCommerce Blocks entities module so admin clients can read store settings via core-data.
diff --git a/plugins/woocommerce/client/blocks/assets/js/entities/index.ts b/plugins/woocommerce/client/blocks/assets/js/entities/index.ts
index 799bbfcfeac..9e92aa3417c 100644
--- a/plugins/woocommerce/client/blocks/assets/js/entities/index.ts
+++ b/plugins/woocommerce/client/blocks/assets/js/entities/index.ts
@@ -1,8 +1,20 @@
 /**
  * Internal dependencies
  */
-import { registerProductEntity } from './register-entities';
+import { isExperimentalWcRestApiV4Enabled } from '../settings/blocks/feature-flags';
+import {
+	registerProductEntity,
+	registerSettingsEntity,
+} from './register-entities';

 export * from './product';
+export * from './settings';

 registerProductEntity();
+
+/**
+ * Register the settings entity only when the experimental v4 REST API is enabled.
+ */
+if ( isExperimentalWcRestApiV4Enabled() ) {
+	registerSettingsEntity();
+}
diff --git a/plugins/woocommerce/client/blocks/assets/js/entities/register-entities.ts b/plugins/woocommerce/client/blocks/assets/js/entities/register-entities.ts
index ae20b660e4a..a71783f3634 100644
--- a/plugins/woocommerce/client/blocks/assets/js/entities/register-entities.ts
+++ b/plugins/woocommerce/client/blocks/assets/js/entities/register-entities.ts
@@ -8,6 +8,7 @@ import { dispatch } from '@wordpress/data';
  * Internal dependencies
  */
 import { PRODUCT_ENTITY } from './product/constants';
+import { SETTINGS_ENTITY } from './settings/constants';

 const registered: string[] = [];

@@ -19,3 +20,12 @@ export const registerProductEntity = () => {
 	addEntities( [ PRODUCT_ENTITY ] );
 	registered.push( PRODUCT_ENTITY.name );
 };
+
+export const registerSettingsEntity = () => {
+	if ( registered.includes( SETTINGS_ENTITY.name ) ) {
+		return;
+	}
+	const { addEntities } = dispatch( coreStore );
+	addEntities( [ SETTINGS_ENTITY ] );
+	registered.push( SETTINGS_ENTITY.name );
+};
diff --git a/plugins/woocommerce/client/blocks/assets/js/entities/settings/constants.ts b/plugins/woocommerce/client/blocks/assets/js/entities/settings/constants.ts
new file mode 100644
index 00000000000..9a6a14b7abc
--- /dev/null
+++ b/plugins/woocommerce/client/blocks/assets/js/entities/settings/constants.ts
@@ -0,0 +1,28 @@
+/**
+ * External dependencies
+ */
+import { __ } from '@wordpress/i18n';
+
+/**
+ * Internal dependencies
+ */
+import { Entity } from '../types';
+import { SettingsEntityRecord } from './types';
+
+export const SETTINGS_ENTITY: Entity = {
+	name: 'settings',
+	kind: 'root',
+	baseURL: '/wc/v4/settings',
+	label: __( 'Settings', 'woocommerce' ),
+	getTitle: ( record ) => {
+		const recordData = record as SettingsEntityRecord;
+		return (
+			recordData?.id.charAt( 0 ).toUpperCase() +
+			recordData?.id.slice( 1 ) +
+			' settings'
+		);
+	},
+	key: 'id',
+	supportsPagination: false,
+	plural: __( 'Settings', 'woocommerce' ),
+};
diff --git a/plugins/woocommerce/client/blocks/assets/js/entities/settings/index.ts b/plugins/woocommerce/client/blocks/assets/js/entities/settings/index.ts
new file mode 100644
index 00000000000..fcb073fefcd
--- /dev/null
+++ b/plugins/woocommerce/client/blocks/assets/js/entities/settings/index.ts
@@ -0,0 +1 @@
+export * from './types';
diff --git a/plugins/woocommerce/client/blocks/assets/js/entities/settings/types.ts b/plugins/woocommerce/client/blocks/assets/js/entities/settings/types.ts
new file mode 100644
index 00000000000..8eb7548d089
--- /dev/null
+++ b/plugins/woocommerce/client/blocks/assets/js/entities/settings/types.ts
@@ -0,0 +1,15 @@
+export type SettingsEntityValue = string | number | boolean | unknown[];
+
+export interface SettingsEntityRecord {
+	id: string;
+	title?: string;
+	description?: string;
+	values?: Record< string, SettingsEntityValue >;
+	groups?: Record<
+		string,
+		{
+			title?: string;
+			description?: string;
+		}
+	>;
+}