-
-
Save pablo-sg-pacheco/c9ef96962a4470e1c20edf3f6e72a3fa 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 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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment