Back to Top

Hide other shipping methods if free shipping is available woocommerce

Updated 2 March 2017

This article will demonstrate that how you can disable other available shipping methods if free shipping is available by using the filters in woocommerce
below is the useful code snippet :-

add_filter( 'woocommerce_package_rates', 'hide_available_shipping_method', 100 );

function hide_available_shipping_method( $rates ) {
	$free = array();
	foreach ( $rates as $rate_id => $rate ) {
		if ( 'free_shipping' === $rate->method_id ) {
			$free[ $rate_id ] = $rate;
			break;
		}
	}
        // this will return only free shipping method
	return ! empty( $free ) ? $free : $rates;
}

If there is something that is not understandable by this blog then do comment below. We will surely assist on that. cheers

Searching for an experienced
Woocommerce Company ?
Find out More
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home