• Hi everyone, can someone please give me a hand with the following? I would like to alter the following code so that flat_rate:17 is also included in the list when free shipping is available.

    /**
    * Hide shipping rates when free shipping is available.
    * Updated to support WooCommerce 2.6 Shipping Zones.
    *
    * @param array $rates Array of rates found for the package.
    * @return array
    */
    function my_hide_shipping_when_free_is_available( $rates ) {
    $free = array();
    foreach ( $rates as $rate_id => $rate ) {
    if ( ‘free_shipping’ === $rate->method_id ) {
    $free[ $rate_id ] = $rate;
    $free_shipping = true;
    }
    if ( $free_shipping == true && ‘local_pickup:21’ === $rate->id ) {
    $free[ $rate_id ] = $rate;
    }

    }
    return ! empty( $free ) ? $free : $rates;
    }
    add_filter( ‘woocommerce_package_rates’, ‘my_hide_shipping_when_free_is_available’, 100 );

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    Flat rate, by default, is already included in the list of methods available when Free Shipping is triggered. By removing your code above, it should show flat rate AND free shipping.

    Thread Starter helencham

    (@helencham)

    I know flat rate by default is included. But i have it removed when a user spends over $100 cause free shipping takes over. However, i still want the option of Express Shipping to still be available for customers to choose from. So that there will still be Free Shipping and Express Shipping. If the user is in a certain state, local pickup is also available. So i’m just unsure how to modify that line of code to incorporate express shipping aswell (flat_rate:17)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Make shipping option always available even when free shipping is provided’ is closed to new replies.