Hi team, I’ve been using snippets to auto-generate coupons for returning customers and now there’re so many used-up coupons in the admin coupon list and it’s occupying massive page height.
I want to clean up the used-up coupons and those expired coupons, but as there are too many, I cannot delete it one by one, is there a better way to sort out all the coupons in the database? For example by searching for the condition: usage limit = usage count, or expiration exceeds certain date.
I cannot seem to find the coupon field in the database, I found in gf_entry_meta but it doesn’t contain the meta values like usage limit and usage count…
If your database has the JSON functions, which, I think, were introduced around MySQL 5.7, try the following:
SELECT *
FROM `wp_gf_addon_feed`
WHERE `addon_slug` = 'gravityformscoupons'
AND JSON_UNQUOTE(JSON_EXTRACT(`meta`, '$.usageLimit')) = JSON_UNQUOTE(JSON_EXTRACT(`meta`, '$.usageCount'));