=== Rearrange Products for WooCommerce ===
Contributors: aslamdoctor
Donate link: https://github.com/sponsors/aslamdoctor
Tags: woocommerce, product, reorder, rearrange, sort
Requires at least: 6.6
Tested up to: 6.9
Requires PHP: 7.4.0
License: GPL-3.0-or-later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Stable Tag: 6.0.0

Boost WooCommerce sales with the Rearrange Products for WooCommerce plugin. Easily reorder products with a simple drag-and-drop tool!

== Description ==

Take Full Control of Your WooCommerce Product Sort-Order

<strong>Do you want to decide which products appear first in your WooCommerce shop?</strong>
Rearrange Products for WooCommerce gives you full control over product ordering so you can highlight your best-selling, featured, or new products exactly where you want them.

This plugin is built specifically for WooCommerce stores and helps improve both customer experience and store performance.

With an easy-to-use <strong>drag-and-drop</strong> interface, you can:

* Reorder/Rearrange products on your main Shop page.
* Set custom product order for specific categories and sub-categories.
* Select multiple products at once and move them together.
* Manage product display without touching any code.

== Why Choose Rearrange Products for WooCommerce? ==

<strong>1. 🛒 Better Shopping Experience</strong>
Help customers find the right products faster by displaying them in a logical and attractive order.

<strong>2. 👀 More Visibility for Key Products</strong>
Promote best-selling, featured, or seasonal products by placing them at the top.

<strong>3. 📈 Higher Conversions</strong>
Showing the right products first can lead to more clicks and increased sales.

