How to Add Handling Fee to WooCommerce Checkout

WooCommerce excelling eCommerce

WooCommerce is a free e-commerce plugin for WordPress. Built by the team at WooThemes, WooCommerce enables anyone to quickly and easily set up an online store with WordPress.

One of my favorite things about WooCommere is its extensive list of hooks and filters. This makes the plugin easy to customize for almost any theme without needing to edit core plugin files.

Let’s say you want to add a handling charge to every order. Out of the box, WooCommerce doesn’t have a way to do this. But it does have an action that allows you to add fees to the order total before the customer submits the order.

Add WooCommerce Handling Fee

Here is the function you would need to add a $5.00 handling charge to each order. Place it in your theme’s functions.php file, or in your own custom plugin.

add_action( 'woocommerce_cart_calculate_fees','endo_handling_fee' );
function endo_handling_fee() {
     global $woocommerce;
     if ( is_admin() && ! defined( 'DOING_AJAX' ) )
     $fee = 5.00;
     $woocommerce->cart->add_fee( 'Handling', $fee, true, 'standard' );

First, trigger the function endo_handling_fee whenever the woocommerce_cart_calculate_fees action is fired. Inside the function, grab the order data from the global variable $woocommerce so you can append the handling fee to the order table. After checking to make sure a customer is the one placing the order, define the amount of the fee.

Using the add_fee method, add the title of the charge (in this case “Handling”) and the fee amount to the order table on the checkout screen.

WooCommerce Order Table with Handling Fee

Now every order will have a handling fee of $5.00 added to the order total.

Learn more ways to add fees on the WooCommerce documentation site.

Need Help with WooCommerce?

We offer web development services for WooCommerce and can build a custom WooCommerce extention that meets your exact needs.

Get help customizing WooCommerce!

38 thoughts on “How to Add Handling Fee to WooCommerce Checkout

  1. This works perfectly, but what if I don’t want this to be applied to, let’s say, gift cards, where there’s really no handling?

  2. Worked great but what if I wanted this fee (in my case $12) to be added with every item ordered? My client only sells cases of things so 2 cases, $24? THANKS!

    1. Hi Courtney,
      I need to do the same thing. Any luck adding the fee per item rather than per order?

      If not, I will try to let you know if I find another solution on my own.

  3. Can i add a Fee to specific checkout option?
    I want to add a fee only on a “Cash on Delivery” payment method. Is this possible?
    Im sorry for my bad english

  4. Hy,

    It works perfectly.

    If $free=1, then the subtotals add it again.

    My question is, how can I solve it only to add fee to the product once more, with a particular attribute (“rent”).
    This would be a security deposit.


    1. Hi Jeremy! The function still works GREAT to add a % fee.

      However, we need to exclude the fee value from the tax calculation. Any advice?

      Thanks a lot.

  5. Is there a way to conditionally do this with 2 radio buttons on the check out screen. One that adds the surcharge and the other does not? I’ve added 2 radio buttons via a woocommerce_form_field_radio function and add_action( ‘woocommerce_before_order_notes’, ‘hear_about_us_field’, 10 ); What I can’t find is the hook I need to add to the radio buttons (AJAX?) to get it to add the surcharge or not based on the radio button state.

  6. how can i add the handling fee on user roles (wholesaler only) ?
    and i can use % instead of fixed amount ?


  7. Hi there,
    Thanks so much for this code! How would I be able to add a handling fee only if the shipping method is UPS. Any help is much appreciated.

  8. Hi jeremy,
    This is really nice post.
    But i have query, I need to update fee price on certain condition on checkout page. Can you help me out i am really stuck.


  9. Hi,

    This is great and working perfectly on my cart.

    Only question is how can I apply it to the Customer Payment Page (when I manually create an order and send customer payment page it skips the cart therefore isn’t adding it onto the checkout,) Any ideas?

    Many thanks,

  10. Please help!

    I’m trying to add an handling fee only applied to my physical products for which the category slugs are ‘printed’ and ‘imprimee’. I tried many things but can’t figure out how to correctly add the product category condition to the php code:

    add_action( ‘woocommerce_cart_calculate_fees’,’endo_handling_fee’ );
    function endo_handling_fee() {
    global $woocommerce;

    if ( is_admin() && ! defined( ‘DOING_AJAX’ ))

    $fee = 3.00;
    $woocommerce->cart->add_fee( ‘Manutention’, $fee, true, ‘standard’ );

  11. I love this, but is there a way to modify the code Jeremy wrote so it is a fee per Shipping Container? We want to charge $5.00 per Box. These are special, insulated boxes for steaks which cost a lot. If someone orders 20 steaks, they go into 2 boxes (we calculate that already on the fly). So we would show $10 for Handling. We can’t add this to the Shipping because we offer free shipping. thanks

  12. I want to achieve like this. I have almost 3000 products in woocommerce where I want to assign additional charge to the cart according to product attribute.

    I have a product attribute named “Size” and this attribute has values like 200 ml, 250ml, 300 ml, 350ml etc..

    Now My question is that how can I assign additional fixed product fee according to product attribute value ?

    Like If the product attribute size is 250ml then I want to add an additional surcharge to that product cart of 10 $ or like that..

    Any code hint ? Or full code… ? We need to select the attribute named “Size” where value is 200 ml 250 ml or like that and then assign the value of $ .

    Can you give me a sample code to do it please

  13. Hi,

    Anyone know how to do the same but with a checkbox ?
    Checking the checkbox add the fee to the total.

  14. Hi

    Is there a way to charge a extra fee based off the subtotal in shopping cart?
    i don’t make any profit with orders under $20

    For orders under $20 there will be a $5 handling fee added

  15. Hi, I know that this post is so old but I have a question to you. I used your code and Work fine with a fixed value, but I need that this value is variable:

    add_action( ‘woocommerce_cart_calculate_fees’,’wc_add_surcharge’ );
    function wc_add_surcharge() {
    global $woocommerce;

    if ( is_admin() && ! defined( ‘DOING_AJAX’ ) )

    $county = array(‘CO’);
    // change the $fee to set the surcharge to a value to suit
    $fee = $_GET[“costo_envio”];

    if ( in_array( WC()->customer->get_shipping_country(), $county ) ) :
    $woocommerce->cart->add_fee( ‘Valor de envío’, $fee, true, ‘standard’ );

    Youy can see that the value to $fee is a GET. In the checkout page work fine, but when I load the pay page this value is lose.

    You have and idea for this?

  16. Hi, I’ve just used this code to add a handling fee to my shipping on Woocommerce, happy I can achieve this with your help and without another bloody plugin.


  17. Hi Jeremy.. This was SUPER helpful.
    I had an odd one.

    We needed to be able to charge shipping for specific product(s), but allow the Free Shipping function to stay in place if they purchased over a certain amount.

    So, regardless if they hit the free shipping minimum, we still needed to charge for shipping of certain products were in the shopping cart.

    We did this by giving those products their own shipping class. Then we used your code above, added a check for the class in the cart. Then multiplied the quantity of items with that class by our set fee.

    Thanks again for the head start. Truly could not come up with another way to solve this one.

    add_action( ‘woocommerce_cart_calculate_fees’,’madcowweb_custom_kaput_shipping’ );
    function madcowweb_custom_kaput_shipping() {
    global $woocommerce;
    $shipping_class_target = 2108; // shipping class ID
    $fee = 0;
    foreach ( WC()->cart->get_cart_contents() as $key => $values ) {
    if ( $values[ ‘data’ ]->get_shipping_class_id() == $shipping_class_target ) {
    $fee += 15 * $values[‘quantity’];

    if ( $fee ) {
    $woocommerce->cart->add_fee( ‘Handling’, $fee, true, ‘standard’ );

Leave a Reply

Your email address will not be published. Required fields are marked *