• Resolved bearcatsandor

    (@bearcatsandor)


    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.

    • This topic was modified 5 years, 11 months ago by bearcatsandor.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi, @bearcatsandor!

    I understand that the 10 sets a priority, but what does the “2” do?

    That is the number of arguments that the function accepts.

    ignore the condition for now, one thing at a time

    That would be an important bit to the puzzle. Please share some detail around the condition, so we’re able to help better.

    Cheers!

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Howdy!

    We haven’t heard back from you in a while, so I’m going to go ahead and mark this thread as resolved. If you have any other questions please start a new thread.

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How Do I Filter out ALL shipping methods conditionally’ is closed to new replies.