0

How can I apply all coupons codes automatically in the checkout page?


function apply_coupon_product() {
    $coupon_code = $coupon->get_code();
if ( WC()->cart->has_discount( $coupon_code ) ) {
        return;
    }
    WC()->cart->apply_coupon( $coupon_code );
}

if user have 1 coupon then it will apply 1 if user have more than 1 coupons then apply all coupons in the cart/checkout page. any help please?
Asher
  • 131
  • 3
  • 10
  • 1
    https://stackoverflow.com/questions/62230388/creating-a-list-of-available-woocommerce-coupon-codes-and-display-anywhere-using https://stackoverflow.com/questions/42979138/how-woocommerce-coupons-are-stored-in-database/42997287#42997287 – Snuffy Oct 11 '22 at 14:27
  • @MartinMirchev is it possible to get coupon code which is allotted to customer email id ?? – Asher Oct 13 '22 at 12:09
  • u can get it but wont apply since other events will check if you can assign coupon to an unallowed email. – Snuffy Oct 19 '22 at 10:34

0 Answers0