Nicola Mustone

Happiness Lead @ Automattic



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.

Advertisements

Subscribe to This Blog

Receive new articles from this blog directly in your inbox! No spam guaranteed!

Join 651 other subscribers

Contribute to Improving This Blog

Did you enjoy this article? Was it helpful? Contribute to help me write more articles! The funds collected from this blog are reinvested directly into improving my skills or the blog so that I can provide more and better content!

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

€5.00
€15.00
€100.00
€5.00
€15.00
€100.00
€5.00
€15.00
€100.00

Or enter a custom amount


Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly
Advertisements

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

Advertisements

Categories

Newsletter

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 651 other subscribers

About The Author

Hi, I’m Nico! Support Lead at Automattic, championing WordPress.com & WooCommerce. Off-duty, I’m at Elemental Beacon, leading epic D&D adventures. Let’s connect, whether it’s about WordPress or a quest!

Advertisements

Don't Miss a Thing!

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 651 other subscribers

Continue Reading

%d bloggers like this: