king10
king10

Reputation: 23

How to remove the total row from cart and checkout

I would like to remove only total row on cart and checkout page not the whole block. I am not able to find any action or filter to remove the total i still want to leave the subtotal . I am using the code below but it hides the whole order block and also it does not remove it from the bill that is generated after checkout

add_action( 'woocommerce_checkout_order_review', 'remove_checkout_totals', 1 );

      function remove_checkout_totals()
   {remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );}

Upvotes: 1

Views: 4014

Answers (2)

Weetameal
Weetameal

Reputation: 1

There is order-total class for order total. You should add a line of code into your css. It should solve the problem.

.order-total { display: none; }

Upvotes: 0

kashalo
kashalo

Reputation: 3562

You will not find any hook specified for the Total row because they are hard coded in the templates the only way to remove the total row from the cart page and checkout pages by modifying those pages template and to do that you need to follow few steps as follow:

  1. Create Folder in your child theme called woocommerce.
  2. Create two folders inside main woocommerce which you just created called name checkout and cart.
  3. now create file called review-order.php put it inside checkout folder and cart-totals.php put it inside the cart folder then copy the content from the original files which you can find in wp-content/plugins/woocoomerce/templates/checkout/review-order.php and wp-content/plugins/woocoomerce/templates/cart/cart-totals.php

Last step:

find the following lines in both files and delete them:

    <tr class="order-total">
       <th><?php _e('Total', 'woocommerce'); ?></th>
       <td><?php wc_cart_totals_order_total_html(); ?></td>
    </tr>

Order received page

To Remove the Total from Order received page you can use woocommerce_get_order_item_totals hook and unset the total as follow:

add_action('woocommerce_get_order_item_totals', 'remove_total', 10, 1);

function remove_total($array)
{
    unset($array['order_total']);
    return $array;
}

put the code above in your functions.php

That's it.

Upvotes: 3

Related Questions