Created
June 14, 2018 10:26
-
-
Save stuartduff/d6d57664b809e5a7cd05449e53511c2f to your computer and use it in GitHub Desktop.
Remove free shipping in WooCommerce if a coupon is applied at checkout
This file contains hidden or 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
add_filter( 'woocommerce_shipping_packages', function( $packages ) { | |
$applied_coupons = WC()->session->get( 'applied_coupons', array() ); | |
if ( ! empty( $applied_coupons ) ) { | |
$free_shipping_id = 'free_shipping:2'; | |
unset($packages[0]['rates'][ $free_shipping_id ]); | |
} | |
return $packages; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment