• Priority: 0
  • Status: Waiting on customer
  • Theme: Alysum
  • Assigned To: Fred
  • Private: No
  • Open Date: 10.11.26, 19:19
  • Opened by: Luca Tonelli

Ticket #26564 - Important cart cache problem

On PrestaShop 9.2.0, using the Alysum theme with pkelements, creativeelements, and pklib active, an anonymous visitor may see another visitor’s product in the side cart (`<template id=”cart-sidebar-template”>`), even though their own actual cart is empty (`prestashop.cart.products_count = 0`).

Reproduction (verified using `curl`, with LiteSpeed/CDN caching disabled; headers set to `no-store`):
Customer A (anonymous) adds a product to their cart.
Customer B (anonymous, with different cookies and an empty cart) opens any page.
Customer B’s footer displays Customer A’s cart contents (product name, price, total). In 3 out of 3 test requests, the content shown to Customer B was identical to that of Customer A.

The file `pkelements/src/Hooks/DisplayBeforeBodyClosingTag.php` caches the entire end-of-page block (saved with the `.pkel.endofpage` extension). This block includes the cart (via `ps_shoppingcart→getWidgetVariables`), as well as favorites and account information.
The `pklib\Cache::getCacheId()` method generates a cache key based solely on `customer→id`, currency, language, and store. For all anonymous users, `customer→id` is `null`, resulting in an identical cache key; the first user to trigger the cache generation sets it for everyone.
Furthermore, for logged-in users, the side cart fails to update because the cache is not invalidated by cart-related events (it is only cleared via `clearWidgetsCache()` during administrative actions).
A similar pattern exists in `creativeelements/includes/base/element-base.php` (around line 713, within the `ce` cache mechanism), which stores the HTML for individual elements using the same key. Consequently, any widget containing user-specific data such as cart counters, favorites, product comparisons, or “recently viewed” lists is exposed to the same risk.

Everything that depends on the shopping cart, guest status, cookies, or the customer should be excluded from the shared cache.
For instance, you could avoid caching the “end-of-page” block or specific widgets that rely on user state; alternatively, you could include a cart or visitor identifier in the cache key while carefully assessing the impact on the files generated within `var/cache` or trigger a cache invalidation whenever cart-related events occur.

Comments

Fred 10 Nov 2026, 22:52

Hi, Luca.
Thank you for your detailed report.
It seems the issue is reproducible even locally.
I propose you this fix

$cart = Context::getContext()->cart;
$settings['id_cart'] = !empty($cart->id) ? (int) $cart->id : null;
$settings['cart_upd'] = !empty($cart->id) ? (string) $cart->date_upd : null;

Add it into the method `getCacheId` in the file /modules/pklib/src/Cache/Cache.php
Like this: https://mega.nz/file/wBZmDAIb#Ywyx8J9sFmKJl24gLsJ_Xn16vCYpwSUJF-I1N6fXRU4

Luca Tonelli 11 Nov 2026, 08:44

Yes, but the problem would reappear with the next theme update, since it’s a bug that will persist unless it’s fixed… you should release an update containing a fix….

Fred 11 Nov 2026, 09:24

if it works for you, as well as on our test environment, we will release it in the next update

Luca Tonelli 11 Nov 2026, 10:55

I am sharing in the attachment, the solution adopted for the issue with the cart; it is both functional and clean.

We have also encountered other issues, which I list below:

1)
When you have items in your cart and apply a discount code in the cart summary, the vertical scroll bar disappears from the page, making it impossible to vertical scroll the page in any way. Refreshing the page brings the scroll bar back and restores normal functionality.

2)
The menu in the normal mobile version not AMP, it turns completely white, in the " themes/alysum/assets/css/theme.css " the problem is: " body .hidden,.d-none,.svgic.hidden { display: none!important "

3)
In the mobile version, not AMP, the "figcaption" covers the entire image. in the " themes/alysum/assets/css/theme.css " the problem is: " .dd_container, .absolute { position: absolute; "

4)
- In the AMP module, by contrast, all the widgets have issues. One example among many: `AMPbanner.tpl` lacks height and width values ​​for the images, which is why they do not appear on the home page.
- Ph_simpleblog does not appear on the home page.
- Third-party payments do not work, even when forcing the desktop version of the page.

but there is much more; these are just a few…

Fred 15 Nov 2026, 23:23

Hi Luca,

Sorry for the delay. I see you’ve applied your own fix for the cart cache. Could you confirm whether the getCacheId change I suggested in my earlier comment worked for you as well? It’s already planned for the next update, so you won’t need to patch it manually again.

For the voucher/scrollbar issue, please download the attached file and upload it to `themes/alysum/modules/ps_shoppingcart/ps_shoppingcart.js` on your server, then clear the cache and hard-reload the page. The page was staying frozen (overflow: hidden) after the cart refresh, and this file fixes it.

The remaining issues (mobile menu, figcaption, AMP) are in progress. For the AMP widgets, if you can share the page URLs and screenshots of what’s broken, that will help us fix them faster.

Luca Tonelli 16 Nov 2026, 09:32

I don't see any attachment…. In our view, the solution we adopted—which I sent to you previously—is more effective, although yours also seemed to work.

Fred 16 Nov 2026, 09:37

Sorry, here is it

Attachments: