WC_Abstract_Legacy_Order::add_tax() public WC 1.0
Add a tax row to the order.
{} Это метод класса: WC_Abstract_Legacy_Order{}
Хуков нет.
Возвращает
Число. order item ID
Использование
$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(число) (обязательный)
- -
- $tax_amount(число)
- amount of tax.
- $shipping_tax_amount(число)
- shipping amount.
Код WC_Abstract_Legacy_Order::add_tax() WC Abstract Legacy Order::add tax WC 5.0.0
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();
}