Knowledgebase

How to set up Cash on Delivery with an extra fee in WooCommerce

Cash on delivery (COD) is still the most popular way to pay for online orders in Egypt. This guide shows how to enable Cash on Delivery in WooCommerce, limit it to certain shipping methods, and add an extra COD fee that appears automatically when the customer picks it.

Step 1: Enable Cash on Delivery

  1. Go to WooCommerce → Settings → Payments.
  2. Turn on Cash on delivery and click Manage.
  3. Set the Title the customer sees, for example "Cash on delivery".
  4. Write a short Description, for example "Pay in cash when the courier delivers your order."
  5. Use Instructions for the text shown on the thank-you page and in emails, such as "Please prepare the exact amount."
  6. Save changes.

Step 2: Limit COD to the right shipping methods

In the same screen, Enable for shipping methods lets you choose where COD is allowed. For example, allow it for your flat-rate courier zones inside Egypt, but not for international shipping. Leave it empty to allow COD for all methods. If you set prices per governorate, see How to set shipping prices by governorate in WooCommerce (Egypt).

The option Accept for virtual orders controls whether COD appears for orders with only virtual products (no shipping). For most stores it should be off.

Step 3: Add a COD fee

WooCommerce has no built-in COD fee field, so you have two options.

Option A: a plugin

Search Plugins → Add New for "payment gateway based fees" or "cash on delivery fee". Pick a well-maintained plugin with recent updates and good reviews, and check that it supports the checkout type you use (block checkout or classic). These plugins let you set a fixed or percentage fee per payment method without code.

Option B: a small code snippet

If your checkout page uses the classic [woocommerce_checkout] shortcode, you can add this snippet with the Code Snippets plugin or in a child theme's functions.php. Take a backup first.

add_action( 'woocommerce_cart_calculate_fees', function ( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return;
}
if ( WC()->session && 'cod' === WC()->session->get( 'chosen_payment_method' ) ) {
// 20 is only an example amount, change it to your own fee
$cart->add_fee( 'Cash on delivery fee', 20, false );
}
} );
add_action( 'wp_footer', function () {
if ( is_checkout() ) {
echo '<script>jQuery(function($){$("form.checkout").on("change","input[name=payment_method]",function(){$("body").trigger("update_checkout");});});</script>';
}
} );

The first part adds the fee when COD is selected. The second part refreshes the order total when the customer switches between payment methods. The value false means the fee is not taxed; change it to true if your accountant says it should be.

Block checkout note: new WooCommerce stores use the block-based Checkout page. The refresh script above only works with the classic checkout. With block checkout, use a plugin that clearly says it supports Cart and Checkout blocks.

Step 4: Test it

  1. Add a product to the cart and go to checkout.
  2. Switch between COD and another method and check that the fee appears and disappears and the total updates.
  3. Place a test order and confirm the fee shows in the order, the admin email and the customer email.

Tips to reduce fake COD orders

  • Make the phone field required and confirm large orders by phone or WhatsApp before shipping.
  • Set a maximum order value for COD if your courier limits cash collection.
  • Offer a small discount for paying online instead of a high COD fee; customers react better to a reward than to a penalty.
  • Track refused deliveries in How to manage orders in WooCommerce and block repeat offenders.

Common problems

  • COD does not show at checkout: the chosen shipping method is not in "Enable for shipping methods", or the cart has only virtual products.
  • The fee only appears after a page reload: the refresh script is missing, or your checkout is block-based.
  • White screen after adding code: a syntax error. Remove the snippet through File Manager or deactivate the Code Snippets plugin, then check the code again.

Frequently asked questions

Is a COD fee legal in Egypt?

Many stores charge one, but show it clearly before the customer confirms the order. For any legal or tax question, check with your accountant.

Can I make the fee a percentage of the order?

Yes. Most fee plugins support percentages. In code, replace 20 with something like $cart->get_subtotal() * 0.02.

Will the fee be sent to my courier automatically?

The fee is part of the order total. Whether it reaches the courier depends on how you send orders to them. See our guide on connecting WooCommerce to shipping companies.

Need help? Open a support ticket or message us on WhatsApp +20 127 113 3655.

  • woocommerce, cash on delivery, cod, cod fee, checkout, egypt

Was this answer helpful?

0 Users Found This Useful