Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Created February 22, 2016 13:07
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mikejolley/e73f9d061aaebd25ccdc to your computer and use it in GitHub Desktop.
Save mikejolley/e73f9d061aaebd25ccdc to your computer and use it in GitHub Desktop.
WooCommerce - Remove subtotal row.
add_filter( 'woocommerce_get_order_item_totals', 'adjust_woocommerce_get_order_item_totals' );
function adjust_woocommerce_get_order_item_totals( $totals ) {
unset($totals['cart_subtotal'] );
return $totals;
}
@daan-janssen
Copy link

Thank you, this works pretty fine!

@christ12345
Copy link

I added this code to theme functions.php but does not work, subtotal still there

@PiotrKrzyzek
Copy link

Indeed: this code did not work. Cart Sub-total is still showing on the cart page.

@mstudioIL
Copy link

I also think it do not work

Copy link

ghost commented May 15, 2017

@christ12345 @PiotrKrzyzek @mstudioIL
To hide the "Subtotal:" row on the Cart and Checkout pages, add this code to style.css:
.cart-subtotal {display: none;}
upd. @mikejolley's code removes the "Subtotal:" row from the Order Received page (and, therefore, from emails).

@Wooody82
Copy link

Wooody82 commented Dec 10, 2017

Did u try to hook to woocommerce_cart_item_subtotal ?
something like this:
function cart_subtotal_func_unset( $total ) {
unset($totals['cart_subtotal']);
return $totals;
}
add_filter('woocommerce_cart_item_subtotal', 'cart_subtotal_func_unset', 10, 2);

@jaibojo
Copy link

jaibojo commented Feb 15, 2018

@DanBeezy, It still shows in mobile, how to hide it in mobile also.

@ewolfy
Copy link

ewolfy commented Oct 26, 2018

@jaibojo

To remove Subtotal row (in mobile also) add this code to style.css
.cart-subtotal { display: none !important; }

@wesleygoldsborough
Copy link

This is the answer for removing the subtotal from the cart and checkout pages
https://stackoverflow.com/questions/53277895/remove-subtotal-line-from-cart-and-checkout-pages-in-woocommerce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment