fix(products): force direct_price=1 when saving a manual price
Keeps weight-based live enrich from replacing an explicit stored mid price. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -117,6 +117,17 @@ class ProductController extends SuperController
|
|||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$data = $this->filterProductData($request->all());
|
$data = $this->filterProductData($request->all());
|
||||||
|
$formulaEnabled = Product::hasPriceFormulaColumns()
|
||||||
|
&& filter_var($data['price_formula_enabled'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||||
|
if (isset($data['price']) && empty($data['app_price']) && ! $formulaEnabled) {
|
||||||
|
$data['reading_method'] = null;
|
||||||
|
if (Product::hasDirectPriceColumn()) {
|
||||||
|
$data['direct_price'] = 1;
|
||||||
|
}
|
||||||
|
if (Product::hasPriceOffsetColumn()) {
|
||||||
|
$data['price_offset_percent'] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$product = Product::create($data);
|
$product = Product::create($data);
|
||||||
|
|
||||||
@@ -146,6 +157,10 @@ class ProductController extends SuperController
|
|||||||
&& filter_var($data['price_formula_enabled'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
&& filter_var($data['price_formula_enabled'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||||
if (isset($data['price']) && empty($data['app_price']) && ! $formulaEnabled) {
|
if (isset($data['price']) && empty($data['app_price']) && ! $formulaEnabled) {
|
||||||
$data['reading_method'] = null;
|
$data['reading_method'] = null;
|
||||||
|
// قیمت دستی ذخیرهشده ⇒ وزنمحور (مظنه زنده) نباید قیمت را عوض کند
|
||||||
|
if (Product::hasDirectPriceColumn()) {
|
||||||
|
$data['direct_price'] = 1;
|
||||||
|
}
|
||||||
if (Product::hasPriceOffsetColumn()) {
|
if (Product::hasPriceOffsetColumn()) {
|
||||||
$data['price_offset_percent'] = 0;
|
$data['price_offset_percent'] = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user