Issue
In the compiled theme.js i can find event listeners like prestashop.on("updatedProduct")
and prestashop.on("clickQuickView")
.
More about those here.
I cannot get the web pack to work, so i would like to just add a listener in the custom.js (i know this is bad practice, i just need a quick solution).
How do i refer to this prestashop
in custom.js, so i can listen for an event like updateProductList
?
Solution
Here is a bulletproof answer :
$(document).ready(function () {
if(typeof prestashop !== 'undefined') {
prestashop.on(
'updateCart',
function (event) {
if(typeof event.reason.linkAction !== "undefined" && event.reason.linkAction == "add-to-cart") {
if (typeof event.reason.idProduct == "undefined" || event.reason.idProduct == "undefined") {
// Bulletproofed action
}
}
}
);
}
});
Answered By - Matt Loye Answer Checked By - Terry (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.