I'm trying to change the cart totals with code but I don't know how. I have managed to change the price for each item in the cart using the filter woocommerce_cart_item_price
. Is there such a filter for the cart totals(see arrow in picture)?
This is the code for each individual item:
add_filter( 'woocommerce_cart_item_price', 'func_change_product_price_cart', 10, 3 );
function func_change_product_price_cart($price, $cart_item, $cart_item_key){
if ( isset($cart_item['tau_lengde']) ) {
if ( WC()->cart->display_prices_including_tax() ) {
$product_price = wc_get_price_including_tax( $cart_item['data'] );
} else {
$product_price = wc_get_price_excluding_tax( $cart_item['data'] );
}
$price = wc_price( (($product_price * $cart_item['tau_lengde']) + $cart_item['price_one_end'] + $cart_item['price_other_end']));
return $price;
}
}