WordPress at Your Fingertips
function is not described

WC_Abstract_Legacy_Order::add_tax() public WC 1.0

Add a tax row to the order.

{} It's a method of the class: WC_Abstract_Legacy_Order{}

No Hooks.

Return

Int. order item ID

Usage

$WC_Abstract_Legacy_Order = new WC_Abstract_Legacy_Order();
$WC_Abstract_Legacy_Order->add_tax( $tax_rate_id, $tax_amount, $shipping_tax_amount );
$tax_rate_id(int) (required)
-
$tax_amount(int)
amount of tax.
$shipping_tax_amount(int)
shipping amount.

Code of WC_Abstract_Legacy_Order::add_tax() WC 5.5.2

<?php
public function add_tax( $tax_rate_id, $tax_amount = 0, $shipping_tax_amount = 0 ) {
	wc_deprecated_function( 'WC_Order::add_tax', '3.0', 'a 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 ), '3.0', 'woocommerce_new_order_item action instead.' );
	return $item->get_id();
}