WC_Order::get_tax_refunded_for_item( int $item_id, int $tax_id, string $item_type = 'line_item' )
Get the refunded tax amount for a line item.
Description Description
Parameters Parameters
- $item_id
-
(Required) ID of the item we're checking.
- $tax_id
-
(Required) ID of the tax we're checking.
- $item_type
-
(Optional) Type of the item we're checking, if not a line_item.
Default value: 'line_item'
Return Return
(double)
Source Source
File: includes/class-wc-order.php
public function get_tax_refunded_for_item( $item_id, $tax_id, $item_type = 'line_item' ) { $total = 0; foreach ( $this->get_refunds() as $refund ) { foreach ( $refund->get_items( $item_type ) as $refunded_item ) { $refunded_item_id = (int) $refunded_item->get_meta( '_refunded_item_id' ); if ( $refunded_item_id === $item_id ) { $taxes = $refunded_item->get_taxes(); $total += isset( $taxes['total'][ $tax_id ] ) ? (float) $taxes['total'][ $tax_id ] : 0; break; } } } return wc_round_tax_total( $total ) * -1; }