wc_product_pre_has_unique_sku
Gives plugins an opportunity to verify SKU uniqueness themselves.
Usage
add_filter( 'wc_product_pre_has_unique_sku', 'wp_kama_wc_product_pre_has_unique_sku_filter', 10, 3 ); /** * Function for `wc_product_pre_has_unique_sku` filter-hook. * * @param bool|null $has_unique_sku Set to a boolean value to short-circuit the default SKU check. * @param int $product_id The ID of the current product. * @param string $sku The SKU to check for uniqueness. * * @return bool|null */ function wp_kama_wc_product_pre_has_unique_sku_filter( $has_unique_sku, $product_id, $sku ){ // filter... return $has_unique_sku; }
- $has_unique_sku(true|false|null)
- Set to a boolean value to short-circuit the default SKU check.
- $product_id(int)
- The ID of the current product.
- $sku(string)
- The SKU to check for uniqueness.
Changelog
Since 9.0.0 | Introduced. |
Where the hook is called
wc_product_pre_has_unique_sku
woocommerce/includes/wc-product-functions.php 668
$has_unique_sku = apply_filters( 'wc_product_pre_has_unique_sku', null, $product_id, $sku );