You are here

public function StockServiceManager::createTransaction in Commerce Stock 8

Create a transaction.

Parameters

\Drupal\commerce\PurchasableEntityInterface $entity: The purchasable entity (most likely a product variation entity).

int $location_id: The location ID.

string $zone: The zone.

float $quantity: The quantity.

float $unit_cost: The unit cost.

string $currency_code: The currency code.

int $transaction_type_id: Transaction type ID.

array $metadata: A metadata array.

Overrides StockTransactionsInterface::createTransaction

File

src/StockServiceManager.php, line 125

Class

StockServiceManager
The stock service manager.

Namespace

Drupal\commerce_stock

Code

public function createTransaction(PurchasableEntityInterface $entity, $location_id, $zone, $quantity, $unit_cost, $currency_code, $transaction_type_id, array $metadata = []) {
  $stock_updater = $this
    ->getService($entity)
    ->getStockUpdater();
  $stock_updater
    ->createTransaction($entity, $location_id, $zone, $quantity, $unit_cost, $currency_code, $transaction_type_id, $metadata);
}