Created
February 13, 2021 00:58
-
-
Save MarceloGlez/429b605309587c3a48fa6e1491439b7d to your computer and use it in GitHub Desktop.
Ocultar otros métodos de envío cuando hay envío gratis en 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
/*Ocultar otros metodos de envio cuando hay envio gratis*/ | |
add_filter( 'woocommerce_package_rates', 'bbloomer_unset_shipping_when_free_is_available_all_zones', 10, 2 ); | |
function bbloomer_unset_shipping_when_free_is_available_all_zones( $rates, $package ) { | |
$all_free_rates = array(); | |
foreach ( $rates as $rate_id => $rate ) { | |
if ( 'free_shipping' === $rate->method_id ) { | |
$all_free_rates[ $rate_id ] = $rate; | |
break; | |
} | |
} | |
if ( empty( $all_free_rates )) { | |
return $rates; | |
} else { | |
return $all_free_rates; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment