Hide duplicate product link from Shop Manager

Is it possible to hide from Shop Manager “Duplicate” link located under a WooCommerce selected product row?

duplicate product link
Duplicate product link

WooCommerce checks ‘manage_woocommerce’ capability by default to decide if ‘Duplicate’ link is available for current user under the product row.

	if ( ! current_user_can( apply_filters( 'woocommerce_duplicate_product_capability', 'manage_woocommerce' ) ) ) {
		return $actions;
	}

But it’s possible to replace it to something more special like ‘duplicate_products’ using custom ‘woocommerce_duplicate_product_capability’ filter, like this:

add_filter('woocommerce_duplicate_product_capability', 'define_wc_duplicate_product_capability', 10, 1);
function define_wc_duplicate_product_capability($cap) {

    $cap = 'duplicate_products';
    
    return $cap;
}

shop_manager will not see “Duplicate” link under a product after that. In order to make it available for a role, you will have to add new capability ‘duplicate_products’ via User Role Editor and grant it to that role.

Return ‘do_not_allow’ from this filter in case you need just to switch off the ‘Duplicate product’ feature:

add_filter('woocommerce_duplicate_product_capability', 'define_wc_duplicate_product_capability', 10, 1);
function define_wc_duplicate_product_capability($cap) {

    $cap = 'do_not_allow';
    
    return $cap;
}
Share