WC_Product::set_sku() – Set SKU.

You appear to be a bot. Output may be restricted

Description

Set SKU.

Usage

WC_Product::set_sku( $sku );

Parameters

$sku
( string ) required – Product SKU.

Returns

void

Source

File name: woocommerce/includes/abstracts/abstract-wc-product.php
Lines:

1 to 9 of 9
  public function set_sku( $sku ) {
    $sku = (string) $sku;
    if ( $this->get_object_read() && ! empty( $sku ) && ! wc_product_has_unique_sku( $this->get_id(), $sku ) ) {
      $sku_found = wc_get_product_id_by_sku( $sku );

      $this->error( 'product_invalid_sku', __( 'Invalid or duplicated SKU.', 'woocommerce' ), 400, array( 'resource_id' => $sku_found ) );
    }
    $this->set_prop( 'sku', $sku );
  }
 

 View on GitHub View on Trac