# Spend More, Save More Discount Tiers

> Gives a bigger percentage discount as the cart subtotal grows, for example 5% over 100 and 10% over 200, and tells shoppers how close they are to the next tier.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, discounts, tiers, conversion
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-spend-tier-discount/

## Code

```php
$wpide_spend_tiers = array( 100 => 5, 200 => 10, 400 => 15 ); // Subtotal => percent off.

$wpide_spend_tier = function ( $subtotal ) use ( $wpide_spend_tiers ) {
    $current = array( 0, 0 );
    $next    = null;
    ksort( $wpide_spend_tiers );

    foreach ( $wpide_spend_tiers as $min => $off ) {
        if ( $subtotal >= $min ) {
            $current = array( $min, $off );
        } elseif ( null === $next ) {
            $next = array( $min, $off );
        }
    }

    return array( $current, $next );
};

add_action( 'woocommerce_cart_calculate_fees', function ( $cart ) use ( $wpide_spend_tier ) {
    if ( is_admin() && ! wp_doing_ajax() ) {
        return;
    }

    list( $current ) = $wpide_spend_tier( (float) $cart->get_subtotal() );

    if ( $current[1] > 0 ) {
        $cart->add_fee( sprintf( 'Spend discount (%d%%)', $current[1] ), -$cart->get_subtotal() * $current[1] / 100, true );
    }
} );

add_action( 'woocommerce_before_cart', function () use ( $wpide_spend_tier ) {
    $subtotal       = (float) WC()->cart->get_subtotal();
    list( , $next ) = $wpide_spend_tier( $subtotal );

    if ( $next ) {
        wc_print_notice( sprintf( 'Spend %1$s more to save %2$d%% on your order.', wc_price( $next[0] - $subtotal ), $next[1] ), 'notice' );
    }
} );
```

## Notes

Only the highest tier reached applies, and the cart notice disappears once the top tier is reached.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Spend More, Save More Discount Tiers" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
