loic.bonnaillie Posted February 27 Share Posted February 27 Bonjour, Je viens d'installer le thème Optima que j'ai trouvé ici: https://optima.posthemes.com/ J'ai un souci avec la boîte d'ajout panier qui ne se lance pas , dans la console je vois une erreur lié au theme.js qui se lance au chargement de la page (donc avant de cliquer sur "Ajouter au panier": Je suis sur Presta 1.7.6.9 et mon site est : https://www.laquiberonnaise.fr/soupes/167-soupe-de-poisson-400-ml.html Je ne sais pas comment la résoudre et suis preneur de conseils Merci pour votre aide l'AI de du debugger me donne ceci comme piste: Expanded Error and Stack Trace Error Message: theme.js:2 Uncaught TypeError: Cannot read properties of undefined (reading 'quantityWanted') (Same as before, but now we have more context.) Stack Trace: theme.js:2:174763 (Where the error originates) HTMLDocument.<anonymous> (theme.js:2:175421): This tells us that the error happens within an event handler that's been attached to the document (the entire HTML page). The anonymous part means the function doesn't have a name. u (core.js:39:22924): This is a function named u within core.js. It's minified code, so the name u is not very helpful, but it shows that the problem in theme.js is triggered from a function in core.js. Object.fireWith [as resolveWith] (core.js:39:23681): This looks like it's part of a promise or event system (likely part of a library like jQuery, which appears to be used on this site). e.ready (core.js:39:25468): This is a function named ready within the minified code. It suggests the problem is happening as part of the document being considered "ready." HTMLDocument.H (core.js:39:22662): This is another event handler attached to the document. It is probably an initialisation function. What the Stack Trace Tells Us Event-Driven Problem: The core issue is occurring within an event handler. This means the problem doesn't happen immediately when the page loads, but rather when something else triggers it. In this case, it is the ready event of the document. Core.js is the Trigger: The core.js file is involved in the chain of events leading to the error. Functions within core.js are ultimately triggering the code in theme.js that causes the quantityWanted error. Document Ready State: The ready function in core.js, combined with the HTMLDocument entries in the stack, suggests that the problem happens when the browser's DOM (Document Object Model) is reported as ready, meaning it's done loading the HTML structure. Anonymous Function: The error is launched by an anonymous function in theme.js, triggered by the document ready event. This should be a key point to check. Refined Possible Causes Given the stack trace, we can refine our list of likely causes: quantityWanted Data Not Ready: The most likely cause is still that the data related to quantityWanted is not fully initialized or available when the document ready event fires. The document might be "ready" in terms of HTML structure, but that doesn't mean all data, especially dynamic data (e.g., from AJAX, JavaScript calculations), is also ready. Incorrect Event Order: The code in theme.js might be assuming that certain data will be set by the time the document is ready, but that assumption could be incorrect. Perhaps some code that should set the data is running after the ready event, or it hasn't finished yet. jQuery event handling: We are probably using the jQuery .ready() function to wait for the DOM to be loaded. If quantityWanted is loaded after the DOM, this will cause an error. Refined Debugging Steps Focus on theme.js and the ready event: Go to theme.js in the Sources panel, line 2. Look for any code that looks like it's registering an event listener related to document.ready or $(document).ready() (or similar). Set a breakpoint within that event handler. This is where the error occurs, so it's crucial to examine what's happening there. Examine the ready Handler in core.js: Go to core.js (line 39). Look for the e.ready function (it's likely minified, so it'll be hard to read, but try to get a sense of what it's doing). Set a breakpoint inside of it. This way, you can see if there are any side effects happening that might be relevant. Add log for the quantityWanted: Add a console.log() just before where quantityWanted is read. Check the log when you click on the add to cart. Data Initialization Order:Ask yourself: Where is the data related to quantityWanted expected to come from? Is it: Hardcoded in HTML? Loaded from an AJAX request? Calculated by JavaScript? Try to trace backward from the point of the error to see when and where this data is set (or should be set). Inspect the DOM at Breakpoints: When you hit your breakpoints, pause the code, and then use the Elements panel to see if the HTML elements you expect to be present and initialized are there. Is there something wrong with the value or the element? Check other related files: Don't forget to check core.js and other javascript files. There might be other functions involved in the process. In essence: We've narrowed the issue down to: when the HTML structure is finished loading, code in core.js triggers an anonymous function in theme.js, and that function tries to access quantityWanted, but it's not available yet. Follow these refined debugging steps, and you should be able to find the root cause of why quantityWanted is undefined. Link to comment Share on other sites More sharing options...
Mediacom87 Posted February 27 Share Posted February 27 Bonjour, n'hésitez pas à contacter le support lié à ce thème : https://optima.posthemes.com/#section-support 1 Link to comment Share on other sites More sharing options...
Eolia Posted February 27 Share Posted February 27 la variable selectors n'est jamais définie donc ça ne risque pas de fonctionner pour selectors.quantityWanted... Link to comment Share on other sites More sharing options...
loic.bonnaillie Posted February 27 Author Share Posted February 27 20 minutes ago, Mediacom87 said: Bonjour, n'hésitez pas à contacter le support lié à ce thème : https://optima.posthemes.com/#section-support Merci, c'est fait mais celui-ci me demande un accès ftp, je préférai éviter, au moins dans un 1er temps si je n'y arrive pas Link to comment Share on other sites More sharing options...
Knowband Plugins Posted February 27 Share Posted February 27 Pourquoi ne pas utiliser le support lorsque vous l'avez. Je pense que le magasin est actuellement dans le magasin de développement, donc je ne pense pas qu'il y ait de mal à partager les détails FTP. Vous ne pouvez pas demander les modifications, puis comparer les choses plus tard. De plus, il semble que les articles soient ajoutés au panier. Le problème vient de la notification, c'est-à-dire aucune notification d'ajout d'articles dans le panier. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now