public function buildDiscountLineItem(string
$code, PromotionEntity
$promotion, PromotionDiscountEntity
$discount, string
$currencyId, float
$currencyFactor = 1.0
): LineItem
{ // get the rules collection of discount
$discountRuleCollection =
$discount->
getDiscountRules();
// this is our target Filter that may be null if discount has no filters
$targetFilter = null;
// we do only need to build a target rule if user has allowed it
// and the rule collection is not empty
if ($discountRuleCollection instanceof RuleCollection &&
$discount->
isConsiderAdvancedRules() &&
$discountRuleCollection->
count() > 0
) { $targetFilter =
new OrRule();
foreach ($discountRuleCollection as $discountRule) { /** @var Rule|string|null $rule */
$rule =
$discountRule->
getPayload();
if ($rule instanceof Rule
) { $targetFilter->
addRule($rule);
} } }