I have just been working on a WooCommerce site were the client needed to allow free shipping for certain levels of user. This seemed like a simple requirement but the WooCommerce line was to use Table Rate Shipping which would be fine if it wasn’t $200 (cmon guys it’s an essential plugin.. it really should be $59 or $79 like other essentials). So the other snippet that was conveniently listed here was to allow free shipping by location.

Using the following code your users with the role ‘charity’ will get free shipping. You can obviously extend it but it’s a nice basic example to work with. Put this code in your functions.php file in your theme or into a new plugin.. whatever works.

The code

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

function sb_woocommerce_set_free_shipping_for_certain_users( $rates, $package ) {
	global $current_user;
	if ($current_user->ID) {
		$user_roles = $current_user->roles;
		$user_role = array_shift($user_roles);
		if ($user_role == 'charity') {
			$freeshipping = $rates['free_shipping'];
			$rates = array();
			$rates[] = $freeshipping;
		} else {
	return $rates;