Skip to content

Instantly share code, notes, and snippets.

@rynaldos-zz
Last active September 5, 2017 17:10
Show Gist options
  • Save rynaldos-zz/e46aa2e2f54a0b450ba1bab9797001a8 to your computer and use it in GitHub Desktop.
Save rynaldos-zz/e46aa2e2f54a0b450ba1bab9797001a8 to your computer and use it in GitHub Desktop.
[WooCommerce] Add a standard $ value surcharge to all transactions
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment