woocommerce hide shipping method if free is available php

Solutions on MaxInterview for woocommerce hide shipping method if free is available php by the best coders in the world

showing results for - "woocommerce hide shipping method if free is available php"
Héloïse
17 Mar 2016
1/**
2 * @snippet       Hide one shipping option in one zone when Free Shipping is available
3 * @how-to        Get CustomizeWoo.com FREE
4 * @author        Rodolfo Melogli
5 * @compatible    WooCommerce 3.6.3
6 * @donate $9     https://businessbloomer.com/bloomer-armada/
7 */
8  
9add_filter( 'woocommerce_package_rates', 'bbloomer_unset_shipping_when_free_is_available_in_zone', 10, 2 );
10   
11function bbloomer_unset_shipping_when_free_is_available_in_zone( $rates, $package ) {
12      
13// Only unset rates if free_shipping is available
14if ( isset( $rates['free_shipping:8'] ) ) {
15     unset( $rates['flat_rate:1'] );
16}     
17     
18return $rates;
19  
20}
21