PrestaShop Cart Not Updating: Cache, JS and Module Conflicts
How Cart Updates Work in PrestaShop
Before diving into troubleshooting, it helps to understand how PrestaShop handles cart operations. When a customer clicks "Add to Cart," the front-end JavaScript sends an AJAX request to the server. The server processes the request, updates the cart in the database and session, then returns a JSON response containing the updated cart summary. The JavaScript receives this response and updates the cart block, product page, and any other cart-dependent elements on the page without a full reload.
This AJAX-driven approach, introduced fully in PrestaShop 1.7, replaced the older page-reload method used in PrestaShop 1.6. While it provides a much smoother shopping experience, it also introduces more potential points of failure. A cart update can break at the JavaScript level, the AJAX request level, the server processing level, or the response rendering level. Each failure point produces different symptoms and requires different diagnostic approaches.
In PrestaShop 1.7 and 8.x, the core JavaScript file responsible for cart operations is core.js, which uses jQuery to send AJAX requests to the cart controller. The cart controller processes the request and dispatches events that modules can hook into. The response triggers a page-wide event (updateCart) that all cart-aware components listen for to refresh their displayed data.
Symptom: Clicking Add to Cart Does Nothing
When clicking the Add to Cart button produces absolutely no response, no animation, no spinner, no error, the problem is almost always a JavaScript error that prevents the click handler from executing. The button's click event is never captured, so no AJAX request is sent to the server.
Open your browser's Developer Tools (F12 or Ctrl+Shift+I in Chrome, Firefox, and Edge) and switch to the Console tab. Reload the product page and look for red error messages. Common errors include $ is not defined or jQuery is not defined (jQuery failed to load), Uncaught TypeError: Cannot read property of undefined (a module's JavaScript references something that does not exist), or Uncaught SyntaxError (a JavaScript file has a syntax error, often from a module that was not properly minified).
A single JavaScript error on the page can halt execution of all subsequent JavaScript, including the core cart functionality. If a module loaded before PrestaShop's core JavaScript throws an error, the entire cart system breaks even though the module has nothing to do with the cart.
To identify the offending module, look at the file name in the error message. It will typically reference a path like /modules/somemodule/views/js/somefile.js. Disable that module temporarily to confirm it is the cause, then contact the module developer for a fix.
Symptom: Add to Cart Spins but Never Completes
If clicking Add to Cart triggers the loading animation but it spins indefinitely, the AJAX request was sent but either received no response or received an error response. Switch to the Network tab in Developer Tools, click Add to Cart, and look for the AJAX request. It will typically be a POST request to a URL containing controller=cart or cart in the path.
Click on the request to inspect it. Check the Status column: a 200 status with an empty or malformed response body indicates a PHP error on the server that was caught before output. A 500 status indicates an unhandled server error. A 403 status may indicate a security module or WAF blocking the request. A 408 or timeout indicates the server took too long to respond.
If the status is 200 but the response body contains HTML instead of JSON (look for HTML tags in the response), it means PHP encountered a warning or notice that was output before the JSON response, breaking the JSON parsing. This is extremely common and is caused by modules or overrides that output text (even a blank line before the opening PHP tag) during the cart processing hooks.
Symptom: Cart Updates but Shows Wrong Data
Sometimes the cart appears to work: the animation plays, the cart icon updates, but the displayed quantities, prices, or products are wrong. This is typically a caching issue where the customer sees stale data instead of the freshly calculated cart.
PrestaShop has multiple caching layers, each of which can serve outdated cart information. Understanding and systematically checking each layer is essential for diagnosing this type of issue.
Browser Cache Issues
The browser itself may cache AJAX responses or static JavaScript files. While AJAX POST requests should not be cached by browsers, some aggressive caching configurations or service workers can interfere.
Test by opening an incognito or private browsing window. If the cart works correctly in incognito mode, the issue is browser-cache related. Instruct the customer to clear their browser cache, or more precisely, try a hard refresh with Ctrl+Shift+R (Windows/Linux) or Cmd+Shift+R (Mac).
If your PrestaShop theme uses a service worker for progressive web app (PWA) functionality, the service worker may be intercepting and caching AJAX requests. Check the Application tab in Developer Tools, then Service Workers, to see if one is registered. Unregister it temporarily to test if it is causing the issue.
Static JavaScript files can also be cached. If you recently updated a module that modifies cart behavior, the customer's browser may still be using the old JavaScript file. PrestaShop appends a version query string to JavaScript URLs (like cart.js?v=1.0.0), but this only works if the module properly increments its version number on update.
Smarty Cache Conflicts
PrestaShop uses the Smarty template engine to render HTML on the server side. Smarty has its own compilation and caching system that can serve stale template output.
If cart-related templates were modified (by a theme update, module installation, or manual edit) but the Smarty cache was not cleared, the old template continues to be served. The compiled templates are stored in /var/cache/prod/smarty/compile/ and cached output in /var/cache/prod/smarty/cache/. Deleting the contents of both directories forces Smarty to recompile all templates from the current source files.
You can also clear the Smarty cache from the back office. Navigate to Advanced Parameters, then Performance, and click the "Clear cache" button. In PrestaShop 8.x, you can also use the "Clear Symfony cache" button which clears both the Symfony container cache and the Smarty cache.
A subtler Smarty issue involves the "Force compile" and "Cache" settings under Advanced Parameters, Performance, Smarty. During development or debugging, set Template Compilation to "Force compilation" and Cache to "No." This ensures every page load uses the latest template files. Remember to restore these to "Recompile templates if the files have been updated" and "Yes" after debugging, as force compilation significantly impacts performance.
CCC Settings and Their Impact
PrestaShop's CCC (Combine, Compress, Cache) feature, found under Advanced Parameters, Performance, merges and minifies CSS and JavaScript files to improve page load times. While beneficial for performance, CCC can cause cart issues in several ways.
When CCC is enabled, PrestaShop combines multiple JavaScript files into a single cached file. If a module's JavaScript depends on loading order (it must execute after jQuery but before another module's code), the combination process may reorder the files incorrectly, causing the dependent code to fail.
CCC also caches the combined files aggressively. After installing, updating, or removing a module, the old combined file may still be served. The fix is to manually clear the CCC cache by going to Advanced Parameters, Performance, and clicking "Clear cache" or by deleting the cached files in /themes/your_theme/cache/.
A particularly frustrating CCC issue occurs when one module's JavaScript file contains a syntax error. When CCC combines it with other files, the syntax error breaks the entire combined JavaScript bundle, disabling all JavaScript functionality on the page, including the cart. Without CCC, only the one module's JavaScript would fail while the rest continues to work. Disabling CCC temporarily can help isolate this type of issue.
To test if CCC is causing your cart issue, disable all three CCC options (Smart cache for CSS, Smart cache for JavaScript, and Apache optimization) under Performance settings. Clear all caches. If the cart starts working, re-enable the options one by one to identify which one causes the conflict.
CDN Cache Issues
If your PrestaShop store uses a CDN (Content Delivery Network) such as Cloudflare, KeyCDN, or CloudFront, the CDN may be caching responses that should not be cached. CDNs are designed to cache static content, but misconfigurations can cause them to cache dynamic AJAX responses or session-dependent pages.
Cloudflare in particular has been known to cache POST request responses when certain page rules or cache-everything rules are configured too broadly. The cart AJAX endpoint returns customer-specific data that must never be cached by a CDN.
To test if the CDN is involved, temporarily bypass it. In Cloudflare, you can pause the CDN or add a page rule to bypass cache for your entire domain temporarily. If the cart works correctly without the CDN, review your caching rules to ensure that AJAX endpoints and dynamic pages are excluded from caching.
For Cloudflare specifically, ensure that the "Cache Everything" page rule does not cover your entire domain. If you must use it, add a rule with higher priority that bypasses cache for URLs containing controller=cart, ajax=true, and the checkout path. Also verify that the "Browser Cache TTL" is not set too high for dynamic assets.
Cookie and Session Problems
PrestaShop uses cookies to maintain the shopping session, including the cart. If cookies are not working correctly, the cart cannot persist between requests. Each AJAX cart update creates a new session instead of updating the existing one, resulting in a cart that appears empty after every page load.
Common cookie issues include: the cookie domain is misconfigured (the cookie is set for www.example.com but the AJAX request goes to example.com without the www prefix, or vice versa), the cookie path is wrong, the SameSite attribute is set to Strict which blocks cookies in certain cross-origin scenarios, or the cookie is too large and is being rejected by the browser (browsers typically limit cookie size to 4KB).
Check cookies in the Application tab of Developer Tools. Look for the PrestaShop session cookie (named PrestaShop-[hash] in newer versions). Verify that it has the correct domain, path, and that it is being sent with AJAX requests (check the Cookie header in the Network tab for the cart AJAX request).
On multi-domain or multi-shop setups, cookie issues are especially common. If the store is accessible via both http and https, or via both www and non-www versions, the cookie may not be shared between these variations. Ensure that your store uses a single canonical URL and that all other variations redirect to it.
SSL certificate issues can also prevent cookies from working. If the Secure flag is set on the cookie but the page is loaded over HTTP (or mixed content), the browser will not send the cookie. Ensure your entire store is served over HTTPS consistently.
Module Conflicts: Diagnosis Process
Module conflicts are the most common cause of cart issues in PrestaShop. Two or more modules may hook into the same cart events and interfere with each other, or a single module may have a bug that corrupts the cart response.
The systematic approach to diagnosing module conflicts involves disabling modules in groups. Start by disabling all third-party modules (keep PrestaShop's native modules active). If the cart works, re-enable modules in groups of 5. When the problem reappears, you have narrowed it down to 5 modules. Disable those 5 and re-enable them one at a time to find the exact culprit.
Pay special attention to modules that hook into these PrestaShop hooks, as they directly affect cart behavior: actionCartSave, actionCartUpdate, displayShoppingCart, displayShoppingCartFooter, actionBeforeCartUpdateQty, actionAfterCartUpdateQty, displayHeader (modules that add JavaScript here can conflict with cart JS), and actionFrontControllerSetMedia.
To see which modules are registered on cart-related hooks, check the database:
SELECT h.name, m.name FROM ps_hook_module hm JOIN ps_hook h ON h.id_hook = hm.id_hook JOIN ps_module m ON m.id_module = hm.id_module WHERE h.name LIKE '%cart%' ORDER BY h.name, hm.position;
This query lists all modules hooked into cart-related hooks, along with their execution order. Conflicts often arise when two modules both try to modify the cart total or apply discounts in incompatible ways.
Debugging with Browser DevTools: A Detailed Walkthrough
Browser Developer Tools are your most powerful weapon for diagnosing cart issues. Here is a step-by-step walkthrough of how to use them effectively.
Step 1: Open DevTools and go to the Console tab. Clear all existing messages. Reload the product page. Note any errors or warnings that appear. These are pre-existing issues that may or may not be related to the cart problem but should be documented.
Step 2: Switch to the Network tab. Check the "Preserve log" checkbox so requests are not cleared on page navigation. Filter by "XHR" or "Fetch" to see only AJAX requests. Click the Add to Cart button.
Step 3: Examine the AJAX request. Click on the cart request that appears. In the Headers sub-tab, verify the Request URL is correct and the Status Code is 200. In the Request payload or Form Data sub-tab, verify that the correct product ID, quantity, and attribute combination are being sent.
Step 4: Check the Response. Switch to the Response or Preview sub-tab. The response should be valid JSON. If you see HTML mixed in, a PHP error or warning is being output. If the response is empty, the server-side processing crashed before generating output. If the JSON is valid but contains error messages, read them for clues.
Step 5: Check the Console after the AJAX response. JavaScript errors that occur during processing of the AJAX response will appear in the Console after the network request completes. These errors indicate that the response was received but could not be properly processed by the front-end JavaScript.
PrestaShop 8.x Specific Considerations
PrestaShop 8.x uses a significantly updated front-end architecture compared to 1.7. The cart JavaScript has been refactored, and some previously jQuery-dependent code now uses vanilla JavaScript or updated jQuery methods. Modules written for PrestaShop 1.7 that manipulate the cart DOM directly may fail on 8.x because the HTML structure and CSS class names have changed.
The Symfony integration in PrestaShop 8.x also means that cache clearing is more involved. The Symfony container cache, located in /var/cache/prod/ and /var/cache/dev/, can contain compiled service definitions and route mappings that affect how cart controllers process requests. Clearing only the Smarty cache is not sufficient; you must also clear the Symfony cache.
PrestaShop 8.x also introduced stricter Content Security Policy (CSP) headers in some configurations. If your server or a security module adds CSP headers that restrict inline JavaScript or AJAX requests to specific domains, the cart AJAX calls may be blocked. Check the Console for CSP violation messages, which appear as red errors mentioning "Content Security Policy."
Server-Side Issues: PHP Sessions and Configuration
PHP session configuration can cause cart issues that are difficult to diagnose because they appear intermittent. If the session storage directory is full, has incorrect permissions, or is on a filesystem that does not support file locking, sessions may be lost or corrupted between requests.
Check your PHP session configuration: session.save_path must point to a writable directory with sufficient disk space. session.gc_maxlifetime controls how long sessions are kept; if set too low, customers lose their carts during long browsing sessions. session.cookie_lifetime should match or exceed the gc_maxlifetime value.
On shared hosting with many sites, the session directory may contain millions of files from all hosted sites, making session file access slow. If your hosting provider supports it, configure a per-site session directory or use database-based sessions.
For stores using multiple web servers behind a load balancer, sessions must be shared between servers. If session storage is file-based and local to each server, a customer's subsequent request may hit a different server that does not have their session, resulting in an empty cart. Use a shared session store such as Redis, Memcached, or database sessions in load-balanced environments.
Step-by-Step Diagnosis Checklist
When a customer reports that the cart is not updating, work through this checklist in order:
1. Reproduce the issue. Try to replicate the problem in an incognito window using the same product and browser the customer reported. If you cannot reproduce it, ask the customer for their browser version, device type, and exact steps.
2. Check the browser console for JavaScript errors. Any red error message is potentially the cause, even if it seems unrelated to the cart.
3. Check the network request. Verify the AJAX request is sent, returns a 200 status, and contains valid JSON.
4. Clear all caches: Smarty compile cache, Smarty cache, Symfony cache, CCC cache, OPcache, and CDN cache if applicable.
5. Disable CCC. If the cart works with CCC disabled, a JavaScript combination error is the cause.
6. Test with the default theme. Switch temporarily to PrestaShop's default classic theme. If the cart works on the default theme, the issue is in your custom theme's JavaScript or templates.
7. Disable third-party modules. If the cart works with all third-party modules disabled, use the binary search method to identify the conflicting module.
8. Check PHP error logs. Server-side errors that do not reach the browser are logged here.
9. Verify cookie and session configuration. Check the session cookie in DevTools and verify PHP session settings on the server.
10. Test on a different device and network. This eliminates local browser issues, network proxies, and device-specific JavaScript compatibility problems as potential causes.
For more details, read our guides: Reducing Cart Abandonment in PrestaShop: Proven Strategies and Module Conflicts: Why Two Good Modules Sometimes Break Each Other.
Was this answer helpful?
Still have questions?
Can't find what you're looking for? Send us your question and we'll get back to you quickly.