Created
November 1, 2023 06:26
Colorado Woocommerce fee WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Colorado fee | |
/** | |
* Add a .27 surcharge to orders shipping to Colorado | |
* https://www.thathandsomebeardedguy.com/woocommerce-colorado-retail-delivery-fee/ | |
*/ | |
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; | |
} | |
$fee = 0.27; | |
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', $fee , true, ''); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment