Created
July 10, 2020 19:05
-
-
Save bolderelements/9cb24c355c3c58d446f80c7257d809b4 to your computer and use it in GitHub Desktop.
Add tax subtext to Fees line similar to Subtotal and Shipping lines
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
/** | |
* Add tax subtext to Fees line | |
* Code snippets should be added to the functions.php file of your child theme | |
* | |
* @return string | |
*/ | |
add_filter( 'woocommerce_cart_totals_fee_html', 'add_tax_subtext_on_fees', 10, 2 ); | |
function add_tax_subtext_on_fees( $cart_totals_fee_html, $fee ) { | |
if( $fee->taxable ) { | |
if ( WC()->cart->display_prices_including_tax() ) { | |
if ( $fee->tax > 0 && ! wc_prices_include_tax() ) { | |
$cart_totals_fee_html .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>'; | |
} | |
} else { | |
if ( $fee->tax > 0 && wc_prices_include_tax() ) { | |
$cart_totals_fee_html .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>'; | |
} | |
} | |
} | |
return $cart_totals_fee_html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment