=== CatCode Catalog Sort Rules for WooCommerce ===
Contributors: catcodestudio
Tags: product sorting, category sorting, brand, catalog order, woocommerce
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A default sorting of its own for every product category, brand and tag: newest, best sellers, price, rating or name.

== Description ==

WooCommerce has one default sorting for the whole catalog. A shop rarely wants that: new arrivals should open with the newest products, a brand page with its best sellers, a sale category with the lowest prices. This plugin gives every category, brand and tag page its own default sorting.

* **A rule per page:** on the edit screen of a category, brand or tag choose "Product sorting on this page" — newest first, best sellers first, highest rated first, price low to high or high to low, name A to Z or Z to A, or the default WooCommerce order.
* **Subcategories inherit:** a subcategory without a rule of its own follows the nearest parent category that has one, so one rule on "Clothing" covers all of its subcategories. Inheritance can be switched off.
* **Brands, tags and more:** WooCommerce brands (WooCommerce 9.6 and later), product tags, the taxonomies of brand plugins and product attributes with archive pages can be switched on in the settings.
* **Shoppers keep the choice:** the rule is only the default. The "Sort by" list stays and shows the rule as the selected entry; a shopper can still pick another sorting. The shop page, search results and pages without a rule keep the default from WooCommerce → Settings → Products.
* **Works with what you have:** the rules are WooCommerce's own orderings, so pagination, the result count, layered navigation, filter plugins, classic themes and block themes (the Product Catalog template and the Catalog Sorting block) behave as on the shop page.
* **Overview:** WooCommerce → Catalog Sort Rules lists every page that has its own sorting; a "Sorting" column in the category, brand and tag lists shows each rule, including the inherited ones.
* No database tables, nothing loaded on the storefront except the sorting itself, products are never modified.

== Installation ==

1. Install and activate the plugin (WooCommerce must be active).
2. Open Products → Categories (or Brands, or Tags) and edit a category.
3. Choose "Product sorting on this page" and save. Open the category on the storefront — the products follow the rule.
4. WooCommerce → Catalog Sort Rules shows every page with its own sorting and the settings.

== Frequently Asked Questions ==

= Does it change the shop page? =

No. The shop page, search results and every category, brand or tag without a rule keep the default sorting from WooCommerce → Settings → Products → Default product sorting.

= Can shoppers still sort by price? =

Yes. The "Sort by" list stays; the rule only decides what is selected when the page opens.

= My theme has no "Sort by" list. =

The rule still applies: it is the order the products are listed in.

= Does it work with the WooCommerce Product Collection block? =

On the product archive templates (the block's "Inherit query from template" option, which the default templates use) — yes. A Product Collection block placed with its own query has its own "Order by" setting in the block, and that setting stays in charge.

= I use a page cache plugin. Will visitors see the new order? =

Yes. Saving a rule, a pinned product or the order clears the page cache of WP Super Cache, W3 Total Cache, WP Rocket, LiteSpeed Cache, WP Fastest Cache, WP-Optimize, Cache Enabler, Breeze, SiteGround Speed Optimizer and Nginx Helper. For any other cache (a CDN, a host's own cache) clear it by hand, or hook into the `ccsort_page_cache_flushed` action.

= What happens to the rules when I deactivate the plugin? =

They stay saved on the categories, brands and tags, and the pages go back to the shop default. Deleting the plugin removes the rules.

== Changelog ==

= 1.0.0 =
* First release: a sorting rule for every product category, brand and tag, inheritance by subcategories, the "Sorting" column and the overview screen; the page cache is cleared after a sorting change.
