Code-Snippets-Functions/Execute a function on a child site/WooCommerce/remove-totals-section-from-cart-while-keeping-subtotal-line.txt

29 lines
1,013 B
Text

add_action( 'woocommerce_cart_collaterals', 'keep_only_cart_subtotal', 9 );
function keep_only_cart_subtotal(){
// Remove cart totals block
remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 );
// Add back Subtotal, "Proceed to checkout" button (and hooks)
printf('<div class="cart_totals%s">', ( WC()->customer->has_calculated_shipping() ) ? ' calculated_shipping' : '');
do_action( 'woocommerce_before_cart_totals' );
?>
<table cellspacing="0" class="shop_table shop_table_responsive">
<tr class="cart-subtotal">
<th><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
<td data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
</table>
<?php
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">';
}