WC_Order::get_qty_refunded_for_item( int $item_id, string $item_type = 'line_item' )

Get the refunded amount for a line item.


Description Description


Parameters Parameters

$item_id

(Required) ID of the item we're checking.

$item_type

(Optional) Type of the item we're checking, if not a line_item.

Default value: 'line_item'


Top ↑

Return Return

(int)


Top ↑

Source Source

File: includes/class-wc-order.php

1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
public function get_qty_refunded_for_item( $item_id, $item_type = 'line_item' ) {
    $qty = 0;
    foreach ( $this->get_refunds() as $refund ) {
        foreach ( $refund->get_items( $item_type ) as $refunded_item ) {
            if ( absint( $refunded_item->get_meta( '_refunded_item_id' ) ) === $item_id ) {
                $qty += $refunded_item->get_quantity();
            }
        }
    }
    return $qty;
}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.