WooCommerce shipping methods filter
-
Hello,
My current filter (see below) to unset shipping methods is not working in the current version of WooCommerce. I was wondering whether someone could help me out, since I am not really familiar with Php.
With kind regards,
Robin
// add filter and function to hide method
add_filter( ‘woocommerce_available_shipping_methods’, ‘custom_shipping_methods’ , 10, 1 );
function custom_shipping_methods( $available_methods ){
if ( cart_has_product_with_orange_cats() ) {
foreach($available_methods as $key => $method){
if($key == ‘local_pickup’){
continue;
}unset($available_methods[$key]);
}
// remove the rate you want
}// return the available methods without the one you unset.
return $available_methods;
}
- The topic ‘WooCommerce shipping methods filter’ is closed to new replies.