WooCommerce Percentage Checkout Admin/Handling Fee

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About this Solution

A little warning, unexpected fees at checkout can put some users off and some payment gateways do not allow custom additional fees. Passing on fees and surcharges may not be legal in your location so do check before implementing this code snippet. Adding a percentage amount fee at checkout based on the cart total for handling or administration costs is really easy and appears in the order summary box as an order item. Once the order is paid for, the admin fee is shown in the cart, on the order received thank you page, order editor as a line item, and in all of the post-purchase emails where the order table appears. This particular guide adds a 10% surcharge to the order.

				
					/**
 * Snippet Name:	Add a percentage handling/admin fee to the order
 * Snippet Author:	ecommercehints.com
 */

add_action( 'woocommerce_cart_calculate_fees','ecommercehints_percentage_checkout_fee' );
function ecommercehints_percentage_checkout_fee() {
  global $woocommerce;

	if ( is_admin() && ! defined( 'DOING_AJAX' ) )
		return;

	$percentage = 0.1;// The percentage fee
	$surcharge = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage;	
	$woocommerce->cart->add_fee( 'Admin Fee', $surcharge, true, '' ); // The order item label

}
				
			
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

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

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers