You are here

public function DefaultOrderTypeResolver::resolve in Commerce Core 8.2

Resolves the order type.

Parameters

\Drupal\commerce_order\Entity\OrderItemInterface $order_item: The order item being added to an order.

Return value

string|null The order type ID, if resolved. Otherwise NULL, indicating that the next resolver in the chain should be called.

Overrides OrderTypeResolverInterface::resolve

File

modules/order/src/Resolver/DefaultOrderTypeResolver.php, line 33

Class

DefaultOrderTypeResolver
Returns the order type, based on order item type configuration.

Namespace

Drupal\commerce_order\Resolver

Code

public function resolve(OrderItemInterface $order_item) {

  /** @var \Drupal\commerce_order\Entity\OrderItemTypeInterface $order_item_type */
  $order_item_type = $this->orderItemTypeStorage
    ->load($order_item
    ->bundle());
  return $order_item_type
    ->getOrderTypeId();
}