// 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
$addItems =
new LineItemQuantityCollection();
foreach ($items as $item) { if ($maxItems > self::UNLIMITED &&
$discountedItems >=
$maxItems) { break;
}