If you want redirect to checkout instead of cart page, do the following steps
1. Find the customproductbuilder.js file in /assest section or create it if it doesn't exist following steps described in this article.
2. Add the following code to the customproductbuilder.js file
;document.body.addEventListener('CPB_ON_PRODUCT_MOUNTED', function(event) {
console.log("%cCPB is loaded", "color: #1e82dd; font-size: 18px");
customJS.init();
});
document.addEventListener('click',function(e){
if(e.target && e.target.classList.contains('personalize-it--js')){
window.dispatchEvent(new Event('resize'));
}
});
const customJS = {
init: function () {
this.initGlobals();
this.redirectToCheckout();
},
initGlobals: function() {
window.dispatchEvent(new Event('resize'));
},
redirectToCheckout: function() {
document.addEventListener('cpb-add-to-cart', function(event) {
window.location = '/checkout';
});
}
}
Comments
0 comments
Please sign in to leave a comment.