fixed show true when price is 0 4

This commit is contained in:
2026-06-22 20:09:56 +03:30
parent 2a91837c2b
commit 6ebd02beb8
2 changed files with 26 additions and 0 deletions
@@ -612,6 +612,10 @@ class ProductController extends SuperController
unset($data['direct_price']);
}
if (!Product::hasInventoryColumn()) {
unset($data['inventory']);
}
return $data;
}
}
+22
View File
@@ -22,6 +22,7 @@ class Product extends Model
private static ?bool $useLastPriceIfZeroColumnExists = null;
private static ?bool $directPriceColumnExists = null;
private static ?bool $tradeByQuantityColumnExists = null;
private static ?bool $inventoryColumnExists = null;
protected static function booted(): void
{
@@ -48,6 +49,9 @@ class Product extends Model
if (!static::hasTradeByQuantityColumn()) {
unset($product->attributes['trade_by_quantity']);
}
if (!static::hasInventoryColumn()) {
unset($product->attributes['inventory']);
}
});
}
@@ -175,6 +179,24 @@ class Product extends Model
return static::$tradeByQuantityColumnExists;
}
public static function hasInventoryColumn(): bool
{
if (static::$inventoryColumnExists !== null) {
return static::$inventoryColumnExists;
}
try {
static::$inventoryColumnExists = Schema::hasColumn(
(new static)->getTable(),
'inventory'
);
} catch (\Throwable) {
static::$inventoryColumnExists = false;
}
return static::$inventoryColumnExists;
}
public function orderLimitsEnabled(): bool
{
if (!static::hasOrderLimitColumns() || !($this->order_limit_enabled ?? false)) {