• Resolved freasy

    (@freasy)


    I want flat rate shipping to be hidden when free shipping is available (only when ordering 8 items and more), I’ve added some code but it does not seem to be working. Is this because some coding due to the plugin? And how can I fix this?

    I’m using the following code in my functions.php file:
    // Hide standard shipping option when free shipping is available
    add_filter( ‘woocommerce_available_shipping_methods’, ‘hide_standard_shipping_when_free_is_available’ , 10, 1 );

    /**
    * Hide Standard Shipping option when free shipping is available
    *
    * @param array $available_methods
    */
    function hide_standard_shipping_when_free_is_available( $available_methods ) {

    if( isset( $available_methods[‘free_shipping’] ) AND isset( $available_methods[‘flat_rate’] ) ) {

    // remove standard shipping option
    unset( $available_methods[‘flat_rate’] );
    }

    return $available_methods;
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    Note that you’ve posted this on the sub-forum for the Advanced Free Shipping?plugin, and I believe you wanted to post this on the WooCommerce plugin sub-forum.

    If you are in fact using this plugin; there’s a option included in the plugin that would allow you to hide all other rates when a Advanced Free Shipping option is available.

    Regards,
    Jeroen

    Thread Starter freasy

    (@freasy)

    wow I overlooked that completely, as simple as ticking a box! thank you

    upir

    (@upir)

    I have that ticked but still shows flatrate as well as free ??

    Plugin Author Jeroen Sormani

    (@sormano)

    Could be shipping cache; https://jeroensormani.com/shipping-debug-mode
    Also note that the checkbox only looks for Advanced Free Shipping rates, not other free shipping options.

    You can also take a look at this code snippet that hides other rates when free is available, that works perfectly with local pickup and all other free shipping rates; https://gist.github.com/JeroenSormani/27a0b0d584af7152040196fdc3582212

    Regards,
    Jeroen

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘hiding flat rate shipping when free shipping is available’ is closed to new replies.