Hide Order Total from Woocommerce Checkout

629 Views Asked by At

I'm trying to hide the "order-total" section from my checkout if the total is 0.00€ (see [Pic here][1] for reference).

I tried to add a condition to the code (as you can see below) I found suggested here:
How to remove order total from cart and checkout page woocommerce

However when I try it live, it hides the field even if the cart is not 0.00€.
Here's the code:

// On checkout page
add_action( 'woocommerce_checkout_order_review', 'remove_checkout_totals', 1 );
function remove_checkout_totals(){
    cart_total = WC()->cart->get_cart_total();
    if ( $cart_total == 0 ) {
            // Remove cart totals block
            remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
    }
}

What should I do?
Thanks in advance for you help!

24/09: edit after 7uc1f3r's corrections

0

There are 0 best solutions below