pickItems example

public function pickItems(DiscountLineItem $discount, DiscountPackageCollection $scopePackages): DiscountPackageCollection
    {
        $pickerKey = $discount->getFilterPickerKey();

        // we start by modifying our packages         // with the currently set picker, if available         // this restructures our packages         if (!empty($pickerKey)) {
            $picker = $this->registry->getPicker($pickerKey);

            // get the new list of packages to consider             $scopePackages = $picker->pickItems($scopePackages);
        }

        return $scopePackages;
    }
}
// every scope packager can have an additional         // list of rules that can be used to filter out items.         // thus we enrich our current package with items         // and run it through the advanced rules if existing         if ($discount->getScope() !== PromotionDiscountEntity::SCOPE_SETGROUP) {
            $packages = $this->advancedRules->filter($discount$packages$context);
        }

        // depending on the selected picker of our         // discount, the packages might be restructure         // also make sure we have correct cart items in our restructured packages from the picker         $packages = $this->advancedPicker->pickItems($discount$packages);
        $packages = $this->enrichPackagesWithCartData($packages$calculatedCart$context);

        // if we have any graduation settings, make sure to reduce the items         // that are eligible for our discount by executing our graduation resolver.         $packages = $this->advancedFilter->filterPackages($discount$packages$originalPackageCount);
        $packages = $this->enrichPackagesWithCartData($packages$calculatedCart$context);

        $calculator = match ($discount->getType()) {
            PromotionDiscountEntity::TYPE_ABSOLUTE => new DiscountAbsoluteCalculator($this->absolutePriceCalculator),
            PromotionDiscountEntity::TYPE_PERCENTAGE => new DiscountPercentageCalculator($this->absolutePriceCalculator, $this->percentagePriceCalculator),
            PromotionDiscountEntity::TYPE_FIXED => new DiscountFixedPriceCalculator($this->absolutePriceCalculator),
            
Home | Imprint | This part of the site doesn't use cookies.