Flat Handling Fee on Shipped Orders
Adds a fixed packing and handling charge to every order that needs shipping, while downloads and services stay fee-free.
Opens WPIDE on
Code
$wpide_handling = array(
'amount' => 1.95, // Fee amount.
'label' => 'Packing & handling', // Line label.
'taxable' => true,
);
add_action( 'woocommerce_cart_calculate_fees', function ( $cart ) use ( $wpide_handling ) {
if ( ( is_admin() && ! wp_doing_ajax() ) || ! $cart->needs_shipping() ) {
return;
}
$cart->add_fee( $wpide_handling['label'], $wpide_handling['amount'], $wpide_handling['taxable'] );
} );
Notes
Set $wpide_handling['taxable'] to match how your accountant treats handling charges.
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.