Refactored haveSufficientQuantity function in product type class
This commit is contained in:
parent
9498348ac1
commit
e15fe96499
|
|
@ -854,9 +854,7 @@ class Configurable extends AbstractType
|
|||
*/
|
||||
public function haveSufficientQuantity(int $qty): bool
|
||||
{
|
||||
$backorders = core()->getConfigData('catalog.inventory.stock_options.backorders');
|
||||
|
||||
$backorders = ! is_null($backorders) ? $backorders : false;
|
||||
$isBackOrderEnable = (bool) core()->getConfigData('catalog.inventory.stock_options.backorders');
|
||||
|
||||
foreach ($this->product->variants as $variant) {
|
||||
if ($variant->haveSufficientQuantity($qty)) {
|
||||
|
|
@ -864,7 +862,7 @@ class Configurable extends AbstractType
|
|||
}
|
||||
}
|
||||
|
||||
return $backorders;
|
||||
return $isBackOrderEnable;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -61,11 +61,7 @@ class Simple extends AbstractType
|
|||
*/
|
||||
public function haveSufficientQuantity(int $qty): bool
|
||||
{
|
||||
$backOrders = core()->getConfigData('catalog.inventory.stock_options.backorders');
|
||||
|
||||
$backOrders = ! is_null($backOrders) ? $backOrders : false;
|
||||
|
||||
return $qty <= $this->totalQuantity() ? true : $backOrders;
|
||||
return $qty <= $this->totalQuantity() ?: (bool) core()->getConfigData('catalog.inventory.stock_options.backorders');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue