public function getMatchingItems(DiscountLineItem
$discount, Cart
$cart, SalesChannelContext
$context): DiscountPackageCollection
{ $allItems =
$cart->
getLineItems()->
filter(fn (LineItem
$lineItem) =>
$lineItem->
getType() === LineItem::PRODUCT_LINE_ITEM_TYPE &&
$lineItem->
isStackable());
$priceDefinition =
$discount->
getPriceDefinition();
if ($priceDefinition instanceof FilterableInterface &&
$priceDefinition->
getFilter()) { $allItems =
$allItems->
filter(fn (LineItem
$lineItem) =>
$priceDefinition->
getFilter()->
match(new LineItemScope($lineItem,
$context)));
} $discountPackage =
$this->
getDiscountPackage($allItems);
if ($discountPackage === null
) { return new DiscountPackageCollection([]);
} return new DiscountPackageCollection([$discountPackage]);
} private function getDiscountPackage(LineItemCollection
$cartItems): ?DiscountPackage
{ $discountItems =
[];
foreach ($cartItems as $cartLineItem) {