WC_Checkout::create_order_tax_lines() public WC 1.0
Add tax lines to the order.
{} Это метод класса: WC_Checkout{}
Возвращает
Null. Ничего.
Использование
$WC_Checkout = new WC_Checkout(); $WC_Checkout->create_order_tax_lines( $order, $cart );
- $order(WC_Order) (обязательный)
- Order instance.
- $cart(WC_Cart) (обязательный)
- Cart instance.
Код WC_Checkout::create_order_tax_lines() WC Checkout::create order tax lines WC 5.0.0
public function create_order_tax_lines( &$order, $cart ) {
foreach ( array_keys( $cart->get_cart_contents_taxes() + $cart->get_shipping_taxes() + $cart->get_fee_taxes() ) as $tax_rate_id ) {
if ( $tax_rate_id && apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) !== $tax_rate_id ) {
$item = new WC_Order_Item_Tax();
$item->set_props(
array(
'rate_id' => $tax_rate_id,
'tax_total' => $cart->get_tax_amount( $tax_rate_id ),
'shipping_tax_total' => $cart->get_shipping_tax_amount( $tax_rate_id ),
'rate_code' => WC_Tax::get_rate_code( $tax_rate_id ),
'label' => WC_Tax::get_rate_label( $tax_rate_id ),
'compound' => WC_Tax::is_compound( $tax_rate_id ),
'rate_percent' => WC_Tax::get_rate_percent_value( $tax_rate_id ),
)
);
/**
* Action hook to adjust item before save.
*
* @since 3.0.0
*/
do_action( 'woocommerce_checkout_create_order_tax_item', $item, $tax_rate_id, $order );
// Add item to order and save.
$order->add_item( $item );
}
}
}