isOrderCountValid example

private function getEligiblePromotionsWithDiscounts(CartPromotionsDataDefinition $dataDefinition, ?CustomerEntity $customer): CartPromotionsDataDefinition
    {
        $result = new CartPromotionsDataDefinition();

        // we now have a list of promotions that could be added to our cart.         // verify if they have any discounts. if so, add them to our         // data struct, which ensures that they will be added later in the enrichment process.         /** @var PromotionCodeTuple $tuple */
        foreach ($dataDefinition->getPromotionCodeTuples() as $tuple) {
            $promotion = $tuple->getPromotion();

            if (!$promotion->isOrderCountValid()) {
                continue;
            }

            if ($customer !== null && !$promotion->isOrderCountPerCustomerCountValid($customer->getId())) {
                continue;
            }

            // check if no discounts have been set             if (!$promotion->hasDiscount()) {
                continue;
            }

            
Home | Imprint | This part of the site doesn't use cookies.