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
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible.

Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

By using our site, you acknowledge that you have read and understood our Privacy Policy and Terms & Conditions.