<strong>4. ⚡ Bulk Sort in One Click ([Pro](https://www.rearrangeproducts.com/))</strong>
Sort all your products at once by best-selling, ratings, price, stock status, and more — no need to drag them one by one.

<strong>5. 💾 Never Lose Your Work ([Pro](https://www.rearrangeproducts.com/))</strong>
Save your product arrangements as reusable presets. Switch between different layouts instantly — perfect for seasonal promotions and A/B testing.

== Free Features ==

* Fully compatible with WooCommerce.
* Simple drag-and-drop product sorting.
* Multi-select products and move them together.
* Custom sorting for categories and sub-categories.
* Works with WooCommerce shortcodes.
* Lightweight plugin with fast performance.
* No coding knowledge required.

== Pro Features ==

Unlock the full power of product management with <strong>[Rearrange Products for WooCommerce Pro](https://www.rearrangeproducts.com/)</strong>:

<strong>⚡ Smart Sort — Bulk Sort Products in One Click</strong>
Stop dragging products one by one. Smart Sort lets you reorder your entire catalog or a specific category in one shot based on:

* <strong>Best Selling</strong> — Put your top sellers front and center.
* <strong>Most Rated</strong> — Showcase products with the best reviews.
* <strong>Price (Low to High / High to Low)</strong> — Organize by price for easy browsing.
* <strong>In Stock First</strong> — Always show available products at the top.
* <strong>Latest / Oldest</strong> — Highlight new arrivals or evergreen products.
* <strong>On Sale</strong> — Push sale items to the top to drive conversions.
* <strong>Shuffle</strong> — Randomize your product display for a fresh look.

<strong>💾 Sort Presets — Save and Reuse Arrangements</strong>
Create, save, and switch between different product arrangements effortlessly:

* Save your current product order as a named preset with a description.
* Apply any saved preset with a single click to instantly rearrange products.
* Duplicate presets to create variations without starting from scratch.
* Search and filter through your presets for quick access.
* Works with both global and category-specific arrangements.
* Perfect for seasonal layouts, holiday promotions, flash sales, and A/B testing different product orders.

<strong>🔄 Import / Export — Portable Product Arrangements</strong>
Move your product arrangements between sites or share them with your team:

* Export global, category-specific, or preset arrangements as JSON files.
* Import arrangements on any site — products are matched by SKU for cross-site compatibility.
* Migrate your product order when moving to a new domain or staging environment.
* Detailed import reports showing matched, skipped, and total products.
* Supports files up to 10MB for large catalogs.

<strong>🚀 [Get Rearrange Products for WooCommerce Pro](https://www.rearrangeproducts.com/)</strong>

Make your WooCommerce store easier to browse and more effective at selling. Start organizing your products the way you want and give your customers a better shopping experience.

<strong>Note:</strong> WooCommerce must be installed and activated before using this plugin.

== Important Notes ==

1. If you deactivate this plugin, any product rearrangements you've made will be turned off. You can restore them at any time by reactivating the plugin.
2. If you delete or uninstall this plugin, all product rearrangements will be permanently removed and cannot be recovered.

== Installation ==

1. Go to your WordPress Admin Dashboard.
2. Navigate to <strong>Plugins → Add New</strong>.
2. Search for <strong>“Rearrange Products for WooCommerce.”</strong>
4. Click <strong>Install</strong>, then <strong>Activate</strong>. If WooCommerce is not installed or activated, this plugin will not activate.
5. Go to <strong>Admin → Rearrange Products</strong> and reorder products using drag and drop.
6. Use the <strong>“Sort by Categories”</strong> tab to arrange products by category.

== Frequently Asked Questions ==

= How do I use this plugin? =

Go to <strong>Admin → Rearrange Products</strong> and drag and drop products into your preferred order.
To sort by category, open the “Sort by Categories” tab.

= Can I recover my product order after deactivating or deleting the plugin? =

1. Deactivating the plugin will temporarily disable your custom product order.
1. Deleting or uninstalling the plugin will permanently remove all product rearrangements, and they cannot be restored.

= Does this plugin work with WooCommerce shortcodes? =

Yes. You can override the default sorting of products added via shortcodes such as:
`[product_category category=”my-category-slug”]`

To enable this:
1. Go to <strong>Admin → Rearrange Products → Settings</strong>
2. Enable <strong>”All Loops (including shortcodes)”</strong>

= What does the Pro version include? =

The [Pro version](https://www.rearrangeproducts.com/) adds three powerful features:

1. <strong>Smart Sort</strong> — Sort all your products in bulk by best-selling, ratings, price, stock status, sale status, and more with a single click.
2. <strong>Sort Presets</strong> — Save your product arrangements and switch between them instantly. Great for seasonal promotions and A/B testing.
3. <strong>Import / Export</strong> — Export your product arrangements as JSON files and import them on another site. Products are matched by SKU for cross-site compatibility.

= Can I try the free version first? =

Absolutely! The free version includes drag-and-drop sorting for all products and categories. You can [upgrade to Pro](https://www.rearrangeproducts.com/) at any time to unlock Smart Sort, Presets, and Import/Export.

= Will I lose my product order if I downgrade from Pro to Free? =

No. Your manually arranged product order (global and category-specific) is preserved. However, Pro features like presets and Smart Sort will no longer be accessible until you [upgrade again](https://www.rearrangeproducts.com/).

= Can I use Import/Export to migrate product order to a new site? =

Yes. The [Import/Export feature (Pro)](https://www.rearrangeproducts.com/) exports your product arrangements as a JSON file. When importing on a different site, products are matched by SKU, so your arrangements transfer even if product IDs differ between sites.

== Troubleshooting ==

**If your custom product order is not showing on the Shop page:**

1. Go to <strong>Admin → Appearance → Customize</strong>
2. Select <strong>WooCommerce → Product Catalogue</strong>
3. Find <strong>Default Product Sorting</strong>
4. Set it to <strong>“Default sorting (custom ordering + name)”</strong>

**If you have a large number of products and changes are not saving**

This may be due to server limits.
Ask your hosting provider to increase:

* memory_limit
* max_execution_time

After updating these settings, try saving the product order again.

**If you are using a page builder plugin (Elementor, Divi, WPBakery, etc.)**

Page builder plugins often have their own product query settings that work independently of WooCommerce's default sorting.

To use custom sort order with page builders:

1. Check your page builder's product widget/module for sorting options
2. Look for a "custom order" or "menu order" option in the product display settings
3. If you need help, contact your page builder's support team for guidance on their specific settings

Note: This plugin works seamlessly with standard WooCommerce shop pages, category pages, and WooCommerce shortcodes.

**Filing a support request?**

Go to <strong>Admin → Rearrange Products → Troubleshooting</strong> and open the <strong>"System Status / Diagnostic Info"</strong> section. Click <strong>"Copy to Clipboard"</strong> and paste the information into your support ticket. This helps us diagnose issues much faster.

== Plugin Demo ==

[youtube https://www.youtube.com/watch?v=ZZS-jXK_GJE]


== Screenshots ==

1. The plugin at work reordering all products
2. Ability to select multiple products and sort
3. Products sorted by Categories for reordering
4. Shortcut link under Categories section to sort by categories
5. Settings to Apply sorting on Main loop or All loops
6. Smart Sort — Automatically sort products by various criteria (Pro)
7. Sort Presets — Save and manage product arrangements (Pro)
8. Import / Export — Transfer product arrangements between sites (Pro)

== ChangeLog ==

= Version 6.0.0 =

**New Features**
* Added: Show private products in admin rearrange UI
* Added: System status / diagnostic info section on Troubleshooting page for easier support requests
* Added: Custom admin menu icon
* Added: Page navigation controls for large product catalogs
* Added: Auto-scroll when moving products to top or bottom of the list
* Added: Smooth FLIP animations for product move buttons
* Added: Empty state UI with guidance for Sort by Products tab
* Added: Product selection counter showing how many products are selected
* Added: Automatic cleanup of sort order data when products are deleted
* Added: Freemius SDK integration for licensing and premium feature management

**Enhancements**
* Improved: Refactored JavaScript into modular ES6 architecture for better maintainability
* Improved: Custom RWPP Modal component replacing third-party MicroModal library
* Improved: Updated branding and plugin display name to "Rearrange Products for WooCommerce"
* Improved: UI redesign with modern styling, CSS variables, and semantic color system
* Improved: Button consistency and visual hierarchy across all admin pages
* Improved: Reorder buttons now disabled based on product position (first/last)
* Improved: Page builder compatibility notes added to Troubleshooting page

**Bug Fixes**
* Fixed: Conflict with Post Types Order plugin by bumping filter priority
* Fixed: Postmeta fallback for category sorting and re-migration support
* Fixed: Filter bleed-through between multiple WooCommerce shortcodes on the same page
* Fixed: WooCommerce shortcode caching returning stale results for custom sorting
* Fixed: Sorting no longer affects secondary queries (widgets, shortcodes, custom blocks) on category pages
* Fixed: Category-specific sort order on category pages when "All Loops" is enabled
* Fixed: Nested category dropdown overflow in admin UI
* Fixed: Layout shift when modals open and close
* Fixed: Label hyphenation in Safari admin sidebar
* Fixed: Unbalanced left/right spacing in admin UI
* Fixed: Modal accessibility issues including aria-hidden warnings

**Compatibility**
* Tested with WordPress 6.9.1 and WooCommerce 10.6.1

= Version 5.0.11 =
* Exclude docs folder from plugin distribution

= Version 5.0.10 =
* Fixed: Product sort order resetting to last position when editing/saving a product at the first position in a category
* Fixed: `Database::get_sort_order()` now correctly distinguishes between "no entry" (null) and "sort_order = 0" (first position)
* Fixed: Category-specific sort orders broken for users who upgraded from v4.x due to silent migration failures
* Fixed: Migration error handling in `Database.php` — `create_table()`, `migrate_data()`, and individual migration methods now properly detect and report failures
* Added: Postmeta fallback in frontend sorting — category pages now automatically fall back to legacy `rwpp_sortorder_{id}` postmeta data if the custom table is empty
* Added: "Re-run Migration" button on Troubleshooting page to manually re-populate the custom table from legacy data

= Version 5.0.9 =
* Fixed: Product category shortcode sorting issues when "Apply Sorting To" is set to "All Loops"
* Added: WPML support - Sync product order across language translations for Global sorting

= Version 5.0.8 =
* Fixed: Plugin sorting no longer affects secondary product queries (widgets, shortcodes, custom blocks) on category pages
* Fixed: Footer product blocks now display correctly with their configured sorting on category archives
* Improved: Sorting filters are now properly removed after main query execution

= Version 5.0.7 =
* Fixed: Products moving to top of list after editing/updating
* Improved: Product updates now preserve existing sort order in custom table
* Tested with WooCommerce 10.4.3

= Version 5.0.6 =
* Fixed: Category sorting page not loading due to URL routing mismatch
* Fixed: Critical data loss bug where unloaded products lost sort orders during pagination
* Improved: Removed automatic orphan cleanup that was causing data loss in category-specific sorting

= Version 5.0.5 =
* Improved: Troubleshooting page with more customer-friendly language and clearer explanations
* Improved: Updated troubleshooting titles to be more relatable for end users
* Improved: Added helpful context and guidance for common issues
* Improved: Simplified technical language in server configuration section

= Version 5.0.4 =
* Fixed: Missing vendor and build files

= Version 5.0.2 =
* Major Release: Complete architectural refactor with unified database storage
* Added: Custom database table `wp_rwpp_product_order` for centralized sort order storage
* Added: Support for both global and category-specific product sorting
* Added: Automatic data migration from legacy storage systems (menu_order and postmeta)
* Added: Confirmation modal for product order changes with undo functionality
* Added: Load More button for pagination (replaced infinite scroll with manual control)
* Added: AJAX load more functionality to load products in chunks of 100
* Added: CSS variables and design tokens for better maintainability and theming
* Added: New SCSS buttons component file for consistent styling
* Added: Comprehensive debug logging for troubleshooting load more issues
* Improved: Database query optimization with indexed JOINs instead of meta_query
* Improved: COALESCE fallback logic for graceful degradation
* Improved: Chunked processing for large product datasets
* Improved: UI redesign with custom category dropdown
* Improved: Removed inline styles from templates (all styles now in SCSS)
* Improved: Cleaner HTML markup without redundant success messages
* Improved: Better separation of concerns between structure and styling
* Improved: Performance by loading initial products in chunks
* Enhanced: Performance with production-ready asset optimization
* Enhanced: User feedback with loading states on Load More button
* Enhanced: Better UX with explicit load more control instead of auto-scroll
* Fixed: Category view now includes subcategory products (matching frontend behavior)
* Fixed: WP_DEBUG reference error in JavaScript by localizing debug flag
* Fixed: WP_Query namespace issue in AJAX handler
* Fixed: AJAX action registrations to execute properly
* Updated: Build system to @wordpress/scripts with modern Sass implementation
* Refactored: Complete SASS file structure with variables for colors, typography, spacing
* Tested with WordPress 6.9 and WooCommerce 10.4.2

= Version 4.3.3 =
* fixed: Attempt to read property “term_id” on null
* tested with wordpress version 6.8.1
* tested with woocommerce version 9.8.3

= Version 4.3.2 =
* fixed: is_tax was called incorrectly
* fixed: settings for effected loops was not working properly
* tested with wordpress version 6.8
* tested with woocommerce version 9.8.2

= Version 4.3.1 =
* tested with wordpress version 6.7.1
* tested with woocommerce version 9.5.2

= Version 4.3.0 =
* Added settings to enable/disable override main loop or all loops
* tested with wordpress version 6.5.3
* tested with woocommerce version 8.9.1

= Version 4.2.0 =
* Make plugin compatible with HPOS ( High-Performance Order Storage )
* tested with wordpress version 6.4
* tested with woocommerce version 8.2.1

= Version 4.1.7 =
* Fix - under admin, some products not visible while sorting by category
* tested with wordpress version 6.3
* tested with woocommerce version 8.0.1

= Version 4.1.6 =
* Fix enqueue_assets hook not checking hook name properly when site is using different language.
Ref: https://wordpress.org/support/topic/products-are-no-longer-displayed-in-categories/#post-16934448

= Version 4.1.5 =
* Fix sort by "Latest" option not working

= Version 4.1.4 =
* tested with wordpress version 6.2.2
* tested with woocommerce version 7.9.0
* Added fix where products were missing on categories pages
* Added fix where is_product_category() was not working
* other minor bug fixes & cleanup

= Version 4.1.3 =
* tested with wordpress version 6.2.0
* tested with woocommerce version 7.7.0
* moved the plugin pages to top level of admin menu
* bug fixes

= Version 4.1.2 =
* tested with wordpress version 6.1.1
* tested with woocommerce version 7.2.0
* added page for troubleshooting guidelines

= Version 4.1.1 =
* Added translations for:
- English (Canada)
- English (UK)
- French (France)
- Spanish (Colombia)
- Spanish (Venezuela)
- Russian
- Hindi
- Spanish (Ecuador)
- Chinese (China)
- Spanish (Spain)

= Version 4.0.9 =
* added Troubleshooting steps for fix missing products issue
* tested with woocommerce version 6.5.1

= Version 4.0.8 =
* updated all node/npm packages to latest stable version
* tested with wordpress version 5.9.3
* tested with woocommerce version 6.4.1
* added notes for developers for contributing to plugin

= Version 4.0.5 =
* added global translation support

= Version 4.0.4 =
* added plugin translation support

= Version 4.0.3 =
* minor security patch to escape sql query

= Version 4.0.2 =
* minor security patch
* tested with woocommerce version 6.3.1

= Version 4.0.1 =
* delete entries from postmeta table when plugin uninstalled/deleted from admin
* fixed the issue that was making navigation menus unordered

= Version 4.0.0 =
* Fixes made for user roles and permissions checking

= Version 3.0.9 =
* Do not escape post title

= Version 3.0.8 =
* Updated code to follow WPCS Protocol
* Check for plugin authorization properly
* Add CSRF security on Ajax requests

= Version 3.0.7 =
* Security fixes: disable direct code file access from browser

= Version 3.0.6 =
* Minor security fixes

= Version 3.0.5 =
* Security Fixes: Removed nonpriv handlers
* Security Fixes: Added security to remove all SQL injections added as input
* Minor fix for checking product loop inside pre_get_posts hook

= Version 3.0.4 =
* Fixed: While sorting by categories, some products that are added recently were not visible.
* Code re-factoring and cleanup.

= Version 3.0.3 =
* Fixed: Keep default sort order on frontend if it was not updated for Categories.

= Version 3.0.2 =
* Fixed: Category orders not showing any products due to meta_query not found.

= Version 3.0.1 =
* Re-published the files as in v3.0.0, the files were not published properly

= Version 3.0.0 =

* Ability to sort products by any product category
* Ability to select multiple products by single click and sort them at once
* Removed feature to sort by Tags as it was not being used and also had unresolvable bug due to WC limitations
* Tested for Woocommerce Version 5.7.1 and Wordpress Version 5.8.1
* Code cleanup

= Version 2.3.6 =

* Tested for Woocommerce Version 4.8.0 and Wordpress Version 5.6
* Code cleanup

= Version 2.3.5 =

* Tested for Woocommerce Version 4.7.0 and Wordpress Version 5.5.3
* Tested with Storefront Theme Version 2.9.0
* Minor bug fixes with Group by Categories & Tags sorting.
* In group by categories parent category was also including products from child categories. So they were repeated to 2 places. This has been updated to show products exactly below their parent categories only. (changed 'include_children' to "false" in tax_query)
* Styling issue fixed for long product names
* Added button to expand/collapse all categories & tags


= Version 2.3.1 =

* Tested for Woocommerce Version 4.3.1 and Wordpress Version 5.4.2
* Added important notices for sorting by categories and tags


= Version 2.3.0 =

* Added feature to group and sort by Product Tags
* Added feature to move products up, down, top, bottom of the list using arrow buttons
* Added serial numbers(not ID) to each products so it can give us idea on which product's sort order we changed
* Added current user check for "manage_woocommerce" capability
* Plugin information updated to properly show "tested upto" version of Woocommerce
* Added security to disable direct access to the plugin PHP files

= Version 2.2.0 =

* Added expand/collapse feature on categories to clear the clutter
* Fixed a minor bug that was happening while activating the plugin
* Tested for Woocommerce Version 4.0.0 and Wordpress Version 5.3.2

= Version 2.1.2 =

* Hide Products from list that are set as "private"
* Added a fix for bug that was checking the user role
* Tested for Woocommerce Version 3.7.1 and Wordpress Version 5.2.4

= Version 2.1.1 =

* Added shortcut button to edit products
* Tested for Woocommerce Version 3.7.0 and Wordpress Version 5.2.3

= Version 2.0.0 =

* Added feature to group products by categories
* Added feature to preview product info from same page
* Added some minor bug fixes
* Tested for latest Woocommerce version 3.6.3

= Version 1.1.1 =

* Added fix as the plugin was not working for some people. As it was using static table prefix "wp_". So changed it to dynamic table prefix to work will all kind of WP Databases.
* Tested for latest Woocommerce version 3.5.3

= Version 1.1.0 =

* Added capability to handle huge amount of products.
* Combined multiple sql update queries into one query.

= Version 1.0.0 =

* Initial release.
