- I’ve created a triggered email.
- got emailID
- got the snippet
- read several articles on how to insert the code
But for some reason I cannot figure out how to put it all together
I have two variables in my triggered email:
${subscribersName} - which is supposed to be customer’s first name
$.{paidplan.title} - tittle of purchased plan
My goal is to automatically send triggered email upon successful purchase and to make sure that those two variables are pointed to correct values.
Here is what I have so far:
import wixCrm from ‘wix-crm-backend’;
import wixUsers from ‘wix-users’;
export [function](function Send_Email_Function() {
const userId = wixUsers.currentUser.id;
//let contactId = // get contact ID
//let value1 = // value for variable1
wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })
.then((result) => {
if (result.status === “Successful”) {
wixCrm.emailContact(‘RvW96RK’, userId, {
variables: {
“paidplan.title”: “enter-value-here”,) [ Send_Email_Function() {](function Send_Email_Function() {
const userId = wixUsers.currentUser.id;
//let contactId = // get contact ID
//let value1 = // value for variable1
wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })
.then((result) => {
if (result.status === “Successful”) {
wixCrm.emailContact(‘RvW96RK’, userId, {
variables: {
“paidplan.title”: “enter-value-here”,)
[const](function Send_Email_Function() {
const userId = wixUsers.currentUser.id;
//let contactId = // get contact ID
//let value1 = // value for variable1
wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })
.then((result) => {
if (result.status === “Successful”) {
wixCrm.emailContact(‘RvW96RK’, userId, {
variables: {
“paidplan.title”: “enter-value-here”,) [ userId = wixUsers.currentUser.id;](function Send_Email_Function() {
const userId = wixUsers.currentUser.id;
//let contactId = // get contact ID
//let value1 = // value for variable1
wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })
.then((result) => {
if (result.status === “Successful”) {
wixCrm.emailContact(‘RvW96RK’, userId, {
variables: {
“paidplan.title”: “enter-value-here”,)
[//let contactId = // get contact ID](function Send_Email_Function() {
const userId = wixUsers.currentUser.id;
//let contactId = // get contact ID
//let value1 = // value for variable1
wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })
.then((result) => {
if (result.status === “Successful”) {
wixCrm.emailContact(‘RvW96RK’, userId, {
variables: {
“paidplan.title”: “enter-value-here”,)
[//let value1 = // value for variable1](function Send_Email_Function() {
const userId = wixUsers.currentUser.id;
//let contactId = // get contact ID
//let value1 = // value for variable1
wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })
.then((result) => {
if (result.status === “Successful”) {
wixCrm.emailContact(‘RvW96RK’, userId, {
variables: {
“paidplan.title”: “enter-value-here”,)
[wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })](function Send_Email_Function() {
const userId = wixUsers.currentUser.id;
//let contactId = // get contact ID
//let value1 = // value for variable1
wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })
.then((result) => {
if (result.status === “Successful”) {
wixCrm.emailContact(‘RvW96RK’, userId, {
variables: {
“paidplan.title”: “enter-value-here”,)
[.then((result) => {](function Send_Email_Function() {
const userId = wixUsers.currentUser.id;
//let contactId = // get contact ID
//let value1 = // value for variable1
wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })
.then((result) => {
if (result.status === “Successful”) {
wixCrm.emailContact(‘RvW96RK’, userId, {
variables: {
“paidplan.title”: “enter-value-here”,)
[if](function Send_Email_Function() {
const userId = wixUsers.currentUser.id;
//let contactId = // get contact ID
//let value1 = // value for variable1
wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })
.then((result) => {
if (result.status === “Successful”) {
wixCrm.emailContact(‘RvW96RK’, userId, {
variables: {
“paidplan.title”: “enter-value-here”,) [ (result.status === “Successful”) {](function Send_Email_Function() {
const userId = wixUsers.currentUser.id;
//let contactId = // get contact ID
//let value1 = // value for variable1
wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })
.then((result) => {
if (result.status === “Successful”) {
wixCrm.emailContact(‘RvW96RK’, userId, {
variables: {
“paidplan.title”: “enter-value-here”,)
[wixCrm.emailContact(‘RvW96RK’, userId, {](function Send_Email_Function() {
const userId = wixUsers.currentUser.id;
//let contactId = // get contact ID
//let value1 = // value for variable1
wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })
.then((result) => {
if (result.status === “Successful”) {
wixCrm.emailContact(‘RvW96RK’, userId, {
variables: {
“paidplan.title”: “enter-value-here”,)
[variables: {](function Send_Email_Function() {
const userId = wixUsers.currentUser.id;
//let contactId = // get contact ID
//let value1 = // value for variable1
wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })
.then((result) => {
if (result.status === “Successful”) {
wixCrm.emailContact(‘RvW96RK’, userId, {
variables: {
“paidplan.title”: “enter-value-here”,)
[“paidplan.title”: “enter-value-here”,](function Send_Email_Function() {
const userId = wixUsers.currentUser.id;
//let contactId = // get contact ID
//let value1 = // value for variable1
wixPay.startPayment(payment.id, { “termsAndConditionsLink”: “https://mysite.com/terms” })
.then((result) => {
if (result.status === “Successful”) {
wixCrm.emailContact(‘RvW96RK’, userId, {
variables: {
“paidplan.title”: “enter-value-here”,) ← How can I map this value?
“subscriberName”: “enter-value-here” ← How can I map this value?
}
})
.then(() => {
// email has been sent
})
. catch ((err) => {
// there was an error sending the email
});
}
}
};