Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

orlybondoc commented Sep 29, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.