InvalidScopeDefinitionException example

$discount = new DiscountLineItem(
            $label,
            $priceDefinition,
            $item->getPayload(),
            $item->getReferencedId()
        );

        $packager = match ($discount->getScope()) {
            PromotionDiscountEntity::SCOPE_CART => $this->cartScopeDiscountPackager,
            PromotionDiscountEntity::SCOPE_SET => $this->setScopeDiscountPackager,
            PromotionDiscountEntity::SCOPE_SETGROUP => $this->setGroupScopeDiscountPackager,
            default => throw new InvalidScopeDefinitionException($discount->getScope()),
        };

        $packages = $packager->getMatchingItems($discount$calculatedCart$context);

        // check if no result is found,         // then this would mean -> no discount         if ($packages->count() <= 0) {
            return new DiscountCalculatorResult(
                new CalculatedPrice(0, 0, new CalculatedTaxCollection()new TaxRuleCollection(), 1),
                []
            );
        }
Home | Imprint | This part of the site doesn't use cookies.