How to remove order total from cart and checkout page woocommerce

主宰稳场 提交于 2020-01-30 07:41:28

问题


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 hide this column.


回答1:


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 '<div class="cart_totals">';
    do_action( 'woocommerce_before_cart_totals' );

    echo '<div class="wc-proceed-to-checkout">';
    do_action( 'woocommerce_proceed_to_checkout' );
    echo '</div>';

    do_action( 'woocommerce_after_cart_totals' );
    echo '</div><br clear="all">';
}

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.




回答2:


If its input field you can remove its value like

 $('#div_id').val('');

If its div or span you can do

$("div").empty();
S('#div_id div').html('');


来源:https://stackoverflow.com/questions/49954483/how-to-remove-order-total-from-cart-and-checkout-page-woocommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!