totalQuantity function added to product and product flat model

This commit is contained in:
jitendra 2019-06-06 16:43:36 +05:30
parent 96e8556b54
commit 2d00679901
2 changed files with 21 additions and 5 deletions

View File

@ -168,11 +168,9 @@ class Product extends Model implements ProductContract
}
/**
* @param integer $qty
*
* @return bool
* @return integer
*/
public function haveSufficientQuantity($qty)
public function totalQuantity()
{
$total = 0;
@ -195,7 +193,17 @@ class Product extends Model implements ProductContract
$total -= $orderedInventory->qty;
}
return $qty <= $total ? true : (core()->getConfigData('catalog.inventory.stock_options.backorders') ? true : false);
return $total;
}
/**
* @param integer $qty
*
* @return bool
*/
public function haveSufficientQuantity($qty)
{
return $qty <= $this->totalQuantity() ? true : (core()->getConfigData('catalog.inventory.stock_options.backorders') ? true : false);
}
/**

View File

@ -53,6 +53,14 @@ class ProductFlat extends Model implements ProductFlatContract
return false;
}
/**
* @return integer
*/
public function totalQuantity()
{
return $this->product->totalQuantity();
}
/**
* @param integer $qty
*