WC_Order::get_tax_refunded_for_item PHP Method

get_tax_refunded_for_item() public method

Get the refunded amount for a line item.
public get_tax_refunded_for_item ( integer $item_id, integer $tax_id, string $item_type = 'line_item' ) : double
$item_id integer ID of the item we're checking
$tax_id integer ID of the tax we're checking
$item_type string type of the item we're checking, if not a line_item
return double
    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) {
                if (absint($refunded_item->get_meta('_refunded_item_id')) === $item_id) {
                    $total += $refunded_item->get_total_tax();
                }
            }
        }
        return wc_round_tax_total($total) * -1;
    }

Usage Example

示例#1
0
 /**
  * Test: get_tax_refunded_for_item
  */
 function test_get_tax_refunded_for_item()
 {
     $object = new WC_Order();
     $this->assertEquals(0, $object->get_tax_refunded_for_item(1, 1));
 }
WC_Order