I have done some development to add a price incl. tax input field at the order item level.
Here is the full code when I recalculate the item prices:
add_action( 'woocommerce_order_before_calculate_taxes', 'cvz_update_item_price', 10, 2);
function cvz_update_item_price( $args, $order ) {
$tax = new WC_Tax();
global $wpdb;
foreach( $order->get_items() as $item_key => $item ) {
if( ! is_numeric( $item->get_meta('_new_price_incl_tax') ) || $item->get_meta( 'fee_amount' )) continue;
$product = wc_get_product( $item['product_id'] );
$taxes = $tax->get_rates($product->get_tax_class());
$rates = array_shift( $taxes );
$item_rate = round( array_shift( $rates ));
$new_product_price = $item->get_meta('_new_price_incl_tax') + ( $item->get_meta( '_new_price_incl_tax' ) / ( 1 + $item_rate / 100 ) - $item->get_meta( '_new_price_incl_tax' ));
$product_quantity = (int) $item->get_quantity();
$new_line_item_price = $new_product_price * $product_quantity;
$item->set_subtotal( $new_line_item_price );
$item->set_total( $new_line_item_price );
$item->calculate_taxes();
$item->save();
/* FROM HERE ON IT BECOMES DIRTY */
$atum_subtotal = $wpdb->get_var("SELECT subtotal FROM `wp_atum_inventory_orders` WHERE order_item_id=$item_key" );
if( $atum_subtotal != NULL && $atum_subtotal != $new_line_item_price ) {
$wpdb->update( 'wp_atum_inventory_orders', array( 'subtotal' => $new_line_item_price ), array( 'order_item_id' => $item_key ));
$wpdb->update( 'wp_atum_inventory_orders', array( 'total' => $new_line_item_price ), array( 'order_item_id' => $item_key ));
}
}
}
My solution is perfectly working without an ATUM inventory, but as you can in the last lines, I had to fix it when there is an inventory.
We are not using any prices at inventory level at all, but ATUM always checks their own table to get the item price and overrides the item price input fields when I click on "Edit order item". This comes from your JS - it doesn't do that when I block this script: h/wp-content/plugins/atum-multi-inventory/assets/js/build/atum-mi-orders.js?ver=1.7.2
Is there a way that I don't need this hack? Why is the JS overwriting my order item price fields? They are updated in the database via the actions' Ajax call, but the JS doesn't know anything about it.