Page 1 of 1

How to show customer group in checkout email?

Posted: Fri Nov 29, 2013 1:25 pm
by 3antz
Hi there,

Does anyone know how to return the customer group name on the checkout email (sent to customer)? I know for sure to edit the .tpl but im not sure the exact command to include.

Can anyone please help?

Thank you

Re: How to show customer group in checkout email?

Posted: Fri Nov 29, 2013 10:10 pm
by 3antz
Hi, I still can't seem to figure this out. I've included <?php echo $text_customer_group; ?><?php echo $customer_group; ?> in order.tpl but I can't seem to get it to display on the confirmation email. Can anyone please help this newbie? :) Thanks.

Re: How to show customer group in checkout email?

Posted: Sat Feb 06, 2016 8:24 am
by robertoliver
i would like to get this too. let me know if you have found the solution.
thanks,
robert

Re: How to show customer group in checkout email?

Posted: Sat Feb 06, 2016 1:45 pm
by ocart777
catalog/language/your_language/mail/order.php
search for

Code: Select all

$_['text_new_email']  			= 'Email:';
add after

Code: Select all

$_['text_customer_group']  		= 'Customer Group:';
catalog/model/checkout/order.php
search for

Code: Select all

$subject = sprintf($language->get('text_new_subject'), $order_info['store_name'], $order_id);
add before

Code: Select all

$this->load->model('account/customer_group');
$customer_info = $this->model_account_customer->getCustomer($order_info['customer_id']);
$customer_group = $this->model_account_customer_group->getCustomerGroup($customer_info['customer_group_id']);
search for

Code: Select all

$template->data['text_email'] = $language->get('text_new_email');
add after

Code: Select all

$template->data['text_customer_group'] = $language->get('text_customer_group');
$template->data['customer_group'] = $customer_group['name'];
catalog/view/theme/your_theme_name/template/mail/order.tpl
search for

Code: Select all

<b><?php echo $text_email; ?></b> <?php echo $email; ?><br />
add after

Code: Select all

<b><?php echo $text_customer_group; ?></b> <?php echo $customer_group; ?><br />
ONLY APPLIED TO OC1520 - OC1521
Create new file and name it customer_group.php this file content should be:

Code: Select all

<?php
class ModelAccountCustomerGroup extends Model {
	public function getCustomerGroup($customer_group_id) {
		$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "customer_group cg LEFT JOIN " . DB_PREFIX . "customer_group_description cgd ON (cg.customer_group_id = cgd.customer_group_id) WHERE cg.customer_group_id = '" . (int)$customer_group_id . "' AND cgd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
		
		return $query->row;
	}

	public function getCustomerGroups() {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_group cg LEFT JOIN " . DB_PREFIX . "customer_group_description cgd ON (cg.customer_group_id = cgd.customer_group_id) WHERE cgd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY cg.sort_order ASC, cgd.name ASC");
		
		return $query->rows;
	}
}
?>
and this file should be placed into public_html/catalog/model/account/ folder

ONLY APPLIED TO OC1530 - OC1531
catalog/model/account/customer_group.php
search for

Code: Select all

$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "customer_group WHERE customer_group_id = '" . (int)$customer_group_id . "'");
replace with

Code: Select all

$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "customer_group cg LEFT JOIN " . DB_PREFIX . "customer_group_description cgd ON (cg.customer_group_id = cgd.customer_group_id) WHERE cg.customer_group_id = '" . (int)$customer_group_id . "' AND cgd.language_id = '" . (int)$this->config->get('config_language_id') . "'");

Re: How to show customer group in checkout email?

Posted: Sat Feb 06, 2016 1:48 pm
by ocart777
Clipboard02.jpg

Clipboard02.jpg (14.79 KiB) Viewed 2351 times


Re: How to show customer group in checkout email?

Posted: Sun Feb 07, 2016 9:44 am
by robertoliver
Thank you for the time to help this.
I am using OC 1.5.3.1 with four customer groups: ASIA, AUSTRALIA, AMERICA and EUROPE.
I have followed your instructions, but still no luck (the customer group remains empty).
Would you please check if there any additional scripts/codes to be added?
Again, I really appreciate for your help!

Thanks,
Robert

Re: How to show customer group in checkout email?

Posted: Sun Feb 07, 2016 7:18 pm
by ocart777
robertoliver wrote:Thank you for the time to help this.
I am using OC 1.5.3.1 with four customer groups: ASIA, AUSTRALIA, AMERICA and EUROPE.
I have followed your instructions, but still no luck (the customer group remains empty).
Would you please check if there any additional scripts/codes to be added?
Again, I really appreciate for your help!

Thanks,
Robert
hi, i've edited my post, you can refer there.. but still you need to start over because the previous code will not working as its use the customer_id instead of customer_group_id to search for customer_group in model file

(SOLVED) How to show customer group in checkout email?

Posted: Mon Feb 08, 2016 2:59 pm
by robertoliver
Hi,
It works great !!!
Thank you so much..

Robert

Re: How to show customer group in checkout email?

Posted: Wed Dec 02, 2020 11:05 pm
by gtphotography
I have done all these in opencart 1.5.6.4 but in mail order customer group is empty.. is there any difference for 1.5.6.4?