You are here

interface AvailabilityManagerInterface in Commerce Core 8.2

Same name in this branch
  1. 8.2 src/AvailabilityManagerInterface.php \Drupal\commerce\AvailabilityManagerInterface
  2. 8.2 modules/order/src/AvailabilityManagerInterface.php \Drupal\commerce_order\AvailabilityManagerInterface

Runs the added checkers to determine the availability of an order item.

If any checker returns an "unavailable" availability result, the order item is considered to be unavailable.

Example checks:

  • Whether the entity is in stock.
  • Whether the entity's "available on" date is before the current date.

Hierarchy

Expanded class hierarchy of AvailabilityManagerInterface

All classes that implement AvailabilityManagerInterface

See also

\Drupal\commerce_order\AvailabilityCheckerInterface

1 file declares its use of AvailabilityManagerInterface
PurchasedEntityAvailableConstraintValidator.php in modules/order/src/Plugin/Validation/Constraint/PurchasedEntityAvailableConstraintValidator.php

File

modules/order/src/AvailabilityManagerInterface.php, line 21

Namespace

Drupal\commerce_order
View source
interface AvailabilityManagerInterface {

  /**
   * Adds a checker.
   *
   * @param \Drupal\commerce_order\AvailabilityCheckerInterface $checker
   *   The checker.
   */
  public function addChecker(AvailabilityCheckerInterface $checker);

  /**
   * Adds a "legacy" (i.e "deprecated") checker.
   *
   * @param \Drupal\commerce\AvailabilityCheckerInterface $checker
   *   The "legacy" (i.e "deprecated") checker.
   */
  public function addLegacyChecker(LegacyCheckerInterface $checker);

  /**
   * Checks the availability of the given order item.
   *
   * @param \Drupal\commerce_order\Entity\OrderItemInterface $order_item
   *   The order item.
   * @param \Drupal\commerce\Context $context
   *   The context.
   *
   * @return \Drupal\commerce_order\AvailabilityResult
   *   An AvailabilityResult value object determining whether an order item
   *   is available for purchase.
   */
  public function check(OrderItemInterface $order_item, Context $context) : AvailabilityResult;

}

Members

Namesort descending Modifiers Type Description Overrides
AvailabilityManagerInterface::addChecker public function Adds a checker.
AvailabilityManagerInterface::addLegacyChecker public function Adds a "legacy" (i.e "deprecated") checker. 1
AvailabilityManagerInterface::check public function Checks the availability of the given order item.