How to Make WPCodeBox Full-Width by Hi...
This WordPress snippet effectively hides the WordPress admin menu, allowing WPCodeBox...

WPCodeBox
484
Enhance your WooCommerce store with this code snippet to easily add a surcharge percentage to all orders. This flexible WordPress solution allows you to apply a 5% surcharge to customer carts, with the ability to customize the percentage as needed, offering greater control over your e-commerce pricing.
/**
* Author: WP Turned UP
* Author URI: https://wpturnedup.com
*/
// ADD SURCHARGE % TO ALL WOOCOMMERCE ORDERS
add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
function woocommerce_custom_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
$percentage = 0.05;
$surcharge = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage;
$woocommerce->cart->add_fee( 'Surcharge', $surcharge, true, '' );
}





