Commit 5febd39d7c4 for woocommerce

commit 5febd39d7c487bc8c776a0e04cd2021a6a23efce
Author: Wesley Rosa <wesleyjrosa@gmail.com>
Date:   Tue Jul 28 16:05:33 2026 -0300

    Add CatalogSortOrder enum class for woocommerce_default_catalog_orderby option values (#66877)

    Add CatalogSortOrder enum class and adopt it across the codebase

diff --git a/plugins/woocommerce/changelog/add-catalog-sort-order-enum b/plugins/woocommerce/changelog/add-catalog-sort-order-enum
new file mode 100644
index 00000000000..89101f65cbd
--- /dev/null
+++ b/plugins/woocommerce/changelog/add-catalog-sort-order-enum
@@ -0,0 +1,4 @@
+Significance: minor
+Type: add
+
+Add CatalogSortOrder enum class for woocommerce_default_catalog_orderby option values and adopt it in the Product Collection block query builder.
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection/QueryBuilder.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection/QueryBuilder.php
index c5b4f6a6bbc..3343bc8457c 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection/QueryBuilder.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductCollection/QueryBuilder.php
@@ -9,6 +9,7 @@ use Automattic\WooCommerce\Blocks\BlockTypes\RatingFilter;
 use Automattic\WooCommerce\Blocks\BlockTypes\StockFilter;
 use WP_Query;
 use WC_Tax;
+use Automattic\WooCommerce\Enums\CatalogSortOrder;
 use Automattic\WooCommerce\Enums\ProductStockStatus;
 use Automattic\WooCommerce\Enums\TaxDisplayMode;

@@ -1119,7 +1120,7 @@ class QueryBuilder {
 			return array( 'orderby' => $orderby );
 		}

-		if ( 'price' === $orderby ) {
+		if ( CatalogSortOrder::PRICE === $orderby ) {
 			add_filter( 'posts_clauses', array( $this, 'add_price_sorting_posts_clauses' ), 10, 2 );
 			return array(
 				'isProductCollection' => true,
@@ -1128,7 +1129,7 @@ class QueryBuilder {
 		}

 		// The popularity orderby value here is for backwards compatibility as we have since removed the filter option.
-		if ( 'sales' === $orderby || 'popularity' === $orderby ) {
+		if ( 'sales' === $orderby || CatalogSortOrder::POPULARITY === $orderby ) {
 			add_filter( 'posts_clauses', array( $this, 'add_sales_sorting_posts_clauses' ), 10, 2 );
 			return array(
 				'isProductCollection' => true,
@@ -1136,7 +1137,7 @@ class QueryBuilder {
 			);
 		}

-		if ( 'menu_order' === $orderby ) {
+		if ( CatalogSortOrder::MENU_ORDER === $orderby ) {
 			add_filter( 'posts_clauses', array( $this, 'add_menu_order_with_title_fallback_posts_clauses' ), 10, 2 );
 			return array(
 				'isProductCollection' => true,
diff --git a/plugins/woocommerce/src/Enums/CatalogSortOrder.php b/plugins/woocommerce/src/Enums/CatalogSortOrder.php
new file mode 100644
index 00000000000..890e78f76f9
--- /dev/null
+++ b/plugins/woocommerce/src/Enums/CatalogSortOrder.php
@@ -0,0 +1,54 @@
+<?php
+
+declare( strict_types = 1 );
+
+namespace Automattic\WooCommerce\Enums;
+
+/**
+ * Enum class for the possible values of the 'woocommerce_default_catalog_orderby' option.
+ *
+ * @since 11.1.0
+ */
+final class CatalogSortOrder {
+	/**
+	 * Default sorting (custom ordering + name).
+	 *
+	 * @var string
+	 */
+	public const MENU_ORDER = 'menu_order';
+
+	/**
+	 * Sort by popularity (number of sales).
+	 *
+	 * @var string
+	 */
+	public const POPULARITY = 'popularity';
+
+	/**
+	 * Sort by average rating.
+	 *
+	 * @var string
+	 */
+	public const RATING = 'rating';
+
+	/**
+	 * Sort by most recent.
+	 *
+	 * @var string
+	 */
+	public const DATE = 'date';
+
+	/**
+	 * Sort by price ascending.
+	 *
+	 * @var string
+	 */
+	public const PRICE = 'price';
+
+	/**
+	 * Sort by price descending.
+	 *
+	 * @var string
+	 */
+	public const PRICE_DESC = 'price-desc';
+}
diff --git a/plugins/woocommerce/src/Enums/README.md b/plugins/woocommerce/src/Enums/README.md
index 14c862137b3..f331ba30a6d 100644
--- a/plugins/woocommerce/src/Enums/README.md
+++ b/plugins/woocommerce/src/Enums/README.md
@@ -6,6 +6,7 @@ The enum classes make it easier to reference string values and avoid typos. They

 ## Available Enumerators

+- [CatalogSortOrder](./CatalogSortOrder.php) - Enumerates the possible values of the `woocommerce_default_catalog_orderby` option.
 - [CatalogVisibility](./CatalogVisibility.php) - Enumerates the possible catalog visibility options for a product.
 - [CurrencyPosition](./CurrencyPosition.php) - Enumerates the possible values of the `woocommerce_currency_pos` option.
 - [DefaultCustomerAddress](./DefaultCustomerAddress.php) - Enumerates the possible values of the `woocommerce_default_customer_address` option.