WooCommerce has a nice feature which allows you to duplicate a product and create new products starting from there. This saves a lot of time to shop managers and administrators.
But they are the only two (roles) who can duplicate products by default.
What if somebody needs the same feature, like a vendor?
There’s a filter in WooCommerce which you can use to change the capability needed to use this feature.
We know that vendors created with WooCommerce Product Vendors have the capability
edit_products which allows them to edit their own products.
So, open your functions.php file located in wp-content/themes/your-theme-name/ and add this code at the end of the file:
|* Allows to duplicate products with the capability edit_products|
|add_filter( 'woocommerce_duplicate_product_capability', create_function( '', 'return "edit_products";' ) );|
This will allow any user who has the capability
edit_products to duplicate products. It includes Administrators, Shop Managers, Vendors, or any other customer user role created with other plugins.