# Small Order Fee

> Adds a handling fee to orders below a set subtotal, which helps cover packing costs on very small orders.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, fees, cart, checkout
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-small-order-fee/

## Code

```php
add_action( 'woocommerce_cart_calculate_fees', function ( $cart ) {
    $threshold = 20;                  // Orders below this subtotal pay the fee.
    $fee       = 3.50;                // Fee amount.
    $label     = 'Small order fee';   // Name shown in the totals.
    $taxable   = false;               // Whether tax applies to the fee.

    if ( is_admin() && ! wp_doing_ajax() ) {
        return;
    }

    if ( $cart->get_subtotal() > 0 && $cart->get_subtotal() < $threshold ) {
        $cart->add_fee( $label, $fee, $taxable );
    }
} );
```

## Notes

Set $threshold, $fee and $taxable. The fee name appears in the cart totals and on the order.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Small Order Fee" 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/
