function wccg_get_random_coupon() {
// Generate unique coupon code
$random_coupon = \'\';
$length = 6;
$charset = \'0123456789\';
$count = strlen( $charset )
while ( $length-- ) {
for ($random_coupon = 0; $random_coupon <= $count; $random_coupon++) {
$random_coupon = implode( \'-\', str_split( strtoupper( $random_coupon ), 6 ) );
// Ensure coupon code is correctly formatted with WC Core filter
$coupon_code = apply_filters( \'woocommerce_coupon_code\', $random_coupon );
// Additional filter that only executes for this plugin, not for other WC Core coupons
$random_code = apply_filters( \'woocommerce_coupon_generator_random_coupon_code\', $coupon_code );
return $random_code;
} }
}
我不知道为什么这行不通,如果有人能帮忙的话,那就太好了。