wc_product_has_unique_sku( int $product_id, string $sku )

Check if product sku is unique.


Description Description


Parameters Parameters

$product_id

(Required) Product ID.

$sku

(Required) Product SKU.


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/wc-product-functions.php

function wc_product_has_unique_sku( $product_id, $sku ) {
	$data_store = WC_Data_Store::load( 'product' );
	$sku_found  = $data_store->is_existing_sku( $product_id, $sku );

	if ( apply_filters( 'wc_product_has_unique_sku', $sku_found, $product_id, $sku ) ) {
		return false;
	}

	return true;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.2 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.