fallback handled
This commit is contained in:
@@ -460,6 +460,12 @@ class ProductController extends SuperController
|
||||
$data['use_last_price_if_zero'] = !empty($data['use_last_price_if_zero']);
|
||||
}
|
||||
|
||||
if (!Product::hasTradeByQuantityColumn()) {
|
||||
unset($data['trade_by_quantity']);
|
||||
} elseif (array_key_exists('trade_by_quantity', $data)) {
|
||||
$data['trade_by_quantity'] = !empty($data['trade_by_quantity']);
|
||||
}
|
||||
|
||||
if (!Product::hasDirectPriceColumn()) {
|
||||
unset($data['direct_price']);
|
||||
}
|
||||
|
||||
@@ -451,6 +451,16 @@ class Controller extends BaseController
|
||||
return (float) $product['amount'] > 0;
|
||||
}
|
||||
|
||||
/** معامله مقداری: فقط فیلد trade_by_quantity */
|
||||
public static function usesQuantityTrade($product): bool
|
||||
{
|
||||
$value = is_array($product)
|
||||
? ($product['trade_by_quantity'] ?? null)
|
||||
: (is_object($product) ? ($product->trade_by_quantity ?? null) : null);
|
||||
|
||||
return !empty($value);
|
||||
}
|
||||
|
||||
/** ضریب قیمت محصول — بدون وزن قطعه همیشه ۱ */
|
||||
public static function productPriceMultiplier($product): float
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user