if (!
$priceDefinition instanceof AbsolutePriceDefinition
) { throw new InvalidPriceDefinitionException($discount->
getLabel(),
$discount->
getCode());
} $fixedUnitPrice =
abs($priceDefinition->
getPrice());
$totalDiscountSum = 0.0;
$composition =
[];
foreach ($packages as $package) { foreach ($package->
getCartItems() as $lineItem) { if ($lineItem->
getPrice() === null
) { continue;
} $quantity =
$lineItem->
getQuantity();
$itemUnitPrice =
$lineItem->
getPrice()->
getUnitPrice();
if ($itemUnitPrice >
$fixedUnitPrice) { // check if discount exceeds or not, beware of quantity
$discountDiffPrice =
($itemUnitPrice -
$fixedUnitPrice) *
$quantity;
// add to our total discount sum