Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e634a2106e | |||
| 3c33c265b2 |
@@ -32,7 +32,7 @@ class WCPriceUpdate {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Если цена товара равна базовой и акционная цена отсутствует, его нет смысла обновлять, т.к. данные везде совпадают
|
// Если цена товара равна базовой и акционная цена отсутствует, его нет смысла обновлять, т.к. данные везде совпадают
|
||||||
if ($price["regular"] === $price["new"] && $price["sale"] === 0) {
|
if ($price["regular"] === $price["new"] && $price["sale"] === "") {
|
||||||
$result[] = array_merge($item->toArray(), $price, [ "message" => "Товар не обновлён. Цены совпадают.", "isError" => true ]);
|
$result[] = array_merge($item->toArray(), $price, [ "message" => "Товар не обновлён. Цены совпадают.", "isError" => true ]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -45,14 +45,15 @@ class WCPriceUpdate {
|
|||||||
|
|
||||||
if ($price["regular"] <= $price["new"]) {
|
if ($price["regular"] <= $price["new"]) {
|
||||||
$product->set_regular_price($price["new"]);
|
$product->set_regular_price($price["new"]);
|
||||||
|
// Полностью очищаем акционную цену
|
||||||
if ($price["sale"] > 0) {
|
$product = self::clearSalePrice($product);
|
||||||
$product->set_sale_price(0);
|
} else {
|
||||||
}
|
if ($price["new"] == 0) {
|
||||||
|
$product = self::clearSalePrice($product);
|
||||||
} else {
|
} else {
|
||||||
$product->set_sale_price($price["new"]);
|
$product->set_sale_price($price["new"]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$product->save();
|
$product->save();
|
||||||
|
|
||||||
@@ -73,4 +74,12 @@ class WCPriceUpdate {
|
|||||||
|
|
||||||
return $result;
|
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