Created
July 11, 2013 09:21
-
-
Save kloon/5973943 to your computer and use it in GitHub Desktop.
WooCommerce hide all shipping options when free shipping is available
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 | |
| add_filter( 'woocommerce_available_shipping_methods', 'hide_standard_shipping_when_free_is_available' , 10, 1 ); | |
| function hide_standard_shipping_when_free_is_available( $available_methods ) { | |
| if( isset( $available_methods['free_shipping'] ) ) { | |
| $methods = $available_methods; | |
| foreach( $methods as $key => $method ) { | |
| if ( $key <> 'free_shipping' ) | |
| unset( $available_methods[$key] ); | |
| } | |
| } | |
| return $available_methods; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment