PHP Snippet 1:
add_filter( 'woocommerce_cart_totals_order_total_html', 'custom_cart_totals_order_total_html', 20, 1 );
function custom_cart_totals_order_total_html( $value ){
$value = '<strong>' . WC()->cart->get_total() . '</strong> ';
// If prices are tax inclusive, show taxes here.
$incl_tax_display_cart = version_compare( WC_VERSION, '3.3', '<' ) ? WC()->cart->tax_display_cart == 'incl' : WC()->cart->display_prices_including_tax();
if ( wc_tax_enabled() && $incl_tax_display_cart ) {
$tax_string_array = array();
$cart_tax_totals = WC()->cart->get_tax_totals();
if ( get_option( 'woocommerce_tax_total_display' ) == 'itemized' ) {
foreach ( $cart_tax_totals as $code => $tax ) {
$tax_string_array[] = sprintf( '%s %s', $tax->formatted_amount, $tax->label );
}
} elseif ( ! empty( $cart_tax_totals ) ) {
$tax_string_array[] = sprintf( '%s %s', wc_price( WC()->cart->get_taxes_total( true, true ) ), WC()->countries->tax_or_vat() );
}
if ( ! empty( $tax_string_array ) ) {
$taxable_address = WC()->customer->get_taxable_address();
$estimated_text = '';
$value .= '<small class="includes_tax">' . sprintf( __( '(includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) . $estimated_text ) . '</small>';
}
}
return $value;
}
PHP Snippet 2:
add_filter( 'woocommerce_cart_totals_order_total_html', function ($html) {
return substr($html, 0, strpos($html, '<small class="includes_tax">'));
}, 10, 2 );