You are here

class StockServiceConfig in Commerce Stock 8

The default stock service configuration class. This class does nothing meaningful and act as a stub to fullfil the StockServiceInterface for the AlwaysInStockService.

For a more meaningful example see the LocalStockServiceConfig class in the local_storage submodule.

Hierarchy

Expanded class hierarchy of StockServiceConfig

File

src/StockServiceConfig.php, line 16

Namespace

Drupal\commerce_stock
View source
class StockServiceConfig implements StockServiceConfigInterface {

  /**
   * A list of stock locations.
   *
   * @var array
   */
  protected $stockLocations = [];

  /**
   * {@inheritdoc}
   */
  public function getAvailabilityLocations(Context $context, PurchasableEntityInterface $entity) {
    return $this->stockLocations;
  }

  /**
   * {@inheritdoc}
   */
  public function getTransactionLocation(Context $context, PurchasableEntityInterface $entity, $quantity) {
    $locations = $this
      ->getAvailabilityLocations($context, $entity);
    return array_shift($locations);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StockServiceConfig::$stockLocations protected property A list of stock locations.
StockServiceConfig::getAvailabilityLocations public function Get locations holding stock. Overrides StockServiceConfigInterface::getAvailabilityLocations
StockServiceConfig::getTransactionLocation public function Get the location for automatic stock allocation. Overrides StockServiceConfigInterface::getTransactionLocation