invalidPercentageDiscount example


        return $this->items;
    }

    /** * @param float|PriceCollection|string|int|null $value */
    private function buildDiscountDefinition(string $type$value, string $key): PriceDefinitionInterface
    {
        if ($type === PercentagePriceDefinition::TYPE) {
            if ($value instanceof PriceCollection) {
                throw CartException::invalidPercentageDiscount($key);
            }
            $value = FloatComparator::cast((float) $value);

            return new PercentagePriceDefinition(abs($value) * -1);
        }
        if ($type !== AbsolutePriceDefinition::TYPE) {
            throw CartException::discountTypeNotSupported($key$type);
        }
        if (!$value instanceof PriceCollection) {
            throw CartException::absoluteDiscountMissingPriceCollection($key);
        }
        
Home | Imprint | This part of the site doesn't use cookies.