Open juricazuanovic opened 2 years ago
@juricazuanovic I'm the author of the Aelia plugins, for which WP Rocket includes an integration. I thought of chiming in, to help addressing the issue.
Based on the information collected from the customer, it looks like, at the moment, WP Rocket works as follows:
This logic is also compatible, to a certain extent, with our other two plugins, Tax Display by Country and Prices by Country, which are standalone products, and use the same geolocation logic as the Currency Switcher. The "gap" that we noticed is that WP Rocket doesn't take into account the fact that these two plugins also provide a geolocation feature.
Due to that, when the Tax Display by Country and Prices by Country plugins are used without the Currency Switcher, or when the Currency Switcher's geolocation is disabled, WP Rocket simply adopts the second approach, serving cached content right from the start, and doesn't let the geolocation run.
The Tax Display by Country and Prices by Country include a geolocation feature that is always enabled. It can't be disabled, because that would make the plugins pointless. Due to that, the logic used by WP Rocket to determine if the geolocation is active should be changed as follows:
That should be the only change needed. The rest of the WP Rocket logic, which fetches the value of country and currency cookies, will work as it is, because all the plugins use the same ones.
Hi, I'm interested in the prognosis for this issue, as my web site relies on WP Rocket pre-load caching and Aelia Tax Display by Country, or failing that some advice on how to get it to work better. I have a couple customers every week commenting either that prices are inconsistent between product catalog and single product pages (wrong tax amount), or the basket/cart suddenly empties itself out, which I suspect may also be related somehow.
I also find WP Rocket typically fails to create a pre-load cache using the "wp-rocket-preload-dynamic-cookies" helper plugin - I have it set to create GB and NL versions of the aelia_customer_country cookie, but it generally only generates the cookie-free pages. These are of no use to any site visitor, given they all have a value set for aelia_customer_country and therefore need country-specific versions of cached pages. I have cloned my site to a test server to investigate this problem and allow WP Rocket support to take a look directly, but the problem disappears on the clone server. There I suspect it's solved by the changing of the URL (re-installation of WP Rocket alone is not effective). The only way I know to get rid of the problem is to clone the site to a new server with new URL. I have even tried permanently migrating the LIVE site to an entirely new server and changing the DNS A records etc, but it seems that without changing the site's URL changing, the problem just does not go away.
I'm still available if there are any questions for me.
@piotrbak It's a shot in the dark, but perhaps the issue could be fixed by adding the following lines to the WP Rocket code.
Files to modify:
wp-rocket/inc/3rd-party/plugins/ecommerce/aelia-tax-display-by-country.php
wp-rocket/inc/3rd-party/plugins/ecommerce/aelia-prices-by-country.php
Line 15
add_filter( 'rocket_cache_mandatory_cookies', 'rocket_add_aelia_mandatory_cookies' );
This goes just before the endif;
line.
Bottom of the file
/**
* Add the customer country to the list of mandatory cookies before generating caching files
*
* @param array $cookies Mandatory cookies to serve the cache.
* @return array Updated cookies list
*/
function rocket_add_aelia_mandatory_cookies( $cookies ) {
$cookies[] = 'aelia_customer_country';
return $cookies;
}
Why this should work
This is a hypothetical fix, based on the logic followed by the Currency Switcher integration. That integration checks if the geolocation is enabled in the Currency Switcher (see function rocket_add_aelia_currencyswitcher_mandatory_cookie( $cookies )
) and, in that case, it adds the currency to the mandatory cookies. This seems to be what makes WP Rocket check for the presence of the cookie before trying to serve cached content. When the cookie is absent, WP Rocket lets the site load, so that the Currency Switcher can set it.
The same logic applies to the Tax Display by Country and Prices by Country plugin, which work exactly the same way. However, WP Rocket doesn't set any "mandatory cookies" for them, therefore it just carries on serving whatever content it had cached. This patch corrects the behaviour, ensuring that WP Rocket expects the cookies that those plugins always set, before making any decision on what content should be served.
Hello @daigo75 thanks for your input. Could you send me the license or coupon for your products to piotr[at]wp-media.me?
Looks like we don't have an active license. We'd proceed with the tests and enhancement then.
@piotrbak I shall send you the details for the licence shortly. I will send it for all the plugins, so you're covered.
Edit Done, I sent you the licences and the download links.
Before submitting an issue please check that you’ve completed the following steps:
3.10.8
Describe the bug The tax/VAT information and prices are not displayed correctly, so our compatibility is not working as expected. When the plugin is enabled, the first visit to the prduct page is cached and the dynamic cookie
aelia_customer_country
is not set or is set after the loading of the page has finished or interacted with. This causes the tax information and prices to be displayed incorrectly for EU and non-EU customers.To Reproduce Steps to reproduce the behavior:
Expected behavior Customers from outside EU should see prices excluding VAT, while citizens within EU should see price including VAT.
Screenshots https://i.imgur.com/H0wbopD.jpeg
Additional context Tickets: https://secure.helpscout.net/conversation/1784109311/325440 https://secure.helpscout.net/conversation/1355525714/219373/
Temporary solution is to make
aelia_customer_country
cookie mandatory using this snippet from Vasilis https://snippi.com/s/cdhrcytBacklog Grooming (for WP Media dev team use only)