• Resolved clooney12

    (@clooney12)


    Hello Dear Developer,

    I wanted to ask ifit’s possible to give the customer to choose between two diffferent types of free shipping options: post and courier service.

    Both are activated when order reaches certain value, but only one (first) right now is available when the value is reached.

    Is there a chance to allow to choose from both with your plugin?

    I owuld be very thnkful for this option!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi,

    I have the same question.
    I found the code where adding the local_pickup:

        if ( ! empty( $new_rates ) ) {
            foreach ( $rates as $rate_id => $rate ) {
                if ('local_pickup' === $rate->method_id ) {
                    $new_rates[ $rate_id ] = $rate;
                    break;
                }
            }
            return $new_rates;
        }

    But can’t found how adding a ‘courier service’.
    The problem: this is the ‘courier service’ is not a standard shipping method.

    Hi @clooney,

    I found a solution.
    What i did is a revert solution. I mean, hide ONLY the FLAT RATE shipping method and SHOW ALL other SHIPPING METHODS when FREE SHIPPING is available.
    Paste this code in ‘functions.php’:

    add_filter( 'woocommerce_package_rates', 'wk_unset_shipping_when_free_is_available_in_zone', 10, 2 );
    
    function wk_unset_shipping_when_free_is_available_in_zone( $rates, $package ) {
    
        // Only unset FLAT RATE if FREE SHIPPING is available
        if ( isset( $rates['free_shipping:2'] ) ) { FREE SHIPPING ID is 2
        unset( $rates['flat_rate:1'] ); // FLAT RATE shipping method with ID 1
        }
    return $rates;
    }

    PS: you want change only the ID’s for your WooCommerce shop. You can find the id’s in the css.

    And deactivate/remove the ‘WC hide shipping methods’-plugin

    Hope this help you!

    • This reply was modified 7 years, 9 months ago by ctuxboy.

    Hi @ctuxboy,

    Thanks for the piece of code. It does exactly what I was looking to do.

    There’s a small bug in your code that causes a serious 500 error:

    FREE SHIPPING ID is 2 should be commented out, like so:
    if ( isset( $rates[‘free_shipping:2’] ) ) { //FREE SHIPPING ID is 2

    Yaniv

    Hi Yaniv,

    Oh, ok happy that i can help you with this snippet.
    Sorry for the typo ‘//’, this is indeed a serious error.
    Thank you for the remark.

    Christophe

    Plugin Author Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Thanks ctuxboy!

    You can also just comment out break; at line 85 in hide-shipping-free-shipping.php

    • This reply was modified 7 years, 7 months ago by Skygrinder.

    Code worked as required, don’t forget to clear WooCommerce transients once implemented

    Hi,

    Could I jump on here and ask for advice on more than one pickup location?

    Currently, the plugin works great in showing only Free Shipping and ONE Local Pickup.
    I have created two local pickups and it seems to only display the option first in order.

    Hoping for some insight.

    Thanks,
    Terry

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘More than one free shipping method’ is closed to new replies.