Product Icon

Smart Coupons for WooCommerce

Boost sales and customer loyalty. Create advanced discounts, sell gift cards, set BOGO deals, give store credits, and all types of rule based dynamic discounts with this all-in-one Smart Coupons plugin for WooCommerce.

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

Author

oystesan

Current Status

Open

Last updated: March 21, 2024

0 comments

Log in to comment on this feature request.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.