Zen Cart Logo
Forums / Managing Customers and Orders / Getting Customer Name & Email Via PHP

Getting Customer Name & Email Via PHP

Locked

Views: 1,615

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
9 May 2008, 10:43 PM
#1
youderian avatar

youderian

New Zenner

Join Date:
Feb 2008
Posts:
15
Plugin Contributions:
0

Getting Customer Name & Email Via PHP

Can someone tell me how to access a customer's name and email address via PHP on the checkout success page? I can't seem to figure it out.... I've tried:

echo $account->fields['customers_lastname'];

-and-

echo $account->fields['customers_email_address'];

But these are obviously wrong. I've looked around in the code for another way / place they are stored, but can't find it.

Any help would be appreciated. Thanks........

10 May 2008, 5:36 AM
#2
drbyte avatar

drbyte

Sensei

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

Re: Getting Customer Name & Email Via PHP

Why ?

11 May 2008, 10:49 PM
#3
youderian avatar

youderian

New Zenner

Join Date:
Feb 2008
Posts:
15
Plugin Contributions:
0

Re: Getting Customer Name & Email Via PHP

Because after a customer finishes a purchase, I'd like to offer the option to enroll in an a follow-up service email list. I'd like to be able to populate the name and email fields automatically so that the customer doesn't need to re-type them in.

12 May 2008, 6:02 AM
#4
drbyte avatar

drbyte

Sensei

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

Re: Getting Customer Name & Email Via PHP

You'll have to manually re-query the data from the database, as it's not extracted for that page's output since it's not normally used there.

/includes/modules/pages/checkout_success/header_php.php

Insert the following at the end of the file, before the closing ?>```
$sql = "SELECT customers_firstname, customers_lastname, customers_email_address FROM " . TABLE_CUSTOMERS . "
WHERE customers_id = :customersID:";

$sql = $db->bindVars($sql, ':customersID:', $_SESSION['customer_id'], 'integer');
$cust = $db->Execute($sql);

Then in your template file, you can reference the info like this:
$cust->fields['customers_firstname']
$cust->fields['customers_lastname']
$cust->fields['customers_email_address']
12 May 2008, 3:09 PM
#5
youderian avatar

youderian

New Zenner

Join Date:
Feb 2008
Posts:
15
Plugin Contributions:
0

Re: Getting Customer Name & Email Via PHP

Fantastic! That was exactly what I needed. Thank you.......