public function LocalStockChecker::getTotalStockLevel in Commerce Stock 8
Gets the stock level.
Parameters
\Drupal\commerce\PurchasableEntityInterface $entity: The purchasable entity.
\Drupal\commerce_stock\StockLocationInterface[] $locations: The locations.
Return value
int The stock level.
Overrides StockCheckInterface::getTotalStockLevel
1 call to LocalStockChecker::getTotalStockLevel()
- LocalStockChecker::getIsInStock in modules/
local_storage/ src/ LocalStockChecker.php - Check if purchasable entity is in stock.
File
- modules/
local_storage/ src/ LocalStockChecker.php, line 146
Class
- LocalStockChecker
- The stock checker implementation for the local stock module.
Namespace
Drupal\commerce_stock_localCode
public function getTotalStockLevel(PurchasableEntityInterface $entity, array $locations) {
$location_info = $this
->getLocationsStockLevels($entity, $locations);
$total = 0;
foreach ($location_info as $location) {
$total += $location['qty'] + $location['transactions_qty'];
}
return $total;
}