We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2c9940e commit 5b53925Copy full SHA for 5b53925
includes/Generator/Coupon.php
@@ -151,6 +151,9 @@ public static function batch( $amount, array $args = array() ) {
151
* @return \WC_Coupon|false Coupon object or false if none available.
152
*/
153
public static function get_random() {
154
+ // Note: Using posts_per_page=-1 loads all coupons into memory for random selection.
155
+ // For stores with thousands of coupons, consider using direct SQL with RAND() for better performance.
156
+ // This approach was chosen for consistency with WordPress APIs and to avoid raw SQL queries.
157
$coupon_ids = get_posts(
158
array(
159
'post_type' => 'shop_coupon',
0 commit comments