Skip to content

Instantly share code, notes, and snippets.

@rynaldos-zz
Last active July 2, 2020 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rynaldos-zz/a1d018c11ca12b94d9af03c4099f0f32 to your computer and use it in GitHub Desktop.
Save rynaldos-zz/a1d018c11ca12b94d9af03c4099f0f32 to your computer and use it in GitHub Desktop.
WooCommerce (hide free shipping when per-product is available)
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