Change the “Duplicate product” capability in WooCommerce

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:

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.


More Posts That You Might Like…


7 responses to “Change the “Duplicate product” capability in WooCommerce”

  1. Ciao, grazie per questa spiegazione.
    Sapresti indicarmi gentilmente cosa dovrei scrivere per rimuovere completamente la funzione “duplicate” di WooCommerce?

    Grazie
    -Enrico

    1. Ciao Enrico,
      Qui puoi trovare il codice per rimuovere completamente la funziona per duplicare i prodotti: https://gist.github.com/SiR-DanieL/da1c464cf27c51400d3aaa0135d1203f


      Hello Enrico,
      Here you can find a snippet to remove the Duplicate feature: https://gist.github.com/SiR-DanieL/da1c464cf27c51400d3aaa0135d1203f

  2. Is there a way of duplicating vendors for a particular product (I run a marketplace) instead of duplicating products for vendors?
    I think that will be more useful to me.
    Thanks

    1. I’m sorry but I don’t think there’s a way to do this.
      Maybe with a plugin to duplicate custom taxonomies, but I’m not aware of such plugin.

      1. Ok. Thanks for your response anyway.
        I’ve been getting by somehow though.
        Cheers

  3. Thank you Nicola for the great post,

    I’m struggling with this because the snippet does seem to work for the vendors on my site.
    I ‘ve found this exact solution from different sources, added to my child theme’s functions.php (I do have other actions running fine from the child theme’s functions.php).

    I use user role editor and the
    edit_products capability is granted for the vendors. I did try to disable the user role editor plugin in case if that is the culprit but it wasn’t.

    Any advice? Thanks.

    1. Hi,
      try to wrap the filter in another function and hooks that function to the init hook.

Leave a Reply

Categories

Newsletter

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Blog at WordPress.com.

%d bloggers like this: