Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Hide “Ship to a Different Address” Based on User Roles in WooCommerce?

Whether your store has numerous user roles like customers, subscribers, or wholesalers, this snippet will help you to hide the “Ship to a different address” section based on the user role.

add_action('init', 'ts_unset_shipping_address' );
function ts_unset_shipping_address() {
    // HERE the targeted user roles
    $user_roles = array('Customer');

    // Check user roles to hide “Ship to a different address”
    foreach( $user_roles as $user_role ) {
        if ( current_user_can( sanitize_title( $user_role ) ) ) {
            add_filter( 'woocommerce_cart_needs_shipping_address', '__return_false');
            break;
        }
    }
}

Output

If the user is logged in with a ‘customer’ role, then it will hide the ‘ship to a different address’ section as shown below.

How to Hide "Ship to a Different Address" Based on User Roles in WooCommerce? - Tyche Softwares

In another case, if the user logs in to any other roles, the “ship to a different address” section will be displayed.

How to Hide "Ship to a Different Address" Based on User Roles in WooCommerce? - Tyche Softwares

Additionally, if you want to remove the option of entering a different shipping address for all users, then you can check this article that explains how to hide the “ship to a different address” checkbox in WooCommerce without any conditions.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x