I was confused by some of the parameters that are required by the StockTransactionsInterface::createTransaction method.

https://git.drupalcode.org/project/commerce_stock/-/blob/8.x-1.x/src/StockTransactionsInterface.php?ref_type=heads#L88

/**
   * Receive stock.
   *
   * @param \Drupal\commerce\PurchasableEntityInterface $entity
   *   The purchasable entity (most likely a product variation entity).
   * @param int $location_id
   *   The location ID.
   * @param string $zone
   *   The zone.
   * @param float $quantity
   *   The quantity.
   * @param float $unit_cost
   *   The unit cost.
   * @param string $currency_code
   *   The currency code.
   * @param string $message
   *   The message.
   */
  public function receiveStock(PurchasableEntityInterface $entity, $location_id, $zone, $quantity, $unit_cost, $currency_code, $message = NULL);
  • What is a "zone". I'm not familiar with the terminology within Drupal so hesitated not knowing whether this is something it would be "safe" to leave blank.
  • Why are $unit_cost and $currency_code needed? Is it purely for logging, or is it going to have an impact on sales figures?

Appreciate that answers can probably be worked out by examining the code base but it would be helpful documenting in code, in my opinion.

Comments

leo pitt created an issue.