Enabling Duplicate SKUs in WooCommerce

Enabling Duplicate SKUs in WooCommerce

Why do I need to allow duplicate SKUs

If you are already using the Woosage50 Default SKU feature, then there are situations where you may want to allow WooCommerce to have duplicate SKU codes.

For example, if you are using the Default SKU feature for Product Bundles, but you also have non-stock items on your website. Rather than adding all the non-stock items to Sage, to allow orders containing these items to be imported by Woosage50, you could to the following.
  1. Add a non-stock item to Sage with a SKU of MISC001 (for example), with a name of something like Non stock item placeholder (this name will never appear in orders)
  2. Enable the WooCommerce to allow duplicate SKUs (see below)
  3. On the website give ALL the non-stock items the same SKU (MISC001, in this case)
  4. In Woosage50>Settings>Orders set Use website product names to Yes
Orders in Sage will appear with a line item SKU of MISC001 (in this example) and will have the item name, quantity, price and VAT from the website.

Enabling Duplicate SKUs

There are plugins to change WooCommerce to duplicate SKUs, but the easiest way is to add the following code snippet to your functions.php file.

/* Allow duplicate SKUs */
add_filter( 'wc_product_has_unique_sku', '__return_false' );

Editing your functions.php file can have unpredictable results and should only be done by WooCommerce specialists.