Created
August 27, 2015 09:02
-
-
Save mikejolley/239a298e43ea7788425d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
/** | |
* Hide Free Shipping for some states | |
*/ | |
add_filter( 'woocommerce_package_rates', 'hide_all_shipping_when_free_is_available' , 10, 2 ); | |
function hide_all_shipping_when_free_is_available( $rates, $package ) { | |
$excluded_states = array( 'AK', 'HI', 'GU', 'PR' ); | |
if( isset( $rates['free_shipping'] ) AND in_array( WC()->customer->get_shipping_state(), $excluded_states ) ) { | |
unset( $rates['free_shipping'] ); | |
} | |
return $rates; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment