From 7719cbcb005271b10b8b21a4ae7542d6074d56b3 Mon Sep 17 00:00:00 2001 From: Luke O'Regan Date: Fri, 9 Dec 2022 16:36:28 +0000 Subject: [PATCH] Update MiniCart.php to fix price total amount on page load prices are including tax (#7832) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update MiniCart.php Added an update to the '$cart_contents_total' variable on the 'get_cart_price_markup' function if $cart->display_prices_including_tax is active. Currently displaying wrong amount total on page load if items are already in the basket. * Update MiniCart.php Removed white spaces? * Update MiniCart.php Fixed IF statement * Remove whitespace at end of line Co-authored-by: Albert Juhé Lluveras --- src/BlockTypes/MiniCart.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/BlockTypes/MiniCart.php b/src/BlockTypes/MiniCart.php index 0c83fca1d60..9957caa2c82 100644 --- a/src/BlockTypes/MiniCart.php +++ b/src/BlockTypes/MiniCart.php @@ -303,6 +303,11 @@ protected function get_cart_price_markup( $attributes ) { $cart_controller = $this->get_cart_controller(); $cart = $cart_controller->get_cart_instance(); $cart_contents_total = $cart->get_subtotal(); + + if ( $cart->display_prices_including_tax() ) { + $cart_contents_total += $cart->get_subtotal_tax(); + } + return '' . esc_html( wp_strip_all_tags( wc_price( $cart_contents_total ) ) ) . ' ' . $this->get_include_tax_label_markup(); }