$affectedPrices =
$packages->
getAffectedPrices();
$calculatedPrice =
$this->percentagePriceCalculator->
calculate( $definedPercentage,
$affectedPrices,
$context );
// if our percentage discount has a maximum
// threshold, then make sure to reduce the calculated
// discount price to that maximum value.
if ($this->
hasMaxValue($discount)) { $maxValue =
(float) $discount->
getPayloadValue('maxValue'
);
$actualDiscountPrice =
$calculatedPrice->
getTotalPrice();
// check if our actual discount is higher than the maximum one
if (abs($actualDiscountPrice) >
abs($maxValue)) { $calculatedPrice =
$this->absolutePriceCalculator->
calculate( -
abs($maxValue),
$affectedPrices,
$context );