Last active
March 16, 2019 13:58
-
-
Save MahdiY/180e692c6143d5c753f06e3722990797 to your computer and use it in GitHub Desktop.
remove free shipping, when coupon applied on cart. woocommerce
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
<?php | |
add_filter( 'woocommerce_package_rates', 'woocommerce_package_rates_remove_free', 1000 ); | |
function woocommerce_package_rates_remove_free( $rates ) { | |
// MahdiY.IR | |
foreach ( $rates as $rate_id => $rate ) | |
if ( 'free_shipping' === $rate->method_id | |
&& count( wc()->cart->get_applied_coupons() ) ) { | |
unset( $rates[ $rate_id ] ); | |
} | |
return $rates; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment