Website Building » WooCommerce » How Do I Add Cash on Delivery Charges in WooCommerce?

How Do I Add Cash on Delivery Charges in WooCommerce?

Last updated on October 1, 2022 @ 5:03 pm

Adding cash on delivery charges in WooCommerce is easy. You simply need to go to your WooCommerce settings page and add the following code to your shipping options:

add_action( ‘woocommerce_cart_calculate_fees’, ‘woo_add_cod_fee’ );

function woo_add_cod_fee() {

global $woocommerce;

if ( is_checkout() && !WC()->cart->needs_shipping() ) {

// Only add the fee if cart does not need shipping. You can also add conditions like “if cart has X item” etc. This is just an example. You can add as many conditions as you want.

$woocommerce->cart->add_fee( ‘Cash on Delivery Fee’, 2 ); // Add a fixed fee of Rs.2 for cash on delivery. You can change this amount as you like.
} }

PRO TIP: Please be aware that adding cash on delivery charges in WooCommerce can be risky. If you are not careful, you could end up overcharging your customers or worse, losing money. We recommend that you consult with a professional before adding any charges to your WooCommerce store.

Conclusion:

Adding cash on delivery charges in WooCommerce is easy. You simply need to go to your WooCommerce settings page and add the following code to your shipping options.

Dale Leydon

Dale Leydon

Sysadmin turned Javascript developer. Owner of 20+ apps graveyard, and a couple of successful ones.