Skip to content

Instantly share code, notes, and snippets.

@sonnetmia
Forked from claudiosanches/functions.php
Created June 2, 2016 05:24
Show Gist options
  • Save sonnetmia/57a6a1ce4b98e439db9b2b7b4b205570 to your computer and use it in GitHub Desktop.
Save sonnetmia/57a6a1ce4b98e439db9b2b7b4b205570 to your computer and use it in GitHub Desktop.
WooCommerce - Hide free shipping if others methods exists
<?php
/**
* Hide free shipping if others methods exists.
*
* @param array $available_methods
*/
function custom_shipping_rules( $available_methods ) {
if ( isset( $available_methods['PAC'] ) || isset( $available_methods['SEDEX'] ) ) {
unset( $available_methods['free_shipping'] );
}
return $available_methods;
}
add_filter( 'woocommerce_available_shipping_methods', 'custom_shipping_rules', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment