Skip to content

Getting order items discount amount returns 0, but order discount returns right amount?

Magento 2.4.6

I ordered an item and applied a coupon code in checkout. I got a discount of $1.50. This amount is shown in the item on the order detail page as well as in the order totals.

Now, trying to get that discount on item level fails:

foreach ($order->getAllItems() as $orderItem) {
    var_dump($orderItem->getDiscountAmount());
}

The var_dump always gives me 0. Calling $order->getDiscountAmount(); on the other hand is giving me the $1.50 … so the question is, how can I get the amount for the item on item level? I also tried calling getOriginalPrice() or getPrice(), both return 0.

What am I doing wrong here?