Blog

Wpexpert blog helps you to be updated with latest web technologies and trends. Find your Web solution here for WordPress , php , eCommerce development.

Hide-flat-rate-shipping-when-free-shipping-is-available
July 22, 2016 Comments Closed

Hide Flat Rate Shipping methods when FREE SHIPPING is available

Posted by:admin onJuly 22, 2016

Hide Flat Rate Shipping methods when FREE SHIPPING is available

This snippet hides Other shipping methods on the cart page , but free_shipping if it’s available and is compatible with Shipping Zones.

Put Below Code in to your theme’s Function.php file

function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
if ( ‘free_shipping’ === $rate->method_id ) {
$free[ $rate_id ] = $rate;
break;
}
}
return ! empty( $free ) ? $free : $rates;
}
add_filter( ‘woocommerce_package_rates’, ‘my_hide_shipping_when_free_is_available’, 100 );

Our Clients

WpExpert's respective happy clients

6
cc
chop
tws
jn
ms
Powered by WpExpert.
Copyrights © 2015 WpExpert.