Code
pkpublic function affiliates_automatic_coupon() {
$code_length = $this->numeric_coupon_code ;
$exclude_alphabets = $this->alphanumeric_coupon_code ;
$exclude_alphabets = explode(',', $exclude_alphabets);
exit();
if ( $this->coupon_code_type == 1 ) {
$random_code = '' ;
$numbers = range( '0' , '9' ) ;
while ( $code_length -- ) {
$random_numbers = array_rand( $numbers ) ;
if(in_array($random_numbers,$exclude_alphabets))
{
$code_length++;
continue;
}
$random_code .= $numbers[ $random_numbers ] ;
}
} else {
$random_code = '' ;
$alphabets = range( 'A' , 'Z' ) ;
$numbers = range( '0' , '9' ) ;
$alpha_numeric = array_merge( $alphabets , $numbers ) ;
while ( $code_length -- ) {
$random_numbers = array_rand( $alpha_numeric ) ;
if(in_array($random_numbers,$exclude_alphabets))
{
$code_length++;
continue;
}
$random_code .= $alpha_numeric[ $random_numbers ] ;
}
}
}
$coupon_code = $this->coupon_code_prefix . $random_code . $this->coupon_code_suffix ;