-
Notifications
You must be signed in to change notification settings - Fork 219
Update MiniCart.php to fix price total amount on page load prices are including tax #7832
Update MiniCart.php to fix price total amount on page load prices are including tax #7832
Conversation
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing this fix, @lukeoregan88! Could you write some testing steps to allow us to reproduce the issue and see how this PR fixes it? It would be good to know what are your settings in the Tax tab, specifically:
- Prices entered with tax
- Display prices in the shop
- Display prices during cart and checkout
Thanks in advance!
src/BlockTypes/MiniCart.php
Outdated
@@ -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(); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple of PHP linting errors because of having white spaces at the end of the file. Here and in line 310.
Removed white spaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed white spaces
So I have an example of a website I've just built... It was recently updated to Woocommerce 7.1.1
Mini-cart popout does show the correct total basket price of £25.00. This is also correct for the basket and checkout pages. This code will fix it. It was actually code taken from an early version of Woocommerce but for some reason, it was removed from version 7? Probably because new blocks were introduced? I think probably a better solution would be to amend the AJAX function for the mini-cart. On interaction (hover) of the mini-cart the basket updates to include the 20% tax. Maybe this should be extended to include on-page load also? This would also be handy for sites that utilise cache plugins. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating this PR, @lukeoregan88! This is testing well. Heads-up that I updated your original PR description to include in-detail testing steps.
Before merging, there is one last code formatting change that is needed. 👇
Fixed IF statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed IF
Thanks, @lukeoregan88! I just merged this PR and it will be released soon in WC Blocks and, after that, in WC core. 🎉 |
Thank you very much @Aljullu . This was my first ever pull request and fix for a public repo. I usually only fix in-house private projects. Thanks for the support. I look forward to seeing the fix in future updates of the WC core 🙌🏻. Have a great weekend and Merry Christmas 🎄. |
… including tax (#7832) * 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 <contact@albertjuhe.com>
* Empty commit for release pull request * Update the readme file with 9.1.1 release changes * Product Query: Add `Sorted by title` preset. (#7949) * Add `Sort by title` preset. * sorted, thanks @nerrad * Update the readme file with #7949 changes * 9.1.1 Release: Add testing docs * Atomic Block: fix ancestor definition (#7947) * Fix the incorrect layout of Rating and Price in Classic Template and Products block (#7932) * Fix the incorrect layout of Rating and Price in Classic Template There were styles required in Rating Filter that were added globally and influenced the layout of Rating in Products block as well as Classic template. The styles were moved to the Rating Filter block * Add dropdown version of Filter by Stock Status (#7831) * Extend Filter by Stock Editor options with dropdown and single/multiple choice * Add dropdown implementation for Filter by Stock Status * Adjust font-sizes to the rest of the filters * Add tests to Filter by Stock: dropdown and list variants * Change test file extension from .js to .tsx, so it handles types as well * Add E2E test to Filter by Stock checking if display style can be toggled * When typing in Filter by Stock dropdown, handle the space so it highlights the suggestions * Change the name of the filter blocks in the test files * Remove unnecessary waiting step in E2E test for Filter by Stock toMatchElement waits for an element for 30s by itself, hence waitForSelector usage was removed * Improve the STOCK_STATUS_OPTIONS type handling * Extract onDropdownChange function instead of inline arrow function * Fix overlaping dropdown content with the wrapper when Filter by Stock was set to single * Product Query: Add patterns (#7857) * Product Query: First attempt at adding patterns * Product Query: Update patterns and the default block template * Product Query: And new and update existing patterns * Product Query: Adjust layout of the Minimal Product Row pattern * Product Query: Update pattern names * Product Query: Polish spaces between blocks inside the patterns * Product Query patterns: Link product titles and improve spacing between product elements * Product Query patterns: Button font-size update * Product Query patterns: Center the pagination * Product Query patterns: Center the pagination for the default pattern * Product Query patterns: Remove an empty column * Product Query patterns: Remove an empty column from the product list with 1:1 images pattern * Add dropdown version of Filter by Rating (#7771) * Rename the setting section to match Filter by Attribute * Add Display Style toggle to the block settings * Set list as a default value of displayStyle for Filter by Rating * Add dropdown variant of Filter by Rating * Extend the Editor settings with selectType: single or multiple * Adjust the styles of a FormTokenField to other dropdown * Align Editor settings order and wording between Filter by Attribute and Rating * Fix the issue with cut off corners of dropdown borders * Provide translated screen reader messages and placeholder * Revert the label property, which is necessary to display checkbox list * Make classname for Rating component optional and remove styling in Filter by Rating * Cover the case when filter with zero products needs string methods for comparison * Handle Typescript errors and add ts-ignore annotations when necessary * Remove explicit key prop assignment in Rating component * Remove leftover property in type definition * Refactor JSX element extension with custom properties to more robust way with object copy * Filter by rating tests (#7845) * Filter by Rating tests: - List single - List multiple - Dropdown single - Dropdown multiple * Adjust the font-size of Filter by Rating dropdown to the rest of the filters * Fix E2E tests after the Editor settings label has been changed * Improve sorting in Filter by Rating dropdown With this change the order of options is always descending: in the chips, suggestions, active filters and URL * Change the name of the filter blocks in the test files * Prevent single dropdown input to overflow the wrapper The issue is fixed in three filters, hence a new shared styles file is created at the path assets/js/blocks/shared/styles/style.css * Remove the unused styles of active options in Filter by Rating Chosen options in Filter by Rating list have been bolded. That was the only filter that was doing it. Class was removed, but not the styles themselves which became obsolete. Removing the leftover styles then * Change the approach of shared styles to fix the dropdown issue in filters Instead of using direct classes, rewrite it to mixin and include in the filters * Fix the Filter by Rating with Products block The problem was with the Products block, that there was incorrect initial value of product ratings query * Align the logic of getting the filters from URL for Filter by Rating with Filter by Stock Co-authored-by: Luigi Teschio <gigitux@gmail.com> * Product Query - Enable "Inherit Query from template" option (#7641) * Add Inherit Query from template option * Update label * Product Elements: Fix block settings (#7914) * Product Elements: Fix block settings * Rating: Fix inactive star color * Product Rating: Fix color inheritance * StyleAttributesUtils: Fix PHP notices and invalid CSS output (#7909) * StyleAttributesUtils: Fix PHP notices and invalid CSS output. Closes #7899. * StyleAttributesUtils: Fix border radius and width support * StyleAttributesUtils: Fix border radius and border color support * StyleAttributesUtils: Include additional checks to deal with PHP warnings * StyleAttributesUtils: Improve the custom border array check * Update MiniCart.php to fix price total amount on page load prices are including tax (#7832) * 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 <contact@albertjuhe.com> * Product Query: implement compatibility with Filter by Rating block (#7792) * Product Query: implement compatibility with Filter by Rating block #7631 Product Query: implement compatibility with Filter by Rating block * address feedback * address feedback * add comment * add new zip file link * add missing class * add testing instructions about #7947 * add new zip file link * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Bumping version strings to new version. Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com> Co-authored-by: Tung Du <dinhtungdu@gmail.com> Co-authored-by: Luigi Teschio <gigitux@gmail.com> Co-authored-by: kmanijak <karol.manijak@automattic.com> Co-authored-by: Luke O'Regan <oregan.luke@gmail.com> Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Empty commit for release pull request * Update the readme file with 9.1.1 release changes * Product Query: Add `Sorted by title` preset. (#7949) * Add `Sort by title` preset. * sorted, thanks @nerrad * Update the readme file with #7949 changes * 9.1.1 Release: Add testing docs * Atomic Block: fix ancestor definition (#7947) * Fix the incorrect layout of Rating and Price in Classic Template and Products block (#7932) * Fix the incorrect layout of Rating and Price in Classic Template There were styles required in Rating Filter that were added globally and influenced the layout of Rating in Products block as well as Classic template. The styles were moved to the Rating Filter block * Add dropdown version of Filter by Stock Status (#7831) * Extend Filter by Stock Editor options with dropdown and single/multiple choice * Add dropdown implementation for Filter by Stock Status * Adjust font-sizes to the rest of the filters * Add tests to Filter by Stock: dropdown and list variants * Change test file extension from .js to .tsx, so it handles types as well * Add E2E test to Filter by Stock checking if display style can be toggled * When typing in Filter by Stock dropdown, handle the space so it highlights the suggestions * Change the name of the filter blocks in the test files * Remove unnecessary waiting step in E2E test for Filter by Stock toMatchElement waits for an element for 30s by itself, hence waitForSelector usage was removed * Improve the STOCK_STATUS_OPTIONS type handling * Extract onDropdownChange function instead of inline arrow function * Fix overlaping dropdown content with the wrapper when Filter by Stock was set to single * Product Query: Add patterns (#7857) * Product Query: First attempt at adding patterns * Product Query: Update patterns and the default block template * Product Query: And new and update existing patterns * Product Query: Adjust layout of the Minimal Product Row pattern * Product Query: Update pattern names * Product Query: Polish spaces between blocks inside the patterns * Product Query patterns: Link product titles and improve spacing between product elements * Product Query patterns: Button font-size update * Product Query patterns: Center the pagination * Product Query patterns: Center the pagination for the default pattern * Product Query patterns: Remove an empty column * Product Query patterns: Remove an empty column from the product list with 1:1 images pattern * Add dropdown version of Filter by Rating (#7771) * Rename the setting section to match Filter by Attribute * Add Display Style toggle to the block settings * Set list as a default value of displayStyle for Filter by Rating * Add dropdown variant of Filter by Rating * Extend the Editor settings with selectType: single or multiple * Adjust the styles of a FormTokenField to other dropdown * Align Editor settings order and wording between Filter by Attribute and Rating * Fix the issue with cut off corners of dropdown borders * Provide translated screen reader messages and placeholder * Revert the label property, which is necessary to display checkbox list * Make classname for Rating component optional and remove styling in Filter by Rating * Cover the case when filter with zero products needs string methods for comparison * Handle Typescript errors and add ts-ignore annotations when necessary * Remove explicit key prop assignment in Rating component * Remove leftover property in type definition * Refactor JSX element extension with custom properties to more robust way with object copy * Filter by rating tests (#7845) * Filter by Rating tests: - List single - List multiple - Dropdown single - Dropdown multiple * Adjust the font-size of Filter by Rating dropdown to the rest of the filters * Fix E2E tests after the Editor settings label has been changed * Improve sorting in Filter by Rating dropdown With this change the order of options is always descending: in the chips, suggestions, active filters and URL * Change the name of the filter blocks in the test files * Prevent single dropdown input to overflow the wrapper The issue is fixed in three filters, hence a new shared styles file is created at the path assets/js/blocks/shared/styles/style.css * Remove the unused styles of active options in Filter by Rating Chosen options in Filter by Rating list have been bolded. That was the only filter that was doing it. Class was removed, but not the styles themselves which became obsolete. Removing the leftover styles then * Change the approach of shared styles to fix the dropdown issue in filters Instead of using direct classes, rewrite it to mixin and include in the filters * Fix the Filter by Rating with Products block The problem was with the Products block, that there was incorrect initial value of product ratings query * Align the logic of getting the filters from URL for Filter by Rating with Filter by Stock Co-authored-by: Luigi Teschio <gigitux@gmail.com> * Product Query - Enable "Inherit Query from template" option (#7641) * Add Inherit Query from template option * Update label * Product Elements: Fix block settings (#7914) * Product Elements: Fix block settings * Rating: Fix inactive star color * Product Rating: Fix color inheritance * StyleAttributesUtils: Fix PHP notices and invalid CSS output (#7909) * StyleAttributesUtils: Fix PHP notices and invalid CSS output. Closes #7899. * StyleAttributesUtils: Fix border radius and width support * StyleAttributesUtils: Fix border radius and border color support * StyleAttributesUtils: Include additional checks to deal with PHP warnings * StyleAttributesUtils: Improve the custom border array check * Update MiniCart.php to fix price total amount on page load prices are including tax (#7832) * 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 <contact@albertjuhe.com> * Product Query: implement compatibility with Filter by Rating block (#7792) * Product Query: implement compatibility with Filter by Rating block #7631 Product Query: implement compatibility with Filter by Rating block * address feedback * address feedback * add comment * add new zip file link * add missing class * add testing instructions about #7947 * add new zip file link * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Bumping version strings to new version. * Remove feature flag from Products block (#8001) * Remove feature flag from Products block * Remove Products block from feature flags documentation * Empty commit for release pull request * Update changelog * Add zip file link * Bumping version strings to new version. Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com> Co-authored-by: Tung Du <dinhtungdu@gmail.com> Co-authored-by: Luigi Teschio <gigitux@gmail.com> Co-authored-by: kmanijak <karol.manijak@automattic.com> Co-authored-by: Luke O'Regan <oregan.luke@gmail.com> Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Empty commit for release pull request * Update the readme file with 9.1.1 release changes * Product Query: Add `Sorted by title` preset. (#7949) * Add `Sort by title` preset. * sorted, thanks @nerrad * Update the readme file with #7949 changes * 9.1.1 Release: Add testing docs * Atomic Block: fix ancestor definition (#7947) * Fix the incorrect layout of Rating and Price in Classic Template and Products block (#7932) * Fix the incorrect layout of Rating and Price in Classic Template There were styles required in Rating Filter that were added globally and influenced the layout of Rating in Products block as well as Classic template. The styles were moved to the Rating Filter block * Add dropdown version of Filter by Stock Status (#7831) * Extend Filter by Stock Editor options with dropdown and single/multiple choice * Add dropdown implementation for Filter by Stock Status * Adjust font-sizes to the rest of the filters * Add tests to Filter by Stock: dropdown and list variants * Change test file extension from .js to .tsx, so it handles types as well * Add E2E test to Filter by Stock checking if display style can be toggled * When typing in Filter by Stock dropdown, handle the space so it highlights the suggestions * Change the name of the filter blocks in the test files * Remove unnecessary waiting step in E2E test for Filter by Stock toMatchElement waits for an element for 30s by itself, hence waitForSelector usage was removed * Improve the STOCK_STATUS_OPTIONS type handling * Extract onDropdownChange function instead of inline arrow function * Fix overlaping dropdown content with the wrapper when Filter by Stock was set to single * Product Query: Add patterns (#7857) * Product Query: First attempt at adding patterns * Product Query: Update patterns and the default block template * Product Query: And new and update existing patterns * Product Query: Adjust layout of the Minimal Product Row pattern * Product Query: Update pattern names * Product Query: Polish spaces between blocks inside the patterns * Product Query patterns: Link product titles and improve spacing between product elements * Product Query patterns: Button font-size update * Product Query patterns: Center the pagination * Product Query patterns: Center the pagination for the default pattern * Product Query patterns: Remove an empty column * Product Query patterns: Remove an empty column from the product list with 1:1 images pattern * Add dropdown version of Filter by Rating (#7771) * Rename the setting section to match Filter by Attribute * Add Display Style toggle to the block settings * Set list as a default value of displayStyle for Filter by Rating * Add dropdown variant of Filter by Rating * Extend the Editor settings with selectType: single or multiple * Adjust the styles of a FormTokenField to other dropdown * Align Editor settings order and wording between Filter by Attribute and Rating * Fix the issue with cut off corners of dropdown borders * Provide translated screen reader messages and placeholder * Revert the label property, which is necessary to display checkbox list * Make classname for Rating component optional and remove styling in Filter by Rating * Cover the case when filter with zero products needs string methods for comparison * Handle Typescript errors and add ts-ignore annotations when necessary * Remove explicit key prop assignment in Rating component * Remove leftover property in type definition * Refactor JSX element extension with custom properties to more robust way with object copy * Filter by rating tests (#7845) * Filter by Rating tests: - List single - List multiple - Dropdown single - Dropdown multiple * Adjust the font-size of Filter by Rating dropdown to the rest of the filters * Fix E2E tests after the Editor settings label has been changed * Improve sorting in Filter by Rating dropdown With this change the order of options is always descending: in the chips, suggestions, active filters and URL * Change the name of the filter blocks in the test files * Prevent single dropdown input to overflow the wrapper The issue is fixed in three filters, hence a new shared styles file is created at the path assets/js/blocks/shared/styles/style.css * Remove the unused styles of active options in Filter by Rating Chosen options in Filter by Rating list have been bolded. That was the only filter that was doing it. Class was removed, but not the styles themselves which became obsolete. Removing the leftover styles then * Change the approach of shared styles to fix the dropdown issue in filters Instead of using direct classes, rewrite it to mixin and include in the filters * Fix the Filter by Rating with Products block The problem was with the Products block, that there was incorrect initial value of product ratings query * Align the logic of getting the filters from URL for Filter by Rating with Filter by Stock Co-authored-by: Luigi Teschio <gigitux@gmail.com> * Product Query - Enable "Inherit Query from template" option (#7641) * Add Inherit Query from template option * Update label * Product Elements: Fix block settings (#7914) * Product Elements: Fix block settings * Rating: Fix inactive star color * Product Rating: Fix color inheritance * StyleAttributesUtils: Fix PHP notices and invalid CSS output (#7909) * StyleAttributesUtils: Fix PHP notices and invalid CSS output. Closes #7899. * StyleAttributesUtils: Fix border radius and width support * StyleAttributesUtils: Fix border radius and border color support * StyleAttributesUtils: Include additional checks to deal with PHP warnings * StyleAttributesUtils: Improve the custom border array check * Update MiniCart.php to fix price total amount on page load prices are including tax (#7832) * 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 <contact@albertjuhe.com> * Product Query: implement compatibility with Filter by Rating block (#7792) * Product Query: implement compatibility with Filter by Rating block #7631 Product Query: implement compatibility with Filter by Rating block * address feedback * address feedback * add comment * add new zip file link * add missing class * add testing instructions about #7947 * add new zip file link * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update docs/internal-developers/testing/releases/911.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Bumping version strings to new version. * Remove feature flag from Products block (#8001) * Remove feature flag from Products block * Remove Products block from feature flags documentation * Empty commit for release pull request * Update changelog * Add zip file link * Bumping version strings to new version. * Enable Product SKU and Product Stock Indicator in Core (#8009) * Update changelog * Update changelog * Empty commit for release pull request * Bumping version strings to new version. Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com> Co-authored-by: Tung Du <dinhtungdu@gmail.com> Co-authored-by: Luigi Teschio <gigitux@gmail.com> Co-authored-by: kmanijak <karol.manijak@automattic.com> Co-authored-by: Luke O'Regan <oregan.luke@gmail.com> Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Fixes #7830
Added an update to the '$cart_contents_total' variable on the 'get_cart_price_markup' function if $cart->display_prices_including_tax is true. Currently displaying wrong amount total on page load if items are already in the basket.
Testing
Automated Tests
User Facing Testing
WooCommerce Visibility
Changelog