Skip to content

Instantly share code, notes, and snippets.

@MahdiY
Last active March 16, 2019 13:58
Show Gist options
  • Save MahdiY/180e692c6143d5c753f06e3722990797 to your computer and use it in GitHub Desktop.
Save MahdiY/180e692c6143d5c753f06e3722990797 to your computer and use it in GitHub Desktop.
remove free shipping, when coupon applied on cart. woocommerce
<?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