fixed show true when price is 0 4
This commit is contained in:
@@ -612,6 +612,10 @@ class ProductController extends SuperController
|
|||||||
unset($data['direct_price']);
|
unset($data['direct_price']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Product::hasInventoryColumn()) {
|
||||||
|
unset($data['inventory']);
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class Product extends Model
|
|||||||
private static ?bool $useLastPriceIfZeroColumnExists = null;
|
private static ?bool $useLastPriceIfZeroColumnExists = null;
|
||||||
private static ?bool $directPriceColumnExists = null;
|
private static ?bool $directPriceColumnExists = null;
|
||||||
private static ?bool $tradeByQuantityColumnExists = null;
|
private static ?bool $tradeByQuantityColumnExists = null;
|
||||||
|
private static ?bool $inventoryColumnExists = null;
|
||||||
|
|
||||||
protected static function booted(): void
|
protected static function booted(): void
|
||||||
{
|
{
|
||||||
@@ -48,6 +49,9 @@ class Product extends Model
|
|||||||
if (!static::hasTradeByQuantityColumn()) {
|
if (!static::hasTradeByQuantityColumn()) {
|
||||||
unset($product->attributes['trade_by_quantity']);
|
unset($product->attributes['trade_by_quantity']);
|
||||||
}
|
}
|
||||||
|
if (!static::hasInventoryColumn()) {
|
||||||
|
unset($product->attributes['inventory']);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,6 +179,24 @@ class Product extends Model
|
|||||||
return static::$tradeByQuantityColumnExists;
|
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
|
public function orderLimitsEnabled(): bool
|
||||||
{
|
{
|
||||||
if (!static::hasOrderLimitColumns() || !($this->order_limit_enabled ?? false)) {
|
if (!static::hasOrderLimitColumns() || !($this->order_limit_enabled ?? false)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user