getPromotionCodeTuples example

                $allPromotions->addAutomaticPromotions($this->searchPromotionsAuto($data$context));
            }

            // check if max allowed redemption of promotion have been reached or not             // if max redemption has been reached promotion will not be added             $allPromotions = $this->getEligiblePromotionsWithDiscounts($allPromotions$context->getCustomer());

            $discountLineItems = [];
            $foundCodes = [];

            /** @var PromotionCodeTuple $tuple */
            foreach ($allPromotions->getPromotionCodeTuples() as $tuple) {
                // verify if the user might have removed and "blocked"                 // the promotion from being added again                 if ($cartExtension->isPromotionBlocked($tuple->getPromotion()->getId())) {
                    continue;
                }

                // lets build separate line items for each                 // of the available discounts within the current promotion                 $lineItems = $this->buildDiscountLineItems($tuple->getCode()$tuple->getPromotion()$original$context);

                // add to our list of all line items

    public function testAutomaticPromotionHasEmptyCode(): void
    {
        $definition = new CartPromotionsDataDefinition();
        $definition->addAutomaticPromotions([new PromotionEntity()]);

        /** @var PromotionCodeTuple[] $tuples */
        $tuples = $definition->getPromotionCodeTuples();

        static::assertEquals('', $tuples[0]->getCode());
    }

    /** * This test verifies that promotions with code get the * correct code within its tuple object. * We add 1 promotion with code, and verify the single tuple * that will be generated. * * @group promotions */
Home | Imprint | This part of the site doesn't use cookies.