Run Black Friday, Cyber Monday, or other flash sales on your WordPress-powered eCommerce or membership site with WooCommerce, Easy Digital Downloads, and Paid Memberships Pro.
Ran into an issue on a WooCommerce site that had 33,000+ coupons. The new sale page would fail with an out of memory issue. Looking into it, it seemed to be due to the query to get the coupons for the WC dropdown.
To Reproduce
Steps to reproduce the behavior:
Somehow put 33k coupons in your site.
Use less than 500mb RAM for your admin user.
Try to create a coupon.
Choose WC from the dropdown.
Notice none of the other fields are loading... because the page should fatal error out.
Suggestions
We should perhaps do a custom query here that just gets the coupon code and ID from the posts table, since (I think) those are the only values we need.
The updates in the PR attached to this issue have been pushed to a site that was experiencing the issue and its still not working very swiftly. What alternatives can we consider?
Filter to optionally "disable" the autocomplete/dropdown and set a secific coupon by ID?
Describe the bug
Ran into an issue on a WooCommerce site that had 33,000+ coupons. The new sale page would fail with an out of memory issue. Looking into it, it seemed to be due to the query to get the coupons for the WC dropdown.
To Reproduce Steps to reproduce the behavior:
Notice none of the other fields are loading... because the page should fatal error out.
Suggestions
We should perhaps do a custom query here that just gets the coupon code and ID from the posts table, since (I think) those are the only values we need.
Alternatively, updating the args here to include a few performance-related ones helps: https://github.com/strangerstudios/sitewide-sales/blob/dev/modules/ecommerce/wc/class-swsales-module-wc.php#L88-L94
Related Stack Overflow: https://wordpress.stackexchange.com/questions/98102/is-there-a-way-to-exclude-the-content-from-the-post-variable-to-save-on-ram-usag
Isolating the problem (mark completed items with an [x]):