Created
September 12, 2012 18:04
-
-
Save maxrice/3708681 to your computer and use it in GitHub Desktop.
Hide default flat rate shipping method when free shipping is available
This file contains 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
// Hide standard shipping option when free shipping is available | |
add_filter( 'woocommerce_available_shipping_methods', 'hide_standard_shipping_when_free_is_available' , 10, 1 ); | |
/** | |
* Hide Standard Shipping option when free shipping is available | |
* | |
* @param array $available_methods | |
*/ | |
function hide_standard_shipping_when_free_is_available( $available_methods ) { | |
if( isset( $available_methods['free_shipping'] ) AND isset( $available_methods['flat_rate'] ) ) { | |
// remove standard shipping option | |
unset( $available_methods['flat_rate'] ); | |
} | |
return $available_methods; | |
} |
i put the code in my child theme functions and disabled shipping calculator in woocommerce settings and yet the drop down menu of countries is there on the cart page along with shipping options. This has been a three hour problem that remains unresolved despite the amount of plugins and php I put in. H E L P
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's another gist (https://gist.github.com/mikejolley/11171530) where some discussed about this issue. I cannot believe I don't understand why this method doesn't affect my ecommerce. I need only local_pickup and free_shipping. I need to hide flat_rate even it exists and should stay there. How can I fix this? I'd be glad to receive your help. :)