I want to create multiple simple-product with same SKU in WooCommerce. I search in admin settings but there I cannot find any settings to enable this features. Is there any hook so I can disable this features.
Asked
Active
Viewed 1.7k times
1 Answers
27
If you want to completely disable the SKU feature then you have to use
wc_product_sku_enabled
filter. It will remove the SKU field from both backend and frontend.
add_filter( 'wc_product_sku_enabled', '__return_false' );
If you want to keep the SKU feature but need to disable unique SKU check then you have to use
wc_product_has_unique_sku
filter. It will keep the SKU field in both backend and frontend, but will allow you to add multiple duplicate SKU.
add_filter( 'wc_product_has_unique_sku', '__return_false' );
Code goes in function.php file of your active child theme (or theme). Or also in any plugin php files.
Hope this helps!

Raunak Gupta
- 10,412
- 3
- 58
- 97
-
2Hello sir, Thanks for your reply, but i resolved the problem by using the below filter. add_filter( 'wc_product_has_unique_sku', '__return_false' ); – dineshkashera Jan 11 '17 at 07:40
-
1Thanks @dineshkashera coz of you I got to know `wc_product_has_unique_sku` filter. I have updated my answer with that. This question is very helpful for the community. – Raunak Gupta Jan 12 '17 at 06:55
-
3Note that doing this means you will get an unpredictable output from get_product_id_by_sku() - it is limited to one result and not filterable. This affects things like the [add_to_cart] shortcode and the API. – richplane Jan 24 '18 at 15:15
-
2Something I've noticed is that the product importer will now not upload the duplicate sku products. Does anyone know a workaround for this? – SpaceBeers Nov 11 '19 at 19:52
-
1@richplane Just thought that I'd add that `get_product_id_by_sku()` (used by `wc_get_product_id_by_sku()`) is filterable now. Filter: [`woocommerce_get_product_id_by_sku`](https://woocommerce.github.io/code-reference/files/woocommerce-includes-data-stores-class-wc-product-data-store-cpt.html#source-view.1023) – Punchlinern Mar 09 '21 at 12:32