Mailchimp Banner | Q2 2024

added by Latoya

Product Icon

Smart Coupons

All-in-one plugin for gift cards, discounts, coupons, store credits, BOGO deals, advanced restrictions, product giveaways, offers, and promotions. Smart Coupons is the original, most complete, best selling and most advanced WooCommerce coupons plugin.

bug / slow query fix

The plug in is using a bad query that almost took our site down.

We run $order->get_coupon_codes() on the orders we have so that we can use the coupon info for other things. But in calling this instance method it seems the WC Smart Coupons plugin runs some other thing that seemingly cause problems in the DB:

SELECT * FROM wp_posts WHERE FIND_IN_SET (ID, (SELECT option_value FROM wp_options WHERE option_name = ‘sc_display_custom_credit_6896_1’)) > 0 GROUP BY ID ORDER BY post_date DESC

That takes forever and runs through N every time, could be replaced with

SELECT distinct * FROM wp_posts WHERE id in (SELECT option_value FROM wp_options WHERE option_name = ‘sc_display_custom_credit_6896_1’) ORDER BY post_date DESC

Which takes 0sec to complete



Current Status


Last updated: March 21, 2024


Log in to comment on this feature request.