Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Displaying User Email in Welcome Email

Displaying User Email in Welcome Email

Locked

Views: 4,427

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
15 Oct 2008, 11:08 PM
#1
itsjosh avatar

itsjosh

New Zenner

Join Date:
Oct 2008
Posts:
12
Plugin Contributions:
0

Displaying User Email in Welcome Email

I've done an hours worth of searching through the forums and several hours worth of meddling with my code in the language file create_account.php and the create_account.php in modules (both under my templates folder heirarchy as per the override system) and can't seem to get the user's email address to show up in their welcome email.
I've added a definition to the create_account language file: ```php
define('CUSTOMER_EMAIL_ADDRESS', $email_address);

I then use this to try calling that constant within my body text: ```php
define('EMAIL_TEXT', '<div class="content-heading">Membership Information </div>' . "\n" . ' <li><strong>Username:</strong>' . CUSTOMER_EMAIL_ADDRESS  . "\n" .

In the create_account module file I added this around line 326

$_SESSION['customers_email_address'] = $email_address;

Thinking it would pass the e-mail address variable on.
Admittedly, I'm a beginner at PHP and am just getting my bearings.
Anyone have any idea what I'm doing wrong and/or how I can get this to work?

And yes, I realize that it is a bit redundant to include someone's email address in an email being sent TO that address, but seeing as it IS their user name and people often have different addresses (and most importantly, to pander to even the dumbest customers) I need to have this. Thanks.

10 Nov 2008, 9:07 AM
#2
scriptjunkie avatar

scriptjunkie

Totally Zenned

Join Date:
Jul 2008
Posts:
772
Plugin Contributions:
0

Re: Displaying User Email in Welcome Email

I'm new to PHP as well and can't answer this, but I can offer an alternative.

What if you edited the email language file for the welcome email to tell them that their user name/logon is the email address that they received their welcome email to?

If you do that, you might also mention that for security purposes, you are unable to provide the password and remind them to keep it in a secure location, and perhaps tell them about the password reset function in case they forget it.

10 Nov 2008, 9:49 AM
#3
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,809
Plugin Contributions:
15

Re: Displaying User Email in Welcome Email

Last time I looked, the login does not say username, but says Email Address. If yours says something different, you may have a strange template.

22 Sep 2009, 6:49 AM
#4
kdays avatar

kdays

Zen Follower

Join Date:
May 2008
Posts:
239
Plugin Contributions:
0

Re: Displaying User Email in Welcome Email

I am also looking at the best way to do this. I'd like to add the customer's email address that they used to register included in the welcome email. I can achieve this using the $EMAIL_TO_ADDRESS in the html template to achieve this welcome email:

The problem is that because I've used the html template file (email_template_welcome.html) to achieve this, it doesn't seem to flow through to the plain text email version.

Is there a way that I can call the customer's email address so that it can be used in the create_account.php file in the same way that STORE_NAME and EMAIL_FROM can be used.

Thanks for any and all suggestions :)

22 Sep 2009, 10:33 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Displaying User Email in Welcome Email

You would have to hard-code it in a custom copy of your /includes/modules/create_account.php file.

23 Sep 2009, 9:27 AM
#6
kdays avatar

kdays

Zen Follower

Join Date:
May 2008
Posts:
239
Plugin Contributions:
0

Re: Displaying User Email in Welcome Email

Thanks for pointing me in the right direction DrByte :)

24 Sep 2009, 11:54 AM
#7
kdays avatar

kdays

Zen Follower

Join Date:
May 2008
Posts:
239
Plugin Contributions:
0

Re: Displaying User Email in Welcome Email

DrByte, I've tried all sorts of variations of trying to code this in /includes/modules/create_account.php and am not having much luck.

I've been trying to use $email_address - is this correct?

What should the format be?

Thanks for your help.

24 Sep 2009, 11:57 AM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Displaying User Email in Welcome Email

You'll have to add $email_address to $email_text.

24 Sep 2009, 12:09 PM
#9
kdays avatar

kdays

Zen Follower

Join Date:
May 2008
Posts:
239
Plugin Contributions:
0

Re: Displaying User Email in Welcome Email

I've added $email_address to this line:

$email_text .= "\n\n" . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_GV_CLOSURE . $email_address;

Do I also need to add an extra $html_msg statement?

24 Sep 2009, 7:18 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Displaying User Email in Welcome Email

$html_msg values are only used for HTML-formatted emails, which I thought you said were already working fine.

25 Sep 2009, 1:04 AM
#11
kdays avatar

kdays

Zen Follower

Join Date:
May 2008
Posts:
239
Plugin Contributions:
0

Re: Displaying User Email in Welcome Email

I'd only worked around it for the HTML emails by putting the text inside the /email/email_template_welcome.html file together with the $EMAIL_TO_ADDRESS tag. But I would prefer to keep the contents of the email all together rather than the different sections of the email having to be updated in different files.

I hope I understand this now. The $email_text is the sections and the order that they appear in the text email. and the $html_msg is the sections and the order that they appear for the html message. And both are built from the /includes/modules/create_account.php file.

In the e-start book it has > So how do you get plain-text emails since only HTML email layout templates are available? Well, the answer is Zen Cart retains all the values from template tags and just strips away all HTML and CSS codes from an email layout template before sending out the relevant plain-text emails.

But this doesn't seem quite right as the contents of the two types of emails can be quite different. For example adding my change to the html template (Your login is: $EMAIL_TO_ADDRESS.) doesn't mean that this also appears in the plain text email.

And so, I have been trying to put this information in at the source of the email build (rather than the email template) but have still been unable to do this. I have been concentrating on getting the HTML email correct first but I will go back and check the text version re $email_address.

I can't believe how long I've spent on one email but this welcome email is the first chance you have of making an impression.

Thanks for all your help.

K

25 Sep 2009, 3:47 AM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Displaying User Email in Welcome Email

kdays:

I'd only worked around it for the HTML emails by putting the text inside the /email/email_template_welcome.html file together with the $EMAIL_TO_ADDRESS tag.Correct approach for HTML emails.
kdays:

But I would prefer to keep the contents of the email all together rather than the different sections of the email having to be updated in different files.Not possible in this version of Zen Cart. (see comment below about a future version)
kdays:

I hope I understand this now. The $email_text is the sections and the order that they appear in the text email. and the $html_msg is the sections and the order that they appear for the html message. And both are built from the /includes/modules/create_account.php file.Almost correct. Clarification: The $html_msg builds the keys that are output in the html message inside the $EMAIL_SOMETHING placeholders, regardless what order they appear in the email template .html files.

kdays:

... the contents of the two types of emails can be quite different. For example adding my change to the html template (Your login is: $EMAIL_TO_ADDRESS.) doesn't mean that this also appears in the plain text email.Correct. They are edited separately. You do have easier control over html emails.

kdays:

And so, I have been trying to put this information in at the source of the email build (rather than the email template) but have still been unable to do this.That is the best strategy.> kdays:

I have been concentrating on getting the HTML email correct first but I will go back and check the text version re $email_address.You do need to treat them separately, since the text-only content is built and used separately from the html content.

In Zen Cart v2.0 the whole email infrastructure has been redone to make all of this way easier. No more language file edits for email messages. All emails are done via email templates. Still separate versions for HTML and TEXT content, but all use clear english with the $EMAIL_SOMETHING$ placeholders ... in both HTML and TEXT messages, making all the edits a lot more straightforward. So, there's something to look forward to down the road when it's released.

In the meantime, you simply need to add the $email_address into the $email_text variable before the email is sent. (In the desired order/placement, of course, since the text message is built in a specific order.)

29 Sep 2009, 2:03 PM
#13
kdays avatar

kdays

Zen Follower

Join Date:
May 2008
Posts:
239
Plugin Contributions:
0

Re: Displaying User Email in Welcome Email

Hi DrByte

Just wanted to say a big THANK YOU for your patience and the information that, together with a break and fresh files, worked a treat first time! :yes:

Thanks again
K