totalQuantity function added to product and product flat model
This commit is contained in:
parent
96e8556b54
commit
2d00679901
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -53,6 +53,14 @@ class ProductFlat extends Model implements ProductFlatContract
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function totalQuantity()
|
||||
{
|
||||
return $this->product->totalQuantity();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $qty
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue