Skip to content

Instantly share code, notes, and snippets.

@WillBrubaker
Last active April 9, 2024 18:44
Show Gist options
  • Save WillBrubaker/4aee2e5762bc424357409461d95231d5 to your computer and use it in GitHub Desktop.
Save WillBrubaker/4aee2e5762bc424357409461d95231d5 to your computer and use it in GitHub Desktop.
WooCommerce Colorado Retail Delivery Fee
// not sure what to do with this code snippet? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/
// BTC Donations to: bc1q0cwjuxxqqmwnxxc0m2xkkyf4kes9e0gejc9u0l
/**
* Add a .27 surcharge to orders shipping to Colorado
*/
add_action('woocommerce_cart_calculate_fees', 'handsome_bearded_guy_custom_surcharge');
function handsome_bearded_guy_custom_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' )) {
return;
}
if ( $woocommerce->cart->needs_shipping() && 'CO' === $woocommerce->customer->get_shipping_state() && 'US' === $woocommerce->customer->get_shipping_country() ) {
$woocommerce->cart->add_fee('CO Retail Delivery Fee', .27, true, '');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment