Code to end poverty
1/12/2019 - 5:41 PM

Apply 3% + 0.30 cent fee to total, on the checkout page

/**
 * Apply 3% + 0.30 cent fee to total, on the checkout page
 */
add_action( 'woocommerce_cart_calculate_fees', 'woocommerce_custom_surcharge' );
function woocommerce_custom_surcharge( $cart ) {
    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
        return;

    $percentage = 0.03;
    $fixed_fee  = 0.3;

    $percentage_fee = ( $cart->cart_contents_total + $cart->shipping_total ) * $percentage;
    $surcharge  = $fixed_fee + $percentage_fee;

    $cart->add_fee( 'Processing Fee', $surcharge, true );
}