WC_Abstract_Legacy_Order::add_tax PHP Method

add_tax() public method

Add a tax row to the order.
public add_tax ( $tax_rate_id, integer $tax_amount, integer $shipping_tax_amount ) : integer
$tax_amount integer amount of tax.
$shipping_tax_amount integer shipping amount.
return integer order item ID
    public function add_tax($tax_rate_id, $tax_amount = 0, $shipping_tax_amount = 0)
    {
        wc_deprecated_function('WC_Order::add_tax', '2.7', 'Create new WC_Order_Item_Tax object and add to order with WC_Order::add_item()');
        $item = new WC_Order_Item_Tax();
        $item->set_props(array('rate_id' => $tax_rate_id, 'tax_total' => $tax_amount, 'shipping_tax_total' => $shipping_tax_amount));
        $item->set_rate($tax_rate_id);
        $item->set_order_id($this->get_id());
        $item->save();
        $this->add_item($item);
        wc_do_deprecated_action('woocommerce_order_add_tax', array($this->get_id(), $item->get_id(), $tax_rate_id, $tax_amount, $shipping_tax_amount), '2.7', 'Use woocommerce_new_order_item action instead.');
        return $item->get_id();
    }