public function getDecorated(): DiscountPackager
{ throw new DecorationPatternException(self::
class);
} /**
* Gets all product line items of the entire cart that
* match the rules and conditions of the provided discount item.
*/
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([]);
}