Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 63fd2b4850 |
@@ -46,14 +46,18 @@ class WCPriceUpdate {
|
||||
if ($price["regular"] <= $price["new"]) {
|
||||
$product->set_regular_price($price["new"]);
|
||||
|
||||
// Полностью очищаем акционную цену
|
||||
if ($price["sale"] > 0) {
|
||||
$product->set_sale_price(0);
|
||||
$product = self::clearSalePrice($product);
|
||||
}
|
||||
} else {
|
||||
$product->set_sale_price($price["new"]);
|
||||
if ($price["new"] == 0) {
|
||||
$product = self::clearSalePrice($product);
|
||||
} else {
|
||||
$product->set_sale_price($price["new"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$product->save();
|
||||
|
||||
$result[] = [
|
||||
@@ -73,4 +77,12 @@ class WCPriceUpdate {
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private static function clearSalePrice($product) {
|
||||
$product->set_sale_price("");
|
||||
$product->set_date_on_sale_from("");
|
||||
$product->set_date_on_sale_to("");
|
||||
|
||||
return $product;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user