I would like to know how I can modify the code so that all transactions have a percentage surcharge and exclude France?
* Add a standard $ value surcharge to all transactions in cart / checkout
*/
add_action( 'woocommerce_cart_calculate_fees','wc_add_surcharge' );
function wc_add_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
$county = array('US');
// change the $fee to set the surcharge to a value to suit
$fee = 1.00;
if ( in_array( WC()->customer->get_shipping_country(), $county ) ) :
$woocommerce->cart->add_fee( 'Surcharge', $fee, true, 'standard' );
endif;
}
I found the code on the woocommerce site
Thank you for your response.
3
Answers
Overload fees are fixed, ideally there should be price tiers
Example from 01€ to 55€ =0.35€ 56 to 150€ = 1.00€ ...
In any case the code works on my site and excludes France.
Something like this based off how I am reading the code at least. Can’t really test it but it seemed simple enaugh.
I got what I wanted by reworking the code, is it gives this:
All that’s left is to change the following country for those they don’t want to put charges on their country!