简体   繁体   中英

Add custom field in email Opencart

I am using Opencart 2.1.0.1. I have added some custom fields on the registration page. How do I display these custom fields in the email that gets send out to the store admin?

Below is the code for the standard fields:

// Send to main admin email if new account email is enabled
    if ($this->config->get('config_account_mail')) {
        $message  = $this->language->get('text_signup') . "\n\n";
        $message .= $this->language->get('text_website') . ' ' . html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8') . "\n";
        $message .= $this->language->get('text_firstname') . ' ' . $data['firstname'] . "\n";
        $message .= $this->language->get('text_lastname') . ' ' . $data['lastname'] . "\n";
        $message .= $this->language->get('text_customer_group') . ' ' . $customer_group_info['name'] . "\n";
        $message .= $this->language->get('text_email') . ' '  .  $data['email'] . "\n";
        $message .= $this->language->get('text_telephone') . ' ' . $data['telephone'] . "\n";

Add your custom field in email message along with existing field.

$message .= $this->language->get('text_custom_field') . ' ' . $data['custom_field'] . "\\n" $message .= $this->language->get('text_custom_field') . ' ' . $data['custom_field'] . "\\n" ;

Now add custom field text in catalog/language/en-gb/mail/customer.php

$_['text_custom_field']          = 'Custom field:';

You will get $data['custom_field'] value if you are passing it from frontend form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM