WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Woocommerce] how to ONLY show tax below subtotal? (2 posts)

  1. Amsterdammer
    Member
    Posted 1 year ago #

    Could someone please find a solution to my "total taxes" problem (inside totals.php of Woocommerce plugin). I am lost.

    Below subtotal I ONLY want to show tax (21% of subtotal) instead of total + tax.

    Default =
    Subtotal: €100,00
    Order total: €79,00
    (Includes €21,00 taxes)

    Currently =
    Subtotaal : €100,00
    Tax (21%) : €79,00 €21,00

    Mijn goal =
    Subtotal : €100,00
    Tax (21%) : €21,00

    In short: how to hide €79,00?

    Default=

    <?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
    
    <tr class="total">
    				<th><strong><?php _e( 'Order Total', 'woocommerce' ); ?></strong></th>
    				<td>
    					<strong><?php echo $woocommerce->cart->get_total(); ?></strong>
    					<?php
    						// If prices are tax inclusive, show taxes here
    						if ( $woocommerce->cart->tax_display_cart == 'incl' ) {
    							$tax_string_array = array();
    
    							foreach ( $woocommerce->cart->get_tax_totals() as $code => $tax ) {
    								$tax_string_array[] = sprintf( '%s %s', $tax->formatted_amount, $tax->label );
    							}
    
    							if ( ! empty( $tax_string_array ) ) {
    								?><small class="includes_tax"><?php printf( __( '(Includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) ); ?></small><?php
    							}
    						}
    					?>

    Currently=

    <?php do_action( 'woocommerce_cart_totals_before_order_total' ); ?>
    
    				<tr class="total">
    					<th><strong><?php _e( 'Tax (21%)', 'woocommerce' ); ?></strong></th>
    					<td>
    						<strong><?php echo $woocommerce->cart->get_total(); ?></strong>
    						<?php
    							// If prices are tax inclusive, show taxes here
    							if (  $woocommerce->cart->tax_display_cart == 'incl' ) {
    								$tax_string_array = array();
    
    								foreach ( $woocommerce->cart->get_tax_totals() as $code => $tax ) {
    									$tax_string_array[] = sprintf( '%s', $tax->formatted_amount, $tax->label );
    								}
    
    								if ( ! empty( $tax_string_array ) ) {
    									echo '<span class="amount">' . sprintf( __( '%s', 'woocommerce' ), implode( ', ', $tax_string_array ) ) . '</span>';
    								}
    							}
    						?>

    I've been working on this problem for hours, so far no luck.. at all :(

  2. Amsterdammer
    Member
    Posted 1 year ago #

    Think I'm going blind.

    Just had to remove

    <strong><?php echo $woocommerce->cart->get_total(); ?></strong>

Topic Closed

This topic has been closed to new replies.

About this Topic