• Resolved jazzu

    (@jazzu)


    Hello!

    I have 2 delivery methods on our store. We have pickup and delivery. I want to enable free shipping for orders over 100 €, so I added Free shipping method. Set the minimum price for it to show and I guess it works.

    However – I want the delivery (not free) option to disappear if the customer reaches over 100 €.

    I was already searching for a solution, found the code below, but it doesn’t work..

    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;
                    break;
              }
            }
    
            return ! empty( $free ) ? $free : $rates;
    }

    ——————————————-

    Another thing – I have two shipping classes on my site. I only need the free shipping to be active for one of those shipping classes.

    What can I do?

    Kind regards

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Sérgio L. a11n

    (@csnlima)

    Hi @jazzu,

    You can find a complete working code and other options (plugins) to hide the other shipping methods when Free Shipping is enabled here:

    https://woocommerce.com/document/hide-other-shipping-methods-when-free-shipping-is-available/#snippets-for-wc-30

    Another thing – I have two shipping classes on my site. I only need the free shipping to be active for one of those shipping classes.

    I believe this guide may be a good start:

    https://woocommerce.com/document/flat-rate-shipping/#how-to-set-up-free-shipping-for-some-products-and-flat-rate-for-the-rest

    I hope this information helps but, please let us know if that doesn’t fit your needs.

    Best,

    Thread Starter jazzu

    (@jazzu)

    Hi @csnlima !

    Thank you for your reply. I solved the first issue through the link you provided. Now, every time an order exceeds 100 €, the only shipping options are Local pickup and Free shipping.

    For the second issue, I don’t understand what I’m supposed to do. I see that the guide is showing that there is a Free Shipping class. I don’t have a free shipping class. I have two shipping classes – one called “Saunas” (which I need to charge for delivery, even if order exceeds 100 €) and “Smaller things”, where we charge 5 € for delivery. For example, if the order exceeds 100 €, I need the shipping to be free. However, if there is a sauna bought, I’d still need the delivery to be 100 €. And for some reason, if anyone would buy more than 1 sauna, I’d still need to have the number of saunas * 100 €. I have that set in the options, so the only problem I have is with the free shipping.

    Here you can see shipping methods I currently have enabled.

    Here you can see the settings I have for Flat rate shipping.

    Kind regards

    Plugin Support Paulo P – a11n

    (@paulostp)

    Hello,

    I solved the first issue through the link you provided.

    That’s great! Thanks for letting us know.

    For the second issue (…) if the order exceeds 100 €, I need the shipping to be free. However, if there is a sauna bought, I’d still need the delivery to be 100 €.

    Offering free shipping with a minimum order amount AND limiting that to just some products is not possible with WooCommerce core – a shipping method is always available for the whole store. For your scenario, something like this would be required: https://woocommerce.com/products/conditional-shipping-and-payments/

    Hope this helps!

    Thread Starter jazzu

    (@jazzu)

    Hello @paulostp !

    Thank you for your reply and for letting me know that I’m not just missing something.

    I’ll try to solve it somehow.

    Thank you for your help!

    Kind regards

    Plugin Support Sérgio L. a11n

    (@csnlima)

    Hi @jazzu,

    Indeed, you’re not missing something. I tough the solution could be different, but with all the details you sent, Paulo’s suggestion is probably the best for your needs.

    I’ll now mark this topic as solved. If you need further help, please open a new thread here:

    https://www.ads-software.com/support/plugin/woocommerce/#new-topic-0

    Best regards!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hide other shipping methods if free shipping is enabled’ is closed to new replies.