Add fee to checkout for all payment gateways

Here’s a quick PHP code for adding a fee to the checkout for each payment or for a certain payment gateway.

Please keep in mind that adding checkout fees to certain payment gateways, such as PayPal, is currently against their Terms of Service, so double-check beforehand. This Snippet must be added into your child theme’s functions.php file.

add_action( 'woocommerce_cart_calculate_fees', 'codeithub_add_checkout_fee' );
  
function codeithub_add_checkout_fee() {

   WC()->cart->add_fee( 'Fee', 7 );
}

Before:

No Checkout Fee

After:

Add Checkout fee

Leave a Reply

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