# Free Shipping for a Customer Role

> Makes your Free Shipping method available to customers with a chosen role, such as wholesale buyers or VIPs, whatever their cart total.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, shipping, free-shipping, roles
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-free-shipping-for-role/

## Code

```php
$wpide_free_ship_roles = array( 'wholesale_customer', 'vip' ); // Roles that always get free shipping.

add_filter( 'woocommerce_shipping_free_shipping_is_available', function ( $available ) use ( $wpide_free_ship_roles ) {
    if ( $available || ! is_user_logged_in() ) {
        return $available;
    }

    return (bool) array_intersect( $wpide_free_ship_roles, (array) wp_get_current_user()->roles );
}, 20 );
```

## Notes

Add a Free Shipping method to each shipping zone first; this snippet only switches it on for the listed roles.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Free Shipping for a Customer Role" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
