Forums / Managing Customers and Orders / Custom Field in database and backend but not in emails

Custom Field in database and backend but not in emails

Views: 1,588

Results 1 to 10 of 10
26 Jul 2012, 6:57 PM
#1
swilliams88 avatar

swilliams88

New Zenner

Join Date:
Apr 2010
Posts:
39
Plugin Contributions:
0

Custom Field in database and backend but not in emails

I have a few custom fields added to our customer account section that they provide when they create their account. The information they enter does find it's way into the correct database fields and is displayed in the admin section, however, it is not passed through in the email confirmations either when an account is created or when an order is placed by the customer.

How do I pass the custom field info along in the emails?

26 Jul 2012, 7:12 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: Custom Field in database and backend but not in emails

You'll have to edit the code that builds the email content so that it includes the data you wish to add to it. The order.php class and your custom create_account.php module are key places to start with that.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

26 Jul 2012, 7:19 PM
#3
swilliams88 avatar

swilliams88

New Zenner

Join Date:
Apr 2010
Posts:
39
Plugin Contributions:
0

Re: Custom Field in database and backend but not in emails

Thanks for the fast response. Yes I've been in there for a while but cannot for the life of me get it to follow though to the email. I used your suggestions for a different thread but I couldn't get it working.

I think it might be because rather than put the fields in the $this->info = array(); a new one was created for the custom fields called $this->customer_extra_info = array();

This has been added around line 241

function get_customer_extra_info() {
global $db;
$customer_extra_info_query = "select customers_fax, customers_taxid, customers_lmnum
from " . TABLE_CUSTOMERS . "
where customers_id = '" . (int) $this->customer['id'] . "'";

$customer_extra_info = $db->Execute($customer_extra_info_query);

$this->customer_extra_info = array('fax' => $customer_extra_info->fields['customers_fax'],
                                   'taxid' => $customer_extra_info->fields['customers_taxid'],
                                   'lmnum' => $customer_extra_info->fields['customers_lmnum']);

}

And in the Order Confirmation emails (for example) the following was added to pull the info in the Office Only section but it doesn't come through:

// send additional emails
if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
$this->get_customer_extra_info();
$extra_info=email_collect_extra_info('','', $this->customer['firstname'] . ' ' . $this->customer['lastname'], $this->customer['email_address'], $this->customer['telephone'], $this->customer_extra_info['fax'], $this->customer_extra_info['taxid'], $this->customer_extra_info['lmnum']);
$html_msg['EXTRA_INFO'] = $extra_info['HTML'];

Am I missing something?

26 Jul 2012, 7:31 PM
#4
drbyte avatar

drbyte

Sensei

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

Re: Custom Field in database and backend but not in emails

If you're trying to stuff the output into the office-use-only section, then you'll need to alter the email_collect_extra_info() function to know what to do with the extra data you're passing to it.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

26 Jul 2012, 7:36 PM
#5
swilliams88 avatar

swilliams88

New Zenner

Join Date:
Apr 2010
Posts:
39
Plugin Contributions:
0

Re: Custom Field in database and backend but not in emails

Yes I did

$extra_info=email_collect_extra_info('','', $this->customer['firstname'] . ' ' . $this->customer['lastname'], $this->customer['email_address'], $this->customer['telephone'], $this->customer_extra_info['fax'], $this->customer_extra_info['taxid'], $this->customer_extra_info['lmnum']);

26 Jul 2012, 8:19 PM
#6
drbyte avatar

drbyte

Sensei

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

Re: Custom Field in database and backend but not in emails

No, that's passing data TO the function. You haven't updated the function itself to handle the extra parameters you're passing to it. So it's just spitting out the stuff it knows to do, and ignoring your extra parameters.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

26 Jul 2012, 8:28 PM
#7
swilliams88 avatar

swilliams88

New Zenner

Join Date:
Apr 2010
Posts:
39
Plugin Contributions:
0

Re: Custom Field in database and backend but not in emails

Oh ok. So where do I update the function itself?

26 Jul 2012, 8:47 PM
#8
drbyte avatar

drbyte

Sensei

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

Re: Custom Field in database and backend but not in emails

The fast way to find out which specific file to edit is by using the Developers Toolkit in your Admin:
http://www.zen-cart.com/content.php?80-how-do-i-find-out-what-files-to-edit
http://www.zen-cart.com/content.php?81-how-do-i-use-the-developers-toolkit
In your case you're looking for the function declaration (instead of a language file like the above articles use in their examples).

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

27 Jul 2012, 2:22 PM
#9
swilliams88 avatar

swilliams88

New Zenner

Join Date:
Apr 2010
Posts:
39
Plugin Contributions:
0

Re: Custom Field in database and backend but not in emails

DrByte:

The fast way to find out which specific file to edit is by using the Developers Toolkit in your Admin:
http://www.zen-cart.com/content.php?80-how-do-i-find-out-what-files-to-edit
http://www.zen-cart.com/content.php?81-how-do-i-use-the-developers-toolkit
In your case you're looking for the function declaration (instead of a language file like the above articles use in their examples).

Yes I've been working with the developers toolkit to find the various locations but there is nothing standing out to me screaming "THIS IS WHAT'S WRONG!" :-) My frustration is growing as I keep testing various options and it just won't show.

27 Jul 2012, 3:20 PM
#10
drbyte avatar

drbyte

Sensei

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

Re: Custom Field in database and backend but not in emails

I searched for "function email_collect_extra_info" and it shows me that /includes/functions/functions_email.php is where the email_collect_extra_info() function exists. It only knows how to handle the data it's been programmed to receive, so you'll need to add your parameters to it and insert the code to use your new parameters in the output it generates.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.