We need to calculate the shipping charge without tax in some condition on WordPress WooCommerce.
Our rule was if user order amount < 50 then shipping charge would be $5 + tax 12%. Its runs fine.
But when we attempt to fire the rule that if user order amount > 50 then shipping charge would be -$5(-) but WooCommerce automatically added the tax -12%(-) with the shipping charge. We could not remove the tax -12%.
Here is our code:
$item = new WC_Order_Item_Shipping();
$item->set_props(
array(
'method_title' => "test",
'method_id' => "test",
'cost' => -5,
'taxes' => array(),
'tax' => array(),
'calc_tax' => 'per_order',
'total' => -5,
'tax_class' => NULL,
'total_tax' => 0,
'tax_status' => 'none',
'meta_data' => array(),
'package' => false,
)
);
$order->add_item( $item );
$order->calculate_totals();
$order->save();
Please advice us.