/** @var string $label */
$label =
$item->
getLabel();
/** @var PriceDefinitionInterface $priceDefinition */
$priceDefinition =
$item->
getPriceDefinition();
$discount =
new DiscountLineItem( $label,
$priceDefinition,
$item->
getPayload(),
$item->
getReferencedId() );
$packager =
match ($discount->
getScope()) { PromotionDiscountEntity::SCOPE_CART =>
$this->cartScopeDiscountPackager,
PromotionDiscountEntity::SCOPE_SET =>
$this->setScopeDiscountPackager,
PromotionDiscountEntity::SCOPE_SETGROUP =>
$this->setGroupScopeDiscountPackager,
default =>
throw new InvalidScopeDefinitionException($discount->
getScope()),
};
$packages =
$packager->
getMatchingItems($discount,
$calculatedCart,
$context);