if ($promotionDefinition === null
) { throw new UnknownPromotionDiscountTypeException($discount);
} // build our discount line item
// and make sure it has everything as dynamic content.
// this is necessary for the recalculation process.
$promotionItem =
new LineItem($discount->
getId(), PromotionProcessor::LINE_ITEM_TYPE
);
$promotionItem->
setLabel($promotion->
getTranslation('name'
));
$promotionItem->
setDescription($promotion->
getTranslation('name'
));
$promotionItem->
setGood(false
);
$promotionItem->
setRemovable(true
);
$promotionItem->
setPriceDefinition($promotionDefinition);
// always make sure we have a valid code entry.
// this helps us to identify the item by code later on.
// we use the one from the argument, because that one tells us why this
// promotion is added...it might not just be the promotion code, but
// one of the thousand individual codes for it...thus we have an
// external algorithm that makes our lookup why this promotion is added.
$promotionItem->
setReferencedId($code);
// add custom content to our payload.