// based on our discount definition.
// the basis might only be from a few items and quantities of the cart
$assessmentBasis =
$affectedPrices->
sum()->
getTotalPrice();
// we have to get our new fictional and lower percentage.
// we now calculate the percentage with MAX VALUE against our basis
// to get the percentage to reach only the max value.
$definedPercentage =
($maxValue /
$assessmentBasis) * 100;
} } $composition =
$this->
getCompositionItems($definedPercentage,
$packages);
return new DiscountCalculatorResult($calculatedPrice,
$composition);
} /**
* @return DiscountCompositionItem[]
*/
private function getCompositionItems(float
$percentage, DiscountPackageCollection
$packages): array
{ $items =
[];