Last active
July 2, 2020 05:26
-
-
Save rynaldos-zz/a1d018c11ca12b94d9af03c4099f0f32 to your computer and use it in GitHub Desktop.
WooCommerce (hide free shipping when per-product is available)
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
function hide_free_when_pp_method_available( $rates ) { | |
$pp = array(); | |
foreach ( $rates as $rate_id => $rate ) { | |
if ( 'per_product' === $rate->method_id ) { | |
$pp[ $rate_id ] = $rate; | |
break; | |
} | |
} | |
return ! empty( $pp ) ? $pp: $rates; | |
} | |
add_filter( 'woocommerce_package_rates', 'hide_free_when_pp_method_available', 100 ); | |
// Did this help? Donate me some BTC: 1BEsm8VMkYhSFJ92cvUYwxCtsfsB2rBfiG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment