Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix product fieldset persistence issue by removing WooCommerce query limit #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luka1199
Copy link

@luka1199 luka1199 commented Feb 2, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant