// we now have a list of promotions that could be added to our cart.
// verify if they have any discounts. if so, add them to our
// data struct, which ensures that they will be added later in the enrichment process.
/** @var PromotionCodeTuple $tuple */
foreach ($dataDefinition->
getPromotionCodeTuples() as $tuple) { $promotion =
$tuple->
getPromotion();
if (!
$promotion->
isOrderCountValid()) { continue;
} if ($customer !== null && !
$promotion->
isOrderCountPerCustomerCountValid($customer->
getId())) { continue;
} // check if no discounts have been set
if (!
$promotion->
hasDiscount()) { continue;
} // now add it to our result definition object.
// we also have to remember the code that has been
// used for a particular promotion (if promotion is type of code).