Support » Plugin: WooCommerce Advanced Free Shipping » hiding flat rate shipping when free shipping is available

  • 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)
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.