I recently came across the situation where a client wanted the flat rate shipping method removed if the free shipping method was available in the WooCommerce shipping cart, something that I would have thought would be standard behaviour in WooCommerce. Apparently it isn’t.
No matter a quick Google search and I found just what I wanted https://docs.woothemes.com/document/hide-other-shipping-methods-when-free-shipping-is-available/ . The problem for me was the fact that the client’s website was a purchased Child Theme and since you can’t have a child theme of a child theme, I would have to edit the functions.php file of the child theme to get this function to work. Of course this would make it difficult if an update to the child theme was ever released.
The solution? Make it into a plugin. This would mean that no editing of the child theme’s function.php file was necessary and I would have the added bonus of having a plugin to re use on other projects if need be. You can download the plugin here:
Keep in mind that you have to make sure you clear your WooCommerce cache (WooCommerce → System Status → Tools → WC Transients → Clear transients), as shipping methods are cached.