Programatically update cart subtotal and order total
-
Hi,
I have updated PRODUCT subtotals using this filter:
add_filter( 'woocommerce_cart_item_subtotal', 'change_product_subtotal_on_condition', 10, 3 ); function change_product_subtotal_on_condition( $subtotal, $cart_item, $cart_item_key ) { $newsubtotal = wc_price( $cart_item['data']->get_price() * ($cart_item['quantity'] - 1 ); $subtotal = sprintf( '<s>%s</s> %s', $subtotal, $newsubtotal ); return $subtotal; }It works fine, however CART subtotal and order total are not updated. Could you please advise me how to update both of them?
I tried
add_filter( 'woocommerce_cart_subtotal', 'update_cart_subtotal', 10, 3 ); function update_cart_subtotal( $cart_subtotal, $compound, $obj ) { $new_cart_subtotal = wc_price( WC()->cart->subtotal); $cart_subtotal = sprintf( '<del>%s</del> <b>%s</b>', $cart_subtotal , $new_cart_subtotal ); return $cart_subtotal; }This does not update CART subtotal with newly calculated PRODUCT subtotals in my first filter.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Programatically update cart subtotal and order total’ is closed to new replies.