These post is related with Add a custom total line to WooCommerce admin order totals
Hello
I'm trying to hide Subtotal, but I can not find the class in CSS like:
.cart-subtotal { display: none; }
.order-total { display: none; }
.order_shipping_line_items {display: none;}
It doesnt work.
Now I'm trying to unset with these code, but it doesn't work too:
add_filter( 'woocommerce_get_order_item_totals', 'reordering_order_item_totals', 10, 3 );
function reordering_order_item_totals( $total_rows, $order, $tax_display ){
$shipping = $total_rows['line_subtotal'];
$order_total = $total_rows['order_total'];
unset($total_rows['line_subtotal']);
unset($total_rows['order_total']);
return $total_rows;
}
I try to reorder the fields and hide fields in the order of request.
To hide original subtotal line From admin order total lines, use the following:
add_action('admin_head', 'admin_head_shop_order_inline_css' );
function admin_head_shop_order_inline_css() {
global $pagenow, $typenow;
// Targeting WooCommerce admin single orders
if ( in_array( $pagenow, ['post.php', 'post-new.php'] ) && $typenow === 'shop_order' ) :
?><style>table.wc-order-totals tr:first-child{display:none;}</style><?php
endif;
}
Code goes in functions.php file of your child theme (or in a plugin). Tested and works.
Note: As all Admin Order total lines HTML are hard-coded in this file, you can not reorder them.
To hide "Envio" shipping total line too, replace the code with:
add_action('admin_head', 'admin_head_shop_order_inline_css' );
function admin_head_shop_order_inline_css() {
global $pagenow, $typenow;
// Targeting WooCommerce admin single orders
if ( in_array( $pagenow, ['post.php', 'post-new.php'] ) && $typenow === 'shop_order' ) :
?><style>
table.wc-order-totals tr:first-child,
table.wc-order-totals tr:nth-child(4){display:none;}
</style><?php
endif;
}
Code goes in functions.php file of your child theme (or in a plugin). Tested and works.