Public Ticket #3963069

Automatically Generate Unique Product SKUs for Vendors

Closed
Comments
21 Tickets 8
Barni started the conversation 1 year ago on April 25, 2025 at 11:44am

Dear WebWizward Team,

I’m reaching out to ask if there's a way to automatically generate product SKUs when a vendor creates a new product.

The background:
Right now, vendors are required to enter SKUs manually. As the number of vendors on our platform grows, the risk of duplicate SKUs increases significantly. Not every vendor comes up with a unique SKU, which can lead to product conflicts and backend issues.

I’ve already tested the SKU for WooCommerce plugin, but unfortunately, it only works within the admin backend and doesn’t meet our needs.

Ideally, we’re looking for a solution that:

  • Automatically generates a unique alphanumeric SKU (e.g. A2XFBD3),

  • Triggers when a product is created by a vendor,

  • Prevents the vendor from editing the generated SKU afterward.

If you have a code snippet or solution that could help us implement this functionality, we’d really appreciate it.

Best regards,

2,762
KingsPlugins replied 1 year ago on April 29, 2025 at 7:58pm

Hi Barni,

You could add this code snippet to your site: https://pastecode.io/s/hy1cxp07

 

This does 2 things:

  1. It hides the SKU area from the vendor product edit panel, so it's no longer modifiable by vendors
  2. When the product is saved, it automatically sets a unique SKU. In this case, the sku is "SKU1234" where 1234 is the ID of each product (unique).

Of course, you can modify it in the above code to configure a custom formula for SKUs.

 

Kind regards,

Stefan

2,762
KingsPlugins replied 1 year ago on April 30, 2025 at 8:48pm

Glad to assist : )

I'm afraid we are not available for customization or larger projects though as we are focusing exclusively on the plugins. Happy to assist with any technical info though if you work with a developer or anyone else.

2,762
KingsPlugins replied 11 months ago on October 29, 2025 at 1:31pm

Hi Artem,

If you'd like to keep the SKU field visible but still automatically generate SKUs, you can use just this part of the snippet:

add_action('marketking_after_save_product', function($product_id, $vendor_id){
$custom_sku_here = 'SKU'.$product_id;
update_post_meta($product_id, '_sku', $custom_sku_here);
}, 10, 2);

 

Kind regards,
Stefan

Sign In