New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add_to_cart event is fired twice in Hyva based theme #203
Comments
Thanks for posting. I have tested this in 3 environments of my own. And in my cases, the What did you do to also add the event via a mouse-click on the button? There must be some custom code involved, because it is not part of this module. |
Hey, Any updates on this? |
Unfortunately, I'm unable to reproduce this issue. In my case, with Hyva, the add-to-cart button submits a form to a controller, which then puts the event Note that there is no functionality in this module to generate an |
@machraf do you use the ajax add-to-cart functionality? We encounter the same issue, and i guess the issues lies around following lines in script-additions.phtml. --> let mageCacheStorage = window.localStorage.getItem('mage-cache-storage'); If you add a product to your cart and refreshes the private content, it seems to not update the local storage. If I replace following
with
It always uses the latest private content and seems to not trigger the add_to_cart event twice when reloading/navigating away after an add to cart. @thehorse2000 and @machraf could you test this change as well? If this is a working bugfix, I will create a PR. Hyva themes version: 1.1.23 |
@MaximGns We also use the ajax add-to cart functionality and are encountering the same issue. After applying your fix it indeed seems to work!
|
I'm noticing that the add_to_cart event is fired twice in a Hyva-based theme, the first time when a user clicks on the add-to-cart button and a second time after a page reloads. it seems like the event is not removed properly from mage-cache-storage in view/frontend/templates/hyva/script-additions.phtml line 58-63
I can provide more details if needed.
The text was updated successfully, but these errors were encountered: