Add unique sku option to error data when setting product sku (#36612)
* Add unique sku option to error data when setting product sku
* Add changelog entry
* Add permalink template to the sku error data
* Revert "Add permalink template to the sku error data"
This reverts commit a49ee1d878
.
This commit is contained in:
parent
f601b0d8a5
commit
83faf8d328
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: add
|
||||
|
||||
Add unique sku option to error data when setting product sku
|
|
@ -820,7 +820,15 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
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->error(
|
||||
'product_invalid_sku',
|
||||
__( 'Invalid or duplicated SKU.', 'woocommerce' ),
|
||||
400,
|
||||
array(
|
||||
'resource_id' => $sku_found,
|
||||
'unique_sku' => wc_product_generate_unique_sku( $this->get_id(), $sku ),
|
||||
)
|
||||
);
|
||||
}
|
||||
$this->set_prop( 'sku', $sku );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue