Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › How to create coupon with multiple discount rules › Reply To: How to create coupon with multiple discount rules

#21565
Soft79
Keymaster

That would need a custom php snippet. Create a 5% discount coupon which excludes discount items and category B items. Add the following snippet to your child theme’s functions.php, replace THE_COUPON_CODE with the actual coupon code.


add_filter('woocommerce_coupon_get_amount', 'custom_tiered_coupon_amount', 10, 2);
function custom_tiered_coupon_amount($amount, $coupon) {
    if (is_admin() && !defined('DOING_AJAX')) return $amount;
    if ($coupon->get_code() !== 'THE_COUPON_CODE') {
        return $amount;
    }
    $cart_total = WC()->cart->get_subtotal();
    if ($cart_total >= 5000) {
        $amount = 20;
    } elseif ($cart_total >= 4000) {
        $amount = 20;
    } elseif ($cart_total >= 3000) {
        $amount = 15;
    } elseif ($cart_total >= 2000) {
        $amount = 10;
    } elseif ($cart_total >= 1000) {
        $amount = 5;
    } else {
        $amount = 0;
    }
    return $amount;
}

That should do the trick. I didn’t test it though.