You are here

public function StockServiceConfig::getTransactionLocation in Commerce Stock 8

Get the location for automatic stock allocation.

This is normally a designated location to act as the main warehouse. This can also be a location worked out in realtime using the provided context (order & customer), entity and the quantity requested.

Parameters

\Drupal\commerce\Context $context: The context containing the customer & store.

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

int $quantity: The quantity.

Return value

\Drupal\commerce_stock\StockLocationInterface The stock location.

Overrides StockServiceConfigInterface::getTransactionLocation

File

src/StockServiceConfig.php, line 35

Class

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

Namespace

Drupal\commerce_stock

Code

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