Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Commit

Permalink
improves #353 fix
Browse files Browse the repository at this point in the history
additional defensive code ensures wc_product_generate_unique_sku
doesn’t result in duplicate sku when called with no productid by
woocommerce product_duplicate
  • Loading branch information
Jon007 committed Aug 19, 2018
1 parent 2a8f359 commit 1d83ef2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Hyyan/WPI/Product/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,11 @@ public function suppressInvalidDuplicatedSKUErrorMsg($sku_found, $product_id, $s
if ( ! $sku_found ) {
return false;
}
//if called with no product id from woocommerce product_duplicate
//no further check can be done
if ( ! $product_id ) {
return $sku_found;
}

/*
* now check the duplicates
Expand All @@ -842,6 +847,10 @@ public function suppressInvalidDuplicatedSKUErrorMsg($sku_found, $product_id, $s
)
);
$curlang = pll_get_post_language( $product_id );
if ( ! $curlang ) {
//if there is no language no further check can be done
return $sku_found;
}
foreach ( $postids as $post_id ) {
//suppress duplicate sku error on translations only
$duplang = pll_get_post_language( $post_id );
Expand Down

0 comments on commit 1d83ef2

Please sign in to comment.