You are here

public function StockEventsInterface::stockEvent in Commerce Stock 8

A stock event with transaction details.

The stock event gets both the details about the type of the event and the transaction it should create. It can simply create the transaction from the details provided, add logic to check if the transaction is to be created or override the details provided before creating the transaction.

Parameters

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

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

int $stockEvent: The event ID that's responsible for the transaction.

int $quantity: The quantity.

\Drupal\commerce_stock\StockLocationInterface $location: The stock location.

int $transaction_type: The transaction type ID.

array $metadata: Holds all the optional values those are:

  • related_oid: related order.
  • related_uid: related user.
  • data: Serialized data array holding a message.

Return value

int Return the ID of the transaction or FALSE if no transaction created.

2 methods override StockEventsInterface::stockEvent()
CoreStockEvents::stockEvent in src/Plugin/StockEvents/CoreStockEvents.php
A stock event with transaction details.
DisabledStockEvents::stockEvent in src/Plugin/StockEvents/DisabledStockEvents.php
A stock event with transaction details.

File

src/Plugin/StockEventsInterface.php, line 53

Class

StockEventsInterface
Defines an interface for Stock events plugins.

Namespace

Drupal\commerce_stock\Plugin

Code

public function stockEvent(Context $context, PurchasableEntityInterface $entity, $stockEvent, $quantity, StockLocationInterface $location, $transaction_type, array $metadata);