How to Add Handling Fee to WooCommerce Checkout

Now Reading
How to Add Handling Fee to WooCommerce Checkout

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.