From a95ec746cb92289825abad540af3694eb66464e1 Mon Sep 17 00:00:00 2001 From: Luke O'Regan Date: Fri, 2 Dec 2022 16:15:17 +0000 Subject: [PATCH 1/4] 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. --- src/BlockTypes/MiniCart.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/BlockTypes/MiniCart.php b/src/BlockTypes/MiniCart.php index 0c83fca1d60..1674e0bcad6 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(); } From 7e5462c0943f344f4776ab50374e65ccfedf3626 Mon Sep 17 00:00:00 2001 From: Luke O'Regan Date: Fri, 9 Dec 2022 10:42:39 +0000 Subject: [PATCH 2/4] Update MiniCart.php Removed white spaces? --- src/BlockTypes/MiniCart.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/BlockTypes/MiniCart.php b/src/BlockTypes/MiniCart.php index 1674e0bcad6..0f14b92ba3a 100644 --- a/src/BlockTypes/MiniCart.php +++ b/src/BlockTypes/MiniCart.php @@ -303,11 +303,9 @@ 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(); - } - + + 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(); } From f549ea9739233743054a20042457bd17f1eabe60 Mon Sep 17 00:00:00 2001 From: Luke O'Regan Date: Fri, 9 Dec 2022 12:47:59 +0000 Subject: [PATCH 3/4] Update MiniCart.php Fixed IF statement --- src/BlockTypes/MiniCart.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/BlockTypes/MiniCart.php b/src/BlockTypes/MiniCart.php index 0f14b92ba3a..066f6f7dcec 100644 --- a/src/BlockTypes/MiniCart.php +++ b/src/BlockTypes/MiniCart.php @@ -304,7 +304,9 @@ protected function get_cart_price_markup( $attributes ) { $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();} + 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(); From fd4e6c3200a5e183a18112af376ca2dd83b39cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Fri, 9 Dec 2022 16:59:58 +0100 Subject: [PATCH 4/4] Remove whitespace at end of line --- src/BlockTypes/MiniCart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BlockTypes/MiniCart.php b/src/BlockTypes/MiniCart.php index 066f6f7dcec..9957caa2c82 100644 --- a/src/BlockTypes/MiniCart.php +++ b/src/BlockTypes/MiniCart.php @@ -304,7 +304,7 @@ protected function get_cart_price_markup( $attributes ) { $cart = $cart_controller->get_cart_instance(); $cart_contents_total = $cart->get_subtotal(); - if ( $cart->display_prices_including_tax() ) { + if ( $cart->display_prices_including_tax() ) { $cart_contents_total += $cart->get_subtotal_tax(); }