Home Remove subtotal and Shipping calculator block in Woocommerce cart totals section
Reply: 2

Remove subtotal and Shipping calculator block in Woocommerce cart totals section

Сергей Шабуров
1#
Сергей Шабуров Published in 2018-02-14 10:32:36Z

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.

Gobbin
2#
Gobbin Reply to 2018-02-14 11:10:13Z
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.

LoicTheAztec
3#
LoicTheAztec Reply to 2018-02-15 05:51:30Z

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:

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.418891 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO