/** * {@inheritdoc} */ public function create(array $options = []) { $options = $this->optionsResolver->resolve($options); /** @var PromotionRuleInterface $promotionRule */ $promotionRule = $this->promotionRuleFactory->createNew(); $promotionRule->setType($options['type']); $promotionRule->setConfiguration($options['configuration']); return $promotionRule; }
/** * @Given /^([^"]+) gives ("[^"]+%") off on every product (classified as "[^"]+" or "[^"]+") if order contains any product (classified as "[^"]+" or "[^"]+")$/ */ public function itGivesOffOnEveryProductClassifiedAsOrIfOrderContainsAnyProductClassifiedAsOr(PromotionInterface $promotion, $discount, array $discountTaxons, array $targetTaxons) { $discountTaxonsCodes = [$discountTaxons[0]->getCode(), $discountTaxons[1]->getCode()]; $targetTaxonsCodes = [$targetTaxons[0]->getCode(), $targetTaxons[1]->getCode()]; $rule = $this->ruleFactory->createTaxon($targetTaxonsCodes); $this->createUnitPercentagePromotion($promotion, $discount, $this->getTaxonFilterConfiguration($discountTaxonsCodes), $rule); }
/** * @Given /^([^"]+) gives ("[^"]+%") off the order for customers from ("[^"]*" group)$/ */ public function thePromotionGivesOffTheOrderForCustomersFromGroup(PromotionInterface $promotion, $discount, CustomerGroupInterface $customerGroup) { $rule = $this->ruleFactory->createNew(); $rule->setType(CustomerGroupRuleChecker::TYPE); $rule->setConfiguration(['group_code' => $customerGroup->getCode()]); $this->createPercentagePromotion($promotion, $discount, [], $rule); }
/** * @Given /^([^"]+) gives ("(?:€|£|\$)[^"]+") off if order contains (?:a|an) ("[^"]+" product)$/ */ public function thePromotionGivesOffIfOrderContainsProducts(PromotionInterface $promotion, $discount, ProductInterface $product) { $rule = $this->ruleFactory->createContainsProduct($product->getCode()); $this->createFixedPromotion($promotion, $discount, [], $rule); }