fix bug 22/4 2
This commit is contained in:
@@ -671,6 +671,22 @@ class ProductController extends SuperController
|
||||
unset($data['direct_price']);
|
||||
}
|
||||
|
||||
if (!Product::hasAppPriceColumn()) {
|
||||
unset($data['app_price']);
|
||||
} elseif (array_key_exists('app_price', $data)) {
|
||||
$data['app_price'] = filter_var($data['app_price'], FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
// قیمت اپ: مرجع خارجی ندارد، متغیر است (هر گرم × وزن) و قیمت دستی نگه داشته نمیشود
|
||||
if ($data['app_price']) {
|
||||
$data['reading_method'] = null;
|
||||
if (Product::hasDirectPriceColumn()) {
|
||||
$data['direct_price'] = 0;
|
||||
}
|
||||
$data['price'] = 0;
|
||||
$data['price_profit'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Product::hasInventoryColumn()) {
|
||||
unset($data['inventory']);
|
||||
}
|
||||
@@ -682,24 +698,35 @@ class ProductController extends SuperController
|
||||
}
|
||||
|
||||
if (!Product::hasPhysicalDeliveryColumns()) {
|
||||
unset($data['has_physical_delivery'], $data['min_physical_delivery_grams']);
|
||||
unset(
|
||||
$data['has_physical_delivery'],
|
||||
$data['min_physical_delivery_quantity'],
|
||||
$data['min_physical_delivery_grams']
|
||||
);
|
||||
} else {
|
||||
// سازگاری با نسخهٔ قبلی که فیلد را min_physical_delivery_grams میفرستاد
|
||||
if (!array_key_exists('min_physical_delivery_quantity', $data)
|
||||
&& array_key_exists('min_physical_delivery_grams', $data)) {
|
||||
$data['min_physical_delivery_quantity'] = $data['min_physical_delivery_grams'];
|
||||
}
|
||||
unset($data['min_physical_delivery_grams']);
|
||||
|
||||
$hasDelivery = array_key_exists('has_physical_delivery', $data)
|
||||
? filter_var($data['has_physical_delivery'], FILTER_VALIDATE_BOOLEAN)
|
||||
: false;
|
||||
$data['has_physical_delivery'] = $hasDelivery;
|
||||
|
||||
if (!$hasDelivery) {
|
||||
$data['min_physical_delivery_grams'] = null;
|
||||
$data['min_physical_delivery_quantity'] = null;
|
||||
} else {
|
||||
$rawMin = $data['min_physical_delivery_grams'] ?? null;
|
||||
$rawMin = $data['min_physical_delivery_quantity'] ?? null;
|
||||
$min = $this->normalizeCashFeeValue($rawMin);
|
||||
if ($min <= 0) {
|
||||
throw new UnprocessableEntityHttpException(
|
||||
'برای فعال کردن تحویل فیزیکی باید حداقل گرم معتبر وارد شود'
|
||||
'برای فعال کردن تحویل فیزیکی باید حداقل مقدار معتبر وارد شود'
|
||||
);
|
||||
}
|
||||
$data['min_physical_delivery_grams'] = $min;
|
||||
$data['min_physical_delivery_quantity'] = $min;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user