Lee Foot

WooCommerce Product Sorter

Reorder products in each WooCommerce category so names closest to the category name come first.

Launch the app → View the source

#about

Reorders the products in every WooCommerce category so those whose names best match the category name come first.

Each name is scored with FuzzyWuzzy token_sort_ratio (0 to 100, word order ignored) and the order is written straight to menu_order through the WooCommerce REST API.

Up to 100 products per category are scored, with no preview, so test on staging first.

A product in several categories keeps the position from the last one processed.

Streamlit app

Platform
Browser-based (no installation required)
Input
WooCommerce store URLConsumer key and consumer secret API credentials
Output
Products automatically reordered within WooCommerce categories by relevancy score. Console shows category names, product counts, and sorted listings.
Category
E-commerce

Use cases

  • Improving default product sorting in WooCommerce
  • Ensuring products appear in logical order based on category names

#features

  • WooCommerce REST API v3 integration
  • FuzzyWuzzy token_sort_ratio scoring (ties broken alphabetically)
  • Batch POST updates for menu_order values
  • Category pagination (100 per page); products fetched one page per category (up to 100)
  • 120-second send/receive timeouts for large catalogues
  • Console output: category names, product counts, sorted listings

#how-to-use

  1. Enter WooCommerce store URL and read/write API credentials
  2. Tool fetches all categories, then the first page of products (up to 100) per category
  3. FuzzyWuzzy scores each product name against its category name
  4. Batch updates menu_order live via products/batch (no dry run)
  5. Set storefront sorting to Default sorting so menu_order takes effect

#faq

Why did only some products in each category get reordered?
The product fetch does not paginate. Categories are fetched 100 per page until exhausted, but products are requested with a single call per category with per_page set to 100. Only that first page, up to 100 products, is scored and given a menu_order. Add pagination to the products request if your categories are larger.
Does this change my live store immediately?
Yes. It POSTs menu_order updates via the products/batch endpoint as it processes each category, with no dry-run or preview mode. Run it against a staging site first. The new order is only visible on the storefront when the catalogue sort option is Default sorting, which is what respects menu_order.
What happens to products in more than one category?
menu_order is a single field on the product, not a per-category value, so a product appearing in several categories gets its menu_order overwritten each time one of its categories is processed. It keeps whichever position was written last, which may not suit its other categories.
How is the relevancy score calculated?
FuzzyWuzzy token_sort_ratio between the product name and the category name, a 0 to 100 score that tokenises and sorts words before comparing, so word order does not matter. Ties are broken alphabetically by product name. It is purely lexical: a 'Leather Hiking Boot' scores well in 'Hiking Boots', but synonyms or model-number-only names score poorly.
What API credentials does it need?
A WooCommerce REST API consumer key and secret with Read/Write permission, created under WooCommerce > Settings > Advanced > REST API, plus your store URL. The script uses API version wc/v3 with 120-second send and receive timeouts for large catalogues.

/contact

Want me to run this for you? I run this tool as a managed service, or build something custom around your data. You get the insights without touching the code.