9

I need to get all discounted price from each cart rule which is applied on current quote. I am getting applied rule ids from $quote->getAppliedRuleIds() and I am getting total discounted amount but I am not sure how can I get discount price of each rule if multiple rules applied to quote.

For example, in quote 3 cart rules applied and each cart rule has different discount(10+20+30) at the code level I am getting total discount amount 60 which is correct but I need (10+20+30) as separate.

Is there any way to get this?

2 Answers 2

0

Try this,

Inject \Magento\Checkout\Model\Cart class

$items = $cart->getQuote()->getAllItems();

  foreach ($items as $item) {
    $discountAmt = $item->getDiscountAmount(); //$item(get all information)
  }

Thanks!

0

Please try this, loop through the quote visible items,
we will get the discount amount per item-wise.

$cartItems = $quote->getAllVisibleItems();
foreach ($cartItems as $item) {
$itemDiscountAmount = $item->getDiscountAmount();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.