How to remove order total from cart and checkout page woocommerce

前端 未结 2 1015
攒了一身酷
攒了一身酷 2021-01-19 02:30

I would like to remove order total block on cart and checkout page.
I am not able to find any action or filter to remove order total.
I don\'t want to use css to h

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-19 03:05

    Using hooks:

    1) Remove cart totals:

    // On cart page
    add_action( 'woocommerce_cart_collaterals', 'remove_cart_totals', 9 );
    function remove_cart_totals(){
        // Remove cart totals block
        remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 );
    
        // Add back "Proceed to checkout" button (and hooks)
        echo '
    '; do_action( 'woocommerce_before_cart_totals' ); echo '
    '; do_action( 'woocommerce_proceed_to_checkout' ); echo '
    '; do_action( 'woocommerce_after_cart_totals' ); echo '

    '; }

    2) Remove checkout totals:

    // On checkout page
    add_action( 'woocommerce_checkout_order_review', 'remove_checkout_totals', 1 );
    function remove_checkout_totals(){
        // Remove cart totals block
        remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
    }
    

    Code goes in function.php file of your active child theme (or active theme). Tested and works.

提交回复
热议问题