// if we are in recalculation,
// we must not re-add any promotions. just leave it as it is.
if ($behavior->
hasPermission(self::SKIP_PROMOTION
)) { return;
} // now get the codes from our configuration
// and also from our line items (that already exist)
// and merge them both into a flat list
$extensionCodes =
$cartExtension->
getCodes();
$cartCodes =
$original->
getLineItems()->
filterType(PromotionProcessor::LINE_ITEM_TYPE
)->
getReferenceIds();
$allCodes =
array_unique(array_merge(array_values($cartCodes),
$extensionCodes));
$allPromotions =
$this->
searchPromotionsByCodes($data,
$allCodes,
$context);
if (!
$behavior->
hasPermission(self::SKIP_AUTOMATIC_PROMOTIONS
)) { // add auto promotions
$allPromotions->
addAutomaticPromotions($this->
searchPromotionsAuto($data,
$context));
} // check if max allowed redemption of promotion have been reached or not