I see when I look at an order it will show the specific item that was refunded if the whole order wasn't.
Is there a way to find using the WC_Order_Item_Product
if an item was refunded? Also, is there a way to get the discount amount that shows up below the item in the order view?
I'm currently doing it manually but if there is a function for it already, I would rather use it.
To get the order refunds you you use some dedicated
WC_Order
methods like the following ones that have the Item ID as argument:You can access an array
WC_Order_Refund
Objects for this order usingget_refunds()
method:WC_Order_Refund
methods.WC_Abstract_Order
methodget_items()
that will give you the refunded items for the current Order refund.WC_Order_Item_Product
(with negative values in general) see this related answer: Get Order items and WC_Order_Item_Product in Woocommerce 3So you can use the following example code:
To get the order items discounted values that appear in admin order edit pages you will use the following code:
Related Answers: