Created
March 8, 2016 17:54
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
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
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