Small Order Fee
Adds a handling fee to orders below a set subtotal, which helps cover packing costs on very small orders.
Opens WPIDE on
Code
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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.