You are here

protected function BuyXGetY::buildConditionGroup in Commerce Core 8.2

Builds a condition group for the given condition configuration.

Parameters

array $condition_configuration: The condition configuration.

Return value

\Drupal\commerce\ConditionGroup The condition group.

1 call to BuyXGetY::buildConditionGroup()
BuyXGetY::apply in modules/promotion/src/Plugin/Commerce/PromotionOffer/BuyXGetY.php
Applies the offer to the given entity.

File

modules/promotion/src/Plugin/Commerce/PromotionOffer/BuyXGetY.php, line 487

Class

BuyXGetY
Provides the "Buy X Get Y" offer for orders.

Namespace

Drupal\commerce_promotion\Plugin\Commerce\PromotionOffer

Code

protected function buildConditionGroup(array $condition_configuration) {
  $conditions = [];
  foreach ($condition_configuration as $condition) {
    if (!empty($condition['plugin'])) {
      $conditions[] = $this->conditionManager
        ->createInstance($condition['plugin'], $condition['configuration']);
    }
  }
  return new ConditionGroup($conditions, 'OR');
}