简体   繁体   English

Magento触发JS添加到购物车

[英]Magento trigger JS on add to cart

I'm working on a new shopping sidebar that appears on mouseover etc. While I have all the basic functionality up and working the one thing I am having issues with is the following. 我正在开发一个新的购物侧边栏,该边栏会出现在鼠标悬停等上。当我具备所有基本功能并正在工作时,遇到的一件问题如下。

I would like the popup to appear for x seconds (via a js function) once an item has been added to cart and the page reloads. 我希望将某项添加到购物车并重新加载页面后,弹出窗口显示x秒(通过js函数)。

I'm having greatly difficulty finding where to insert this call to the JS, or the general add to cart success messages. 我很难找到将此调用插入JS的位置,或者将其添加到购物车成功消息中。

does anyone have any ideas where it is located? 有谁知道它的位置?

Thanks 谢谢

If this should be shown before the Page is new loaded, you use for example a onClick Event on the addToCart Elements. 如果应该在新加载页面之前显示此内容,则可以在addToCart Elements上使用onClick事件。

If it should be shown, after the Page is new loaded, you need an observer for the AddToCart event, which sets a variable in I think the Session and you add a js trigger, if this variable is true (and set it false after this). 如果应该显示,则在重新加载Page之后,您需要一个AddToCart事件的观察者,该事件在我认为Session设置了一个变量,并且添加了js触发器(如果此变量为true,则在此之后将其设置为false) )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM