How Do I Filter out ALL shipping methods conditionally
-
I know this is easy but my php-fu is weak today and i’m struggling. I want to conditionally remove all shipping options from https://psp.felinesoulsystems.com/checkout/ and the shopping cart. (ignore the condition for now, one thing at a time). I’ve been playing with various sources of code to do this. Extrapolating from https://www.xadapter.com/woocommerce-shipping-hide-shipping-methods-based-destination-country/ I’ve got this:
function remove_all_shipping_methods ($available_shipping_methods) {
foreach ($available_shipping_methods as $shipping_method => $value) {
unset($available_shipping_methods[$shipping_method]);
}
return $available_shipping_methods;
}
add_filter(‘woocommerce_package_rates’, ‘remove_all_shipping_methods’, 10, 2);
I see “10, 2” all over the place. I understand that the 10 sets a priority, but what does the “2” do?
?
If i save this, add a product to the cart, the shipping options are still in the cart and in the checkout. This code seems to do nothing when placed in my functions.php.
?
Any help is appreciated.
The page I need help with: [log in to see the link]
- The topic ‘How Do I Filter out ALL shipping methods conditionally’ is closed to new replies.