Skip to content
Advertisement

Disable only flat rate shipping method when free shipping is available in Woocommerce

I am using Hide specifics Flat Rates when Free Shipping is available in WooCommerce 3 lightly changed answer code to hide all shipping methods except one. The only method I want showing is a rate from the “Woocommerce Advanced Shipping” plugin.

I am using the correct rate ID etc…

Everything works fine except when a customer tries to click that shipping method, it won’t stay selected. It just jumps back to free shipping.

I have tried debugging and also tried the code with a native woocommerce flat rate ID and it showed up/able to select it just fine.

JavaScript

ID I want to Keep Shown: “2588” (Custom Shipping Rate From Plugin)

How can I disable the Flat rate shipping method when free shipping is available o and keep a custom shipping rate (from a plugin)?

Advertisement

Answer

As you have 3 shipping methods, 1 free shipping, 1 flat rate and 1 custom ‘2588’, it’s possible to hide the flat rate shipping method when free shipping is available instead:

JavaScript

Code goes in functions.php file of your active child theme (or active theme). Tested and works.

Refresh the shipping caches:

  1. This code is already saved on your function.php file.
  2. In a shipping zone settings, disable / save any shipping method, then enable back / save.
    You are done and you can test it.
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement