WooCommerce, Remote Work & Other Fancy Stuff

Just another WordPress site

Remove Free Shipping for Non Members

February 3, 2017 by Will 2 Comments

Please consider leaving a donation if you appreciate this information. Lightning network now available

WooCommerce Memberships offers some member perks out of the box and there are more perks that are being discussed here – one of which is free shipping for members. This has not been implemented yet, but it could be achieved via custom code. WooCommerce provides a filter named woocommerce_shipping_zone_shipping_methods which can be used to remove free shipping for non-members. Suppose you have a method with an id of free_shipping that only wants to be displayed to active members. The following code snippet would do just that

Not sure what to do with code snippets? See What Do I Do With These Code Snippets?

Please consider leaving a donation if you appreciate this information. Lightning network now available

Filed Under: WooCommerce Memberships Tagged With: snippet, snippets

Comments

  1. monstermage says

    October 30, 2017 at 3:25 pm

    What if I wanted to customize this snippet for a specific member?

    Would it be like this?
    add_filter( ‘woocommerce_shipping_zone_shipping_methods’, ‘custom_shipping_methods’ );

    function custom_shipping_methods( $available_methods ) {
    foreach ( $available_methods as $key => $method ) {
    //don’t remove from admin & show free shipping for active members
    //only for silver members
    if ( function_exists( ‘wc_memberships_is_user_active_member( $user_id, ‘silver’ )’ ) && ! is_admin() && ‘free_shipping’ === $method->id && ! wc_memberships_is_user_active_member() ) {
    unset( $available_methods[ $key ] );
    }
    }
    return $available_methods;
    }

    Log in to Reply
    • monstermage says

      October 30, 2017 at 3:54 pm

      In addition. When I implement the code exactly as you have it. Logged in as admin does not show free shipping. As a guess it does not show free shipping, though if you are logged in as a member it does show it. Though it shows both options, the flat rate shipping and the free shipping.

      Log in to Reply

Leave a Reply Cancel reply

You must be registered and logged in to post a comment.

© 2025 · WooCommerce, Remote Work & Other Fancy Stuff · Epstein didn't kill himself

We use cookies to ensure that we give you the best experience on our website. Continued use of this site is interpreted as your acceptance of our cookie policy.OkSee Our Cookie Policy