• Resolved johnny538

    (@johnny538)


    I want to use the plugin and I like the ‘Hide other shipping methods when free shipping is available’. But I also have a physical store where customers can pick up their order which is free.

    Therefore I’d like to hide all ‘paid’ shipping methods, but still leave the option to pick up.

    Is this possible ? Or is it a feature you’d be willing to add ? I can imagine I’m not the only one here offering ‘pick up in store’.

    I tried adding 2 shipping rates in the plugin in hopes it would show both but it didn’t.

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

    (@sormano)

    Hi,

    I’ve made this code snippet some time ago that will also show local pickup:
    https://gist.github.com/JeroenSormani/354a5ea652ddb8a4c51d

    Hope that helps ??

    Cheers,
    Jeroen

    Thread Starter johnny538

    (@johnny538)

    How do I apply it?

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    I’ve written this post about adding code snippets to your site: https://shopplugins.com/how-to-add-a-code-snippet-to-your-site/

    Cheers,
    Jeroen

    stefanico

    (@stefanico)

    Hi Jeroen,

    I am sorry but I have tried to implement this exception, however after adding the snippet to the function.php as required the exception just doesn’t work?

    Please confirm I need to have the hide other shipping option set (ticked) / pasted the snipet as is in my function php, however, it will not show the Local pickup when the free shipping condition is met, just the free shipping ??

    In looking at the code of the page, the Local Pickup option seems to have a different name?, see below:

    <input name=”shipping_method[0]” data-index=”0″ id=”shipping_method_0_local_pickup10″ value=”local_pickup:10″ class=”shipping_method” type=”radio”>

    and the free shipping option is:

    <input name=”shipping_method[0]” data-index=”0″ id=”shipping_method_0_advanced_free_shipping” value=”advanced_free_shipping” class=”shipping_method” type=”radio”>

    Anything I am doing wrong??

    Thanks for your time

    stefanico

    (@stefanico)

    I also found another snipet from CodeCanyon (your post of course) ?? as below, without success:

    function custom_hide_all_shipping_when_free_is_available( $available_methods ) {
    $to_test_methods = $available_methods;
    unset( $to_test_methods[‘local_pickup’] );
    $shipping_costs = wp_list_pluck( (array) $to_test_methods, ‘cost’, ‘id’ );
    if ( in_array( 0, $shipping_costs ) ) :
    foreach ( $available_methods as $key => $method ) :
    if ( 0 != $method->cost ) :
    unset( $available_methods[ $key ] );
    endif;
    endforeach;
    endif;
    return $available_methods;
    }
    add_filter( ‘woocommerce_package_rates’, ‘custom_hide_all_shipping_when_free_is_available’ );

    Maybe the sipping[id] // 10 is needed?

    thanks for your time ??

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi Stefan,

    Those code snippets are all a bit old, I wrote this one bout 2 weeks ago which should work nicely with both my plugins and WC Shipping Zones:
    https://gist.github.com/JeroenSormani/38af8a40b235246a75042f3a481d6b25

    Cheers,
    Jeroen

    stefanico

    (@stefanico)

    Hi Jeroen,

    And thanks for your prompt reply, much appreciated.

    Just tried it out. However as a result it will only show the Local Pickup when it is not free shipping, and indeed will show both free shipping and local pickup when qty justify free shipping.

    Both plugin and WP are up to date and I placed the snippet as required in the function.php file.
    I tried with Hide other shipping method or not, same result ??

    In looking at your new code snipet, I realise it is targeting free_rates… I actually need to allow the Express Post as well as free-shipping for slow shipping. It is for medical goods and need to have the option to have it using Express post as well as Freeshiping when purchasing 3+ qty.
    Looking at your previous code I hoped I could just replace the Id / name of the local pickup to the Express post shipping option to have the exception in place?

    I really would appreciate your help on this, it is beyond my capacity at this stage ??

    Thanks for your time
    Stephane

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi Stephane,

    If you still want to show a express shipping rate then using the option / code like this might not be right for your needs.

    You could modify the code further to fit your exact needs, but this would be outside what this plugin can do.

    Depending on your needs you may also be able to setup the appropriate shipping cost using my other plugin; https://codecanyon.net/item/woocommerce-advanced-shipping/8634573
    But that really depends if you use flat rates / live quotes for example.

    Hope that makes sense ??

    Cheers,
    Jeroen

    stefanico

    (@stefanico)

    Hiya ?? I managed to find a solution for this.

    I used the code below and it basically hides the standard delivery option leaving the free + Express.

    Sorted ??

    See the code below:

    add_filter( ‘woocommerce_package_rates’, ‘unset_shipping_when_free_is_available_in_zone’, 10, 2 );

    function unset_shipping_when_free_is_available_in_zone( $rates, $package ) {

    // Only unset rates if free_shipping is available
    if ( isset( $rates[‘advanced_free_shipping’] ) ) {
    unset( $rates[‘flat_rate:1’] );
    }

    return $rates;

    }

    }

    *************************************************
    Thanks again for your time with this.

    Plugin Author Jeroen Sormani

    (@sormano)

    Glad to hear you found a solution ??

    I have a fedex shipping option and this free shipping option when a person meets a 299.00 order it goes to free shipping, but I only want free shipping to continental US only not Alaska or Hawaii, so I added to extra conditions that only allow free shipping if the order exceeds 299.00 and is not located by state in Alaska and hawaii, and it works good but if a customer is in Alaska or Hawaii, they now get a message that says no shipping method available please contact us, why does it not just go to my fedex shipping option now?

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi @isiteweb,

    Please create a new support thread as this doesn’t seem to be related to the initial.

    Thank you,
    Jeroen

    Hello,can you please tell me the right code for make appears the free shipping with local pickup?
    The code from above have id for shipping zones?
    I don’t want to apply it to specific zones ,but everywhere.
    Thank you

    Hello Jeroen!

    I use this plugin and your pay version too, and other shipping plugins. I try to use your code to not hide the local pickup, but if I use it, it hide my other shipping methods too, the problem is, it doing that if I don’t have free shipping option too. So Local pickup is show up the free shipping condition is not triger because it’s not true, in this case my other shipping methods have too show up, but I only see the local pickup methods only.

    Pls help me, thank you

    • This reply was modified 7 years, 4 months ago by Amoditer.
Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Hide other shipping methods EXCEPT’ is closed to new replies.