• Resolved yeahhbaby

    (@yeahhbaby)


    Hello,

    I would like to add an extra line to cart_totals, but am not successful positioning it where it should be displayed.
    For a german online shop I would like to add an extra line with total taxes that are included in order total.
    Problem is due to my customers requirement to show the prices including taxes. So it is not an option to change the shop’s pricing options.
    That’s why I decided to add the extra line by code. But as you can see here, it is above the cart total calculation and therefore gets added to the total amount.
    Screenshot
    I would like the tax line to disappear below the cart total line. This is the code I’m currently using:

    add_action( 'woocommerce_cart_calculate_fees','custom_tax_surcharge_for_ger' );
    function custom_tax_surcharge_for_ger( $cart ) {
        if ( is_admin() && ! defined('DOING_AJAX') ) return;
    
        // Only for DE country (if not we exit)
        if ( 'DE' != WC()->customer->get_shipping_country() ) return;
    
        $percent = 18.9990;
        # $taxes = array_sum( $cart->taxes ); // <=== This is not used in your function
    
        // Calculation
        $surcharge = ( ( $cart->cart_contents_total + $cart->shipping_total ) / 100 ) * $percent;
    
        // Add the fee (tax third argument disabled: false)
        $cart->add_fee( __( 'inkl. 19% MwSt.', 'woocommerce'), $surcharge, false );
    }

    Would be glad about any hint. Thanks a lot, best regards,
    -Bj?rn

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Support Hannah S.L.

    (@fernashes)

    Automattic Happiness Engineer

    Hey there,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

Viewing 1 replies (of 1 total)
  • The topic ‘Add Extra Line To Cart_Totals’ is closed to new replies.