Plugin’s shipping methods does not show when:
-
Plugin’s shipping methods does not show When this snippet
“Hide other shipping methods when “Free Shipping” is available” is active
as documented in this page:https://docs.woocommerce.com/document/hide-other-shipping-methods-when-free-shipping-is-available/
/**
* Hide shipping rates when free shipping is available, but keep “Local pickup”
* Updated to support WooCommerce 2.6 Shipping Zones
*/function hide_shipping_when_free_is_available( $rates, $package ) {
$new_rates = array();
foreach ( $rates as $rate_id => $rate ) {
// Only modify rates if free_shipping is present.
if ( ‘free_shipping’ === $rate->method_id ) {
$new_rates[ $rate_id ] = $rate;
break;
}
}if ( ! empty( $new_rates ) ) {
//Save local pickup if it’s present.
foreach ( $rates as $rate_id => $rate ) {
if (‘local_pickup’ === $rate->method_id ) {
$new_rates[ $rate_id ] = $rate;
break;
}
}
return $new_rates;
}return $rates;
}add_filter( ‘woocommerce_package_rates’, ‘hide_shipping_when_free_is_available’, 10, 2 );
I have set in amount 0.00 and the shipping method is not showing
(I want to have to 2 free shipping options)
- The topic ‘Plugin’s shipping methods does not show when:’ is closed to new replies.