$lineItems =
$toCalculate->
getLineItems()->
filterType(PromotionProcessor::LINE_ITEM_TYPE
)->
filter(fn ($discountLineItem) =>
$discountLineItem->
getId() ===
$discount->
getId());
// if we have a line item in cart for this discount, it is already stored and we do not need to add
// another lineitem
if ($lineItems->
count() > 0
) { return;
} $priceDefinition =
new QuantityPriceDefinition(0,
new TaxRuleCollection(), 1
);
$price =
$this->quantityPriceCalculator->
calculate($priceDefinition,
$context);
$promotionItem =
$this->builder->
buildDeliveryPlaceholderLineItem($discount,
$priceDefinition,
$price);
$toCalculate->
addLineItems(new LineItemCollection([$promotionItem]));
} private function isAutomaticDisount(LineItem
$discountItem): bool
{ return empty($discountItem->
getPayloadValue('code'
));
}}