WooCommerce multiple vendors setup

WooCommerse with multiple vendors

WooCommerse with multiple vendors

WooCommerce multiple vendors decision – is it possible to setup this popular WordPress plugin for eCommerce that way?
WooCommerce is designed for the only shop owner by default. Yes, you may assign the ‘Shop Manager’ role more than to one user simultaneously, but all of them will have the same permissions. All of them will be the boss at your e-shop. What to do if you wish that your e-shop has multiple sellers with limited rights for editing their own selling items only? That is a seller or vendor (e.g. software developer) may input and publish at your e-shop his own items (software applications) only? Is it possible without additional programming? Read further and I show you one of the possible decisions.
Yes, you may configure WordPress and WooCommerce to work correctly with multiple vendors. Answer is simple. Woocommerce products is a custom post type. WordPress works with custom post types exactly the same way as it does that with standard posts. Thus your vendors may have the same permissions on their own selling products as standard WordPress authors have for their own posts.
We need to create the duplicate of the ‘Author’ WordPress role, but for WooCommerce products, not WordPress posts.
You may do it easily with help of the User Role Editor WordPress plugin. Step by step description of actions needed follows:

  • Download and install User Role Editor plugin;
  • Create new role (e.g. ‘Vendor’) as the copy of the Author role;
  • Select the same list of WooCommerce capabilities from the custom capabilities list at the bottom as the Author role has at the top. Just change ‘post’ to the ‘product’ to make relation between them. In case you do not wish to give your vendors permissions to make posts, exclude all core capabilities from the new created ‘Vendor’ role, except the ‘read’ one. Finally your ‘Product Owner’ role should contain these capabilities for begin:
    – read,
    – upload_files,
    – delete_product,
    – delete_products,
    – delete_published_products,
    – edit_product,
    – edit_products,
    – edit_published_products,
    – publish_products,
    – read_product.

  • Change role of the users, you select to be the product owners, to the “Vendor” role. Go to the user profile for that;
  • Create some products from the side of those users;
  • Go to the ‘Products’ list and check that user with ‘Product Owner” role could edit his products only;

I recorded the short support video on the subject. It has no sound, but with process description above you will understand the show easy, I hope.

Did we resolve all problems on the declared subject? Almost Yes. Why almost? Woocommerce has ‘Prevent customers from accessing WordPress admin’ option at the ‘Settings’ page. If you turn it on, not only customers will lose access to the WordPress admin dashboard, but your new configured happy vendors too. Why it is happened?
WooCommerse plugin manages this by checking if user has ‘edit_posts’ or ‘manage_woocommerce’ capabilities.
So, the easiest way to fix the issue, just add ‘edit_posts’ capability to the ‘Vendor’ role.
2nd way needs to edit woocommerce plugin source code, and restore this modifications after every plugin update:
At file woocommerce-core-functions.php at line #392 replace the original function with this one

392
393
394
395
396
397
398
399
400
    function woocommerce_disable_admin_bar( $show_admin_bar ) {
        if ( get_option('woocommerce_lock_down_admin')=='yes' && ! ( current_user_can('edit_posts') ||
       current_user_can('manage_woocommerce')  || current_user_can('edit_products')) ) {
            $show_admin_bar = false;
        }
 
        return $show_admin_bar;
    }
}

if you compare code you will see that I added ” || current_user_can(‘edit_products’)” condition. You may replace ‘edit_products’ with role name ‘vendor’ (lowercase), if you wish. Make the same for admin/woocommerce-core-functions.php, at line # 256 replace original function with this version

256
257
258
259
260
261
262
function woocommerce_prevent_admin_access() {
    if ( get_option('woocommerce_lock_down_admin') == 'yes' && ! is_ajax() && ! ( current_user_can('edit_posts') ||
      current_user_can('manage_woocommerce') || current_user_can('edit_products') ) ) {
        wp_safe_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
        exit;
    }
}

Select variant you like better.

  • Carl Moebis

    Your solution doesn’t allow the vendor role to view order details, nor does it email the vendor when an order is placed for an item they listed. Am I missing something? Without those 2 features, it doesn’t allow for an autonomous system for vendors and their products. Thanks for this great tutorial.

  • http://shinephp.com/ Vladimir Garagulya

    Hi Carl,

    Thanks, you are right. This solution is not supposed to be autonomous from the very begin. Such vendors do not have their own account in such e-shop. All payments are still processed centralized through the main payment gateway of e-shop owner.
    Described solution is intended just to delegate to vendors the products management. The rest part is still the responsibility of the e-shop owner.

    I suppose that adding ‘read_shop_order’ capability could allow vendor to view order details. But I did not check that myself.

    Regards,
    Vladimir.

  • Frank

    Hi,
    How to ensure that the seller can choose the category of products?

    Thank you

  • EMS

    use “assign_product_terms” capability for that.

  • EMS

    i used capability

    “read_shop_order”,
    “edit_shop_order”,
    “delete_shop_order”,
    “delete_shop_orders”,
    “edit_shop_orders”,

    it worked.

  • Andrew S

    Thank you very much. Is it possible to add custom post like shops in woocommerce and all vendors would have their shops ?

  • srikanth

    Hi, Is there any vendor capability for view and andd his own products and view only orders of his products.

  • luis

    several authors have products and products need to filter by author, so you can print on one page

  • Alain Chakri

    Find ! It’s work very good ! Big Thanks !!! ;-)

  • Luis Ruiz Figueroa

    as I can on a page displaying products uploaded by a user

  • Rishikant

    Hi,
    did you get solution for this?

  • http://www.kheme.tk/ Okiemute Omuta

    This is amazing, can’t wait to try it out :)

  • DvO

    Works perfect! But is there a solution to hide ‘all products’ and only show the one they have posted?

  • shweta

    how can i get only login vendors product’s order in order list page?