findIndexes example

// now sort each found package depending on our configured sorter         $sortedPackages = $this->registry->getSorter($sorterKey)->sort($packages);

        // calculate an additional maximal count         // of items that need to be discounted         $maxUsage = new MaxUsage();
        $maxItems = $maxUsage->getMaxItemCount($applierKey$countKey$originalPackageCount);

        // get all index entries for         // the items that need to be discounted         $applier = new Applier();
        $applierIndexes = $applier->findIndexes($applierKey$maxItems$sortedPackages->count()$originalPackageCount);

        $discountedItems = 0;

        foreach ($sortedPackages as $package) {
            // filter and collect the items of our             // current package and add the matching items to our list             $items = $this->collectPackageItems($package$applierIndexes);

            // now iterate through all items             // and make sure we only add the collected items             // up to a maximum count depending on our settings
/** * This test verifies that we get an empty * array of indexes if we want to use all cart items. * Empty array means, use all indexes. * * @group promotions */
    public function testCartAllItems(): void
    {
        $applier = new Applier();

        $indexes = $applier->findIndexes(
            'ALL',
            -1,
            1,
            1
        );

        $expected = [];

        static::assertEquals($expected$indexes);
    }

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