0

I was wondering if anyone had come up with a viable workaround to provide free shipping on products that are sold to members.

The only possibility I can think of at the moment is to have two separate product offerings for each product - one for members and on for the public.

But that would not be feasible in a store with a large product base.

How could I implement free shipping for members?

1

If you are open to using a plugin to achieve this, then the Advanced Free Shipping" plugin by Jeroen Sormani can definitely help you. Using this, you can provide free shipping based on the user role. In that case, you can simply create a new user role that will be used to identify the users.

It's in the wordpress plugin directory and is free : https://wordpress.org/plugins/woocommerce-advanced-free-shipping/

EDIT --

Thought you were trying to base it through WP user roles. There's actually a way to identify the current user's membership plan and at the same time to unset the other woocommerce shipping rates/method. Based on the docs, we might be able to achieve what you need by doing something like this.

    add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 10, 2 );

    function hide_shipping_when_free_is_available( $rates, $package ) {

    // Get current user ID
    $user_id = get_current_user_id();

    // Let's use a hook based o https://docs.woocommerce.com/document/woocommerce-memberships-function-reference/
   // This is assuming that the plan's name is "gold"
   if (wc_memberships_is_user_active_member( $user_id, 'gold' )) {

   // If the user is active, then let's force the free shipping method
    $free_shipping          = $rates['free_shipping'];
    $rates                  = array();
    $rates['free_shipping'] = $free_shipping;
   }
   return $rates;
   }

This is from a sample in woocommerce. Only, we modified the if statement a bit.

  • I already tried this plugin, this doesn't fetch the memberships in the conditions. – dh47 Sep 5 '17 at 4:04
  • I don't understand "doesn't fetch the memberships in the conditions". Did you already created a new user role for all the members with certain privilege and assigned it to this plugin to provide free shipping? – The Filipino Freelancer Sep 5 '17 at 8:11
  • I have 3 membership plans created using Woocommerce memberships now I need free shipping for members who are in the Highest plan, I installed the said plugin by you before that plugin have different options for conditions but it doesn't have any option which fetches my woocommerce membership plans. – dh47 Sep 6 '17 at 9:58
  • Added a sample code for a possible implementation. Hope it works or could be a start. – The Filipino Freelancer Sep 6 '17 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.