Lukas Truninger Posted August 23, 2020 Share Posted August 23, 2020 Hello, in my previous shop I did use a simple java script to create a coupon code. The script is triggered when the page to subscribe to our newsletter is opened (a CMS page) and does fill in the coupon code and expiry date directly in some hidden fields. The customized Mailchimp integration then did store the code to database when the form was sent. I like to do now the same in Prestashop: the Coupon code is generated on a specific CMS page and must be stored into Database when user submits the form. What is the right way to do this? Is there a simple way to add some java script (and / or php), or is it required to create a complete module? Thanx Lukas function set_coupon_code() { var timestamp = Date.now(); var cupon_code = md5(timestamp); cupon_code = cupon_code.substring(0, 8); cupon_code = cupon_code.toUpperCase(); document.getElementById("mce-COUPON").value = cupon_code; var today = new Date(); var exp_date = today; exp_date.setDate(today.getDate() + 126); var exp_date2 = (exp_date.getDate() + "." + (exp_date.getMonth()+1) + "." + exp_date.getFullYear()); document.getElementById("mce-COUPON_EXP").value = exp_date2; } 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