Hi Wix Codes Experts,
First of all I’m loving Wix more now each day, and Wix Code just exploded my love for Wix! Thank you all for every contribution you put in to bring Wix Code to life.
Back to my challenge:
I created a quiz on my Wix site (strictly using only Wix features with no third-party integration), I’ve solved the codes that enabled me to run some algorithm based on user’s quiz answers to redirect them to the respective result pages after saving their responses in my collection (as my opt-in).
//this part is working fine
Next, where it doesn’t work, is for me to send the user a specific triggered email also based on user’s quiz answers while redirecting them to the respective result pages and saving their responses in my collection.
//the triggered email part didn’t work
I tried studying Sending a Triggered Email with Code | Help Center | Wix.com among other Wix resources to send a specific triggered email based on their result (as run by my algorithm), but because I already have the algorithm running inside the onAfterSave(), after trying to add the triggered email codes inside, the quiz algorithm didn’t work and no email sent.
Question 1: Where to include the triggered email code snippet correctly amidst my algorithm to decide which page to redirect the user, all inside onAfterSave()?
Question 2: When it says ‘user has to be currently logged in’ what does it mean? My quiz submit form acts like a ‘sign up’ form, so by clicking on the submit button, is that considered logged in to be able to send triggered emails to them immediately?
Question 3: How to set up each triggered email to continue to send the next sequence of emails, say 1 day later, 3 days later, 1 week later, and so on?
Here’re my current codes under the quiz answers submit button, submitQuizH:
Note: The other inputs from quiz questions are on a slideshow that has been hidden upon clicking on another button to display the final form as in the screenshot above.
export function submitQuizH_click() {
if ($w('#txtName').valid && $w('#txtEmail').valid ) {
$w("#dataset1").onAfterSave( () => {
if ($w('#achieverDreamer').value === 'achiever' && $w('#providerContributor').value === 'provider1' && $w('#living').value === 'together1' && $w('#communication').value === 'goodComm' && $w('#complement').value === 'complement1' && $w('#marriageCondition').value === 'happy') {
// here, I want to send a triggered email with the unique email ID "Praiseworthy01email"
wixLocation.to("/praiseworthy-husband/");
}
else {
if ($w('#communication').value === 'poorComm') {
// here, I want to send a triggered email with the unique email ID "CanGrow01email"
wixLocation.to("/can-grow-love-husband/");
}
else if ($w('#marriageCondition').value === 'happy') {
if ($w('#providerContributor').value === 'contributor1') {
// here, I want to send a triggered email with the unique email ID "Loving01email"
wixLocation.to("/loving-husband/");
}
else {
// here, I want to send a triggered email with the unique email ID "Trustworthy01email"
wixLocation.to("/trustworthy-husband/");
}
}
else if ($w('#marriageCondition').value === 'coping') {
// here, I want to send a triggered email with the unique email ID "CanLead01email"
wixLocation.to("/can-lead-husband/");
}
else {
// here, I want to send a triggered email with the unique email ID "CanSave01email"
wixLocation.to("/can-save-husband/");
}
}
} );
}
else {
$w('#txtErrSubmit').show();
}
}
Thank you so much for helping me on this. I have been waiting to launch my quiz