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
- class \Drupal\commerce_stock\StockServiceConfig implements StockServiceConfigInterface
Expanded class hierarchy of StockServiceConfig
File
- src/
StockServiceConfig.php, line 16
Namespace
Drupal\commerce_stockView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
StockServiceConfig:: |
protected | property | A list of stock locations. | |
StockServiceConfig:: |
public | function |
Get locations holding stock. Overrides StockServiceConfigInterface:: |
|
StockServiceConfig:: |
public | function |
Get the location for automatic stock allocation. Overrides StockServiceConfigInterface:: |