How to create a smart coupon in PHP
-
I was wondering if i could set the variables of a smart coupon via PHP.
For example i have this in my code already:
$coupon_code = substr($author_email,0,4).'4LUCAS'.random_int( 1000, 9999 ); // OR generate_coupon_code(); $discount_type = 'fixed_cart'; // type can be 'fixed_cart', 'percent' or 'fixed_product', defaults to 'fixed_cart' $coupon_amount = '4000'; // Amount $coupon->set_code( $coupon_code ); $coupon->set_discount_type( $discount_type ); $coupon->set_amount( $coupon_amount ); $coupon->set_individual_use( true ); $coupon->set_usage_limit( 1 ); $coupon->set_email_restrictions( array( $author_email ) ); $coupon->set_date_expires( strtotime( '+60 days' ) ); $coupon->set_free_shipping( false );
Is there a way i can set other variables, like:
- Giveaway product
- Automatically apply
- Display in checkout/My Account
- Category of the products needed to be applied
- And so many other variables that smart coupons give to the woo coupons
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘How to create a smart coupon in PHP’ is closed to new replies.