Customizing coupon codes
-
Is there a better way to customize the coupon codes?
I’m currently using:add_filter('woocommerce_coupon_code','robert_get_random_coupon'); function robert_get_random_coupon($arg) { if (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,4)[3]['function']!=='wccg_get_random_coupon') return $arg; // Generate unique coupon code $random_coupon = 'xxx-'; $length = 7; $charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $count = strlen( $charset ); while ( $length-- ) { $random_coupon .= $charset[ mt_rand( 0, $count-1 ) ]; } return $random_coupon; }
Is this plugin on github/etc/…?
I can offer a few small changes in the code to become more customizing friendly ??
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Customizing coupon codes’ is closed to new replies.