public function ProductBundleStockProxy::getIsInStock in Commerce Product Bundle 8
Check if purchasable entity is in stock.
Parameters
\Drupal\commerce\PurchasableEntityInterface $entity: The purchasable entity.
\Drupal\commerce_stock\StockLocationInterface[] $locations: The locations to check against.
Return value
bool TRUE if the entity is in stock, FALSE otherwise.
Overrides StockCheckInterface::getIsInStock
File
- modules/
commerce_product_bundle_stock/ src/ ProductBundleStockProxy.php, line 85
Class
- ProductBundleStockProxy
- Provides a stock service for product bundles.
Namespace
Drupal\commerce_product_bundle_stockCode
public function getIsInStock(PurchasableEntityInterface $bundle, array $locations) {
/** @var \Drupal\commerce\PurchasableEntityInterface $entity */
foreach ($this
->getAllPurchasableEntities($bundle) as $entity) {
$service = $this->stockServiceManager
->getService($entity);
$checker = $service
->getStockChecker();
if (!$checker
->getIsInStock($entity, $locations)) {
return FALSE;
}
}
return TRUE;
}