Last active
December 16, 2015 09:59
-
-
Save ChromeOrange/5416643 to your computer and use it in GitHub Desktop.
Hide free shipping if shipping state for WooCommerce 2
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
add_filter( 'woocommerce_package_rates', 'hide_standard_shipping_in_state' , 10, 2 ); | |
/** | |
* Hide free shipping if shipping state is AK, AL, AR, HI, MA, MS, PA, or UT | |
* | |
* @param array $available_methods | |
*/ | |
function hide_standard_shipping_in_state( $rates, $package ) { | |
$excluded_states = array( 'AK','AL','AR','HI','MA','MS','PA','UT' ); | |
if( isset( $rates['free_shipping'] ) AND in_array( WC()->customer->get_shipping_state(), $excluded_states ) ) { | |
// remove free shipping option | |
unset( $rates['free_shipping'] ); | |
} | |
return $rates; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Let me elaborate, I used this code during a pretty stressful time, and can't remember where I put it! It is currently working, but can't find it anywhere? I am using the storefront theme.. Thanks!