Creating a custom email trigger for new Affiliate sign ups

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
jis
Ensign (ENS)
Ensign (ENS)
Posts: 5
Joined: Wed Jun 09, 2010 12:38 am

Creating a custom email trigger for new Affiliate sign ups

Post by jis » Mon Dec 06, 2010 6:41 am

How can I creat a custom email trigger? We need to have an email sent to Affiliates when they sign up.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Creating a custom email trigger for new Affiliate sign ups

Post by mazhar » Mon Dec 06, 2010 7:06 am

At the moment system doesn't have any support for sending notifications on affiliate sign-up. You can accomplish this with customization. For example first of all create an Email template and fill in the details. In body section of Email template let's say you need store information, current affiliate information and current user account information. Suppose we are going to have following three variables in template body for dynamic information
$store => store information
$affiliate = affiliate information
$user = user account information

Now do the desired coding in template body using these three variables and finally we need to trigger an Email using this new template upon each signup. In order to do this you need to go to eidt Website/ConLib/AffiliateRegForm.ascx.cs file and locate following code block

Code: Select all

 _Affiliate.Save();
Group group = new Group();
group.Name = string.Format("Affiliate [{0}]", _Affiliate.Name);
group.Save();
Token.Instance.User.UserGroups.Add(new UserGroup(Token.Instance.User.UserId,group.GroupId));
Token.Instance.User.Save();
_Affiliate.GroupId = group.GroupId;
_Affiliate.Save();
and then update it as below

Code: Select all

 _Affiliate.Save();
Group group = new Group();
group.Name = string.Format("Affiliate [{0}]", _Affiliate.Name);
group.Save();
Token.Instance.User.UserGroups.Add(new UserGroup(Token.Instance.User.UserId,group.GroupId));
Token.Instance.User.Save();
_Affiliate.GroupId = group.GroupId;
_Affiliate.Save();

//Signup Notification Code Start

            CommerceBuilder.Messaging.EmailTemplateCollection emailTemplates = CommerceBuilder.Messaging.EmailTemplateDataSource.LoadForCriteria(" Name = 'AffiliateSignupTemplateName");
            if (emailTemplates.Count > 0)
            {
                emailTemplates[0].Parameters.Add("store", Token.Instance.Store);
                emailTemplates[0].Parameters.Add("affiliate", _Affiliate);
                emailTemplates[0].Parameters.Add("user", Token.Instance.User);
                emailTemplates[0].ToAddress = Token.Instance.User.Email;
                emailTemplates[0].Send();
            }
            //Signup Notification Code End

where AffiliateSignupTemplateName = what ever is the name of your signup template, so you need to place correct template name in place of it. Save the file and try some demo affiliate signup.

Post Reply