You are here

public function ProductBundleStockProxy::getIsAlwaysInStock in Commerce Product Bundle 8

Check if entity is always in stock.

Parameters

\Drupal\commerce\PurchasableEntityInterface $entity: The purchasable entity.

Return value

bool TRUE if the entity is always in stock, FALSE otherwise.

Overrides StockCheckInterface::getIsAlwaysInStock

File

modules/commerce_product_bundle_stock/src/ProductBundleStockProxy.php, line 104

Class

ProductBundleStockProxy
Provides a stock service for product bundles.

Namespace

Drupal\commerce_product_bundle_stock

Code

public function getIsAlwaysInStock(PurchasableEntityInterface $bundle) {

  /** @var \Drupal\commerce\PurchasableEntityInterface $entity */
  $entities = $this
    ->getAllPurchasableEntities($bundle);
  foreach ($entities as $entity) {
    xdebug_break();
    $service = $this->stockServiceManager
      ->getService($entity);
    $checker = $service
      ->getStockChecker();
    if (!$checker
      ->getIsAlwaysInStock($entity)) {
      return FALSE;
    }
  }
  return TRUE;
}