1
votes

In woocommerce, I am using the following to remove the shipping block in cart totals section bloc:

 function disable_shipping_calc_on_cart( $show_shipping ) {
        if( is_cart() ) {
            return false;
        }
        return $show_shipping;
    }
    add_filter( 'woocommerce_cart_ready_to_calc_shipping', 'disable_shipping_calc_on_cart', 99 );

But in that cart totals section bloc there are some other things like the cart Subtotal and Total.

I just need to keep only Total

Any help is welcome.

2
Not clear what you are exactly looking for....if you are looking for removing shipping section,- you can do it from woocommerce settings under shipping section - > shippings options But if you are looking for removing that 'subtotal' text, unfortunately there is no such hook to do that, you have to modify your theme according to that.Alice

2 Answers

1
votes

You seem to keep only the total on cart totals section. For that the only way is overriding woocommerce templates.

There is 2 steps:

  1. You should read Template structure & Overriding templates via a theme to understand how you can override woocommerce templates via your active child theme (or active theme).

    So you will have to create in you active theme folder (if it doesn't exist yet) a folder named "woocommerce" and a sub-sub folder "cart"…

    You will have to copy from the wp-content/plugins/woocommerce/templates/cart/cart-totals.php to your active theme woocommerce/cart/cart-totals.php (if it not exist yet).

  1. Editing cart-totals.phptemplate and removing code:

    Since WooCommerce version 2.3.6 and up: You will have to remove the code from line 32 to 59 (You will keep only fees and taxes if they are any)

    If you want to keep only the total amount you will remove the code from line 32 to line 87

    Then save.

You will not need your function code anymore

Now your cart totals will be something like this:

enter image description here

0
votes
add_filter( 'woocommerce_get_order_item_totals', 'adjust_woocommerce_get_order_item_totals' );

function adjust_woocommerce_get_order_item_totals( $totals ) {
  unset($totals['cart_subtotal']  );
  return $totals;
}

Is this what you are looking for? Basically you asked to remove the subtotal.