Fix product fieldset persistence issue by removing WooCommerce query limit #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue where saving more than 10 products in a fieldset caused some products to disappear after saving and reloading the fieldset. The issue was due to WooCommerce’s default product query limit of 10, which prevented all selected products from being retrieved when reloading the fieldset.
Bug Effects
If more than 10 product IDs were stored in the fieldset, only the first 10 (based on WooCommerce’s internal query order) were loaded.
Any products beyond this limit were not displayed in the fieldset after reloading.
If the user saved again without noticing the missing products, they would be permanently removed from the fieldset.
Fix
Updated the wc_get_products() query to explicitly set 'limit' => -1, ensuring all selected products are always retrieved.
This prevents products from being unintentionally excluded and removed upon subsequent saves.