You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在WooCommerce购物车及结账页面移除订单总计模块

Remove WooCommerce Order Totals from Cart & Checkout Without CSS

Got it, I totally get why you don’t want to rely on CSS—hiding elements with display:none just masks the section instead of actually removing it from the DOM, which can cause unexpected issues with WooCommerce’s backend logic or accessibility. Let’s use proper WooCommerce hooks to tackle this cleanly.

Step 1: Remove Totals from the Cart Page

The order totals section on the cart page is hooked into woocommerce_cart_collaterals by default with the callback woocommerce_cart_totals. We can unhook this to completely remove the section:

// Remove order totals from WooCommerce cart page
add_action( 'init', 'remove_cart_order_totals' );
function remove_cart_order_totals() {
    remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 );
}

Step 2: Remove Totals from the Checkout Page

On the checkout page, the totals live in the order review section, hooked into woocommerce_checkout_order_review via woocommerce_checkout_totals. Here’s how to unhook that:

// Remove order totals from WooCommerce checkout page
add_action( 'init', 'remove_checkout_order_totals' );
function remove_checkout_order_totals() {
    remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_totals', 10 );
}

Combine into a Single Function (Optional)

If you prefer to keep your code tidy, you can merge both removals into one function:

// Remove order totals from both cart and checkout pages
add_action( 'init', 'remove_all_order_totals' );
function remove_all_order_totals() {
    // Cart page
    remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 );
    // Checkout page
    remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_totals', 10 );
}

Important Notes

  • Where to add this code: Paste it into your child theme’s functions.php file, or use a custom code snippets plugin. Never edit WooCommerce core files—your changes will get overwritten when the plugin updates.
  • Adjust priority if needed: If your theme or another plugin has modified the hook priority (the 10 in the code), you might need to match that number. You can check WooCommerce’s template files (like cart/cart-totals.php or checkout/review-order.php) to confirm the priority being used.

内容的提问来源于stack exchange,提问作者Karan Rpn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:36:19