Refactored haveSufficientQuantity function in product type class

This commit is contained in:
jitendra 2022-08-09 11:33:11 +05:30
parent 9498348ac1
commit e15fe96499
2 changed files with 3 additions and 9 deletions

View File

@ -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;
}
/**

View File

@ -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');
}
/**