Description
Preconditions (*)
- Magento version: 2.4-develop brach
Description (*)
In the store, the display prices is set as including tax. And persistent shopping cart is enabled. So, as a not logged in customer the prices display on the category list and product view page is including tax and it is correct. But when I logged in as a customer and wait for the automatically expire customer session and then it shows the excluding tax price some time on category list page and some time on product page. But after customer logout it should display including tax price on both places.
Configurations (*)
-
Create one category and create one product, assigned this product to the category.
-
Create one tax rate for one country. For example here I have created tax rate for Denmark country (see screenshot-01).
screenshot-01 -
Create one tax rule and select the tax rate we created above (see screenshot-02).
screenshot-02 -
Configure the 'Tax classes' and 'Default Tax Destination Calculation' as in screenshot-03.
screenshot-03 -
Configure the display price every where with including tax same as below screenshot-04.
screenshot-04 -
Configure Country Options. Here, Set default country for which we added the tax rate. For example I have set Denmark as default country. And allow multiple countries (Note: we must allow the country for which we added tax rate and second country for which no any tax rate configure). For example I have allowed Denmark and United State.
-
Configure 'Persistent Shopping Cart'. We need to enable persistence from the Store -> Configuration -> Customers -> Persistent Shopping Cart -> General Options -> Enable persistence
-
Configure the 'Cookie Lifetime' for small amount of time like 3 - 4 minute. So, it can be expire within given time for checking issue without wait for long time. for that Goto Store -> Configuration -> General -> Web -> Default Cookie Settings -> Cookie Lifetime
-
Create one customer and add the address with the country for which no any tax rate configured. Here I have created customer with United state country.
Steps to reproduce (*)
- In frontend, goto category page and open product in product page, observe the price at both pages.
- Now flush the cache by using php bin/magento cache:flush command. And logged in with the customer which have no any tax rate.
- Goto category page again and add product to cart from category page and open that product in another tab. And observe the price at both place.
- Stay on the category page and Wait for the customer session expire (As per the configuration cookie lifetime sets for 3 min). So, Wait for 3 min and then refresh the category page one time. Now you will see that, customer session expired.
- Now remove that product from the mini-cart and don't refresh the page.
- Again add that product to cart from the category page. Open that product in another tab. And refresh the category page, observe price. Also observe the price on product view page.
Expected result (*)
After following the above steps and when customer session expired, then price should display including tax as per the tax configuration.
Actual result (*)
As per the configuration, when customer is not logged in then the price is including tax. But when we use above steps and after customer session expired, then the price display excluding tax.
Additional information (*)
When you view the category list page and product view page without logged in, the category page cache and product page cache have including tax price. Please refer below screenshot-05 and screenshot-06 accordingly.
Now after the 6th step mention in the steps to reproduce, again check the cache report. And in the cache, it shows the excluding tax price even after logged out. Please refer below screenshot-07 and screenshot-08.
In the above screenshot, it shows the data from the cache key. And this cache key generates from the afterGetCacheKey() function (see screenshot-09) of the below class:
Magento/Catalog/Block/Category/Plugin/PriceBoxTags.php
In the cache key the last three things represent the Store Id, Customer Group Id and Tax Rate Id.
If any tax rate applied to the customer group, tax rate id will be display at the end of the generated cache key. And if not applied then it will display as blank after underscore (_) in cache key (as in the sceershot-05 to sceernshot-08).
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.