Why Add a COD Fee?
Cash on Delivery (COD) is convenient for customers, but it often increases risk and handling costs for store owners.
By adding a small COD fee (e.g., $2 or 2%), you can:
- Recover extra payment handling costs
- Encourage prepaid orders
- Still provide COD as an option without losing money
PHP Snippet: Add COD Fee
/**
* @snippet Add COD Fee in WooCommerce Checkout
* @author Spiderwares
* @compatible WooCommerce 8+
*/
add_action( 'woocommerce_cart_calculate_fees', 'spiderwares_cod_fee' );
function spiderwares_cod_fee() {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;
$chosen_gateway = WC()->session->get( 'chosen_payment_method' );
if ( $chosen_gateway === 'cod' ) {
$fee = 2; // Flat fee, can change to percentage if needed
WC()->cart->add_fee( __( 'Cash on Delivery Fee', 'woocommerce' ), $fee );
}
}
Result
- If a customer selects Cash on Delivery, WooCommerce automatically adds a “COD Fee” to the order total.
- If they choose another payment method, no extra fee is applied.
Pro Tips
- Change
$fee = 2;
to match your business needs. - For a percentage fee, calculate it like this:
$fee = WC()->cart->subtotal * 0.02; // 2% COD fee
- Style the fee row via CSS if you want it highlighted.
Benefits
- Recovers COD processing costs
- Encourages digital payments
- Works seamlessly with existing WooCommerce checkout
A small tweak like this gives you more control over payment handling costs while still offering customers the convenience of COD.