fix price 2

This commit is contained in:
2026-06-14 13:31:32 +03:30
parent f07e56ed70
commit 6f86e8242c
3 changed files with 66 additions and 0 deletions
+22
View File
@@ -20,6 +20,7 @@ class Product extends Model
private static ?bool $orderLimitColumnsExist = null;
private static ?bool $showInAssetsColumnExists = null;
private static ?bool $useLastPriceIfZeroColumnExists = null;
private static ?bool $directPriceColumnExists = null;
protected static function booted(): void
{
@@ -40,6 +41,9 @@ class Product extends Model
if (!static::hasUseLastPriceIfZeroColumn()) {
unset($product->attributes['use_last_price_if_zero']);
}
if (!static::hasDirectPriceColumn()) {
unset($product->attributes['direct_price']);
}
});
}
@@ -131,6 +135,24 @@ class Product extends Model
return static::$useLastPriceIfZeroColumnExists;
}
public static function hasDirectPriceColumn(): bool
{
if (static::$directPriceColumnExists !== null) {
return static::$directPriceColumnExists;
}
try {
static::$directPriceColumnExists = Schema::hasColumn(
(new static)->getTable(),
'direct_price'
);
} catch (\Throwable) {
static::$directPriceColumnExists = false;
}
return static::$directPriceColumnExists;
}
public function orderLimitsEnabled(): bool
{
if (!static::hasOrderLimitColumns() || !($this->order_limit_enabled ?? false)) {