/** @var CartPromotionsDataDefinition $promotionsList */
$promotionsList =
$data->
get($keyCacheList);
// our data is a runtime cached structure.
// but when line items get removed, the collect function gets called multiple times.
// in the first iterations we still have a promotion code item
// and then it is suddenly gone. so we also have to remove
// entities from our cache if the code is suddenly not provided anymore.
/*
* @var string
*/
foreach ($promotionsList->
getAllCodes() as $code) { // if code is not existing anymore,
// make sure to remove it in our list
if (!\
in_array($code,
$allCodes, true
)) { $promotionsList->
removeCode((string) $code);
} } $codesToFetch =
[];
// let's find out what promotions we
// really need to fetch from our database.