Skip to content

Instantly share code, notes, and snippets.

@TimBHowe
Created March 8, 2016 17:54
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TimBHowe/fe9418b9224d8b8cb339 to your computer and use it in GitHub Desktop.
Save TimBHowe/fe9418b9224d8b8cb339 to your computer and use it in GitHub Desktop.
Forcibly remove the tax line item and calculation from the cart. (suggest just using the GEO setting in WooCommerce)
<?php
// Remove the Tax Line item from the cart.
function wc_remove_cart_tax_totals( $tax_totals, $instance ) {
if( is_cart() ) {
$tax_totals = array();
}
return $tax_totals;
}
add_filter( 'woocommerce_cart_tax_totals', 'wc_remove_cart_tax_totals', 10, 2 );
// Show the cart total excluding tax.
function wc_exclude_tax_cart_total( $total, $instance ) {
// If it is the cart subtract the tax
if( is_cart() ) {
$total = round( WC()->cart->cart_contents_total + WC()->cart->shipping_total + WC()->cart->fee_total, WC()->cart->dp );
}
return $total;
}
add_filter( 'woocommerce_calculated_total', 'wc_exclude_tax_cart_total', 10, 2 );
add_filter( 'woocommerce_subscriptions_calculated_total', 'wc_exclude_tax_cart_total', 10, 2 );
@orlybondoc
Copy link

Hello, Tim.

I would like to ask how and is it possible to add a custom fee into the recurring totals for subscriptions?

I have tried the WC()->cart->add_fee but it only worked for the non subscription products.

Thank you

@BoyetDgte
Copy link

I have to say, even this is an old gist but up to now, it's still working! Thank you very much!

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