Add custom bcc on admin confirmation email

  • Posts: 23
  • Thank you received: 2
9 years 5 months ago #177155

-- HikaShop version -- : 2.3.4
-- Joomla version -- : 2.5.27

Hello All.
I have create a custom adress field caled emailsalesman. In this field i enter the salesman email of every customer we have. I want this field to be as BCC in every admin confirmation email the system send in order to take both the admin and the salesman this email. I use custom field for every customer because there are more than one salesmen.

Is this possible?

Last edit: 9 years 5 months ago by sales@technoran.gr.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
9 years 4 months ago #177189

Hello,
I didn't totally understood what you wanted to do, do you just want to add the emailsalesman custom field on your admin email ?

The following user(s) said Thank You: sales@technoran.gr

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #177264

i want to take the email i have set in my new custom field as bcc on the admin notification mail

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
9 years 4 months ago #177306

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: sales@technoran.gr

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #177377

Dear Jerome i don't want to put a static email account but i want hikashop to take automatic the email acount which is set in my custom field for every client.

Example. in client1 i have set on my custom field the email This email address is being protected from spambots. You need JavaScript enabled to view it. and when this client will put an order i want from the system to send the admin notification email also as BCC to This email address is being protected from spambots. You need JavaScript enabled to view it.

in client2 i have set on my custom field the email This email address is being protected from spambots. You need JavaScript enabled to view it. so for this client i want from the system to send the admin notification email also as BCC to x2x.gmail.com

i hope you understand.

regards

Last edit: 9 years 4 months ago by sales@technoran.gr.

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
9 years 4 months ago #177410

Hi,

You can try with that code at the end of the preload of your emails that you can edit via the menu System>Emails :
$this->mailer->addBCC($userInfos->custom_field_column_name);

where custom_field_column_name is the column name of your user custom field.

The following user(s) said Thank You: sales@technoran.gr

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #177478

Dear Nicolas,
i have set the following line one each time at the end of the preload.

i have try this $this->mailer->addBCC($userInfos->emailsalesman); nothing happens

i have try this $this->mailer->addBCC('This email address is being protected from spambots. You need JavaScript enabled to view it.'); to see if it send at least a static email nothing happens

i have try this $this->mailer->addCC($userInfos->emailsalesman); to see if it has problem with the BCC nothing happens

i have try this $this->mailer->addCC('This email address is being protected from spambots. You need JavaScript enabled to view it.'); to see if it send at least a static email as CC nothing happens

Any idea?

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #177691

If someone can help me i would appreciate it.

for your help the field which has the email i want to be as bcc is in g87ob_hikashop_address

and the field name is emailsalesman

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
9 years 4 months ago #177714

Hi,

Since HikaShop 2.3.0 we allow to set some email addresses in the $mail variable.
The mail class have this code

		if(!empty($mail->cc_email)) {
			if(!is_array($mail->cc_email))
				$mail->cc_email = explode(',', $mail->cc_email);
			$this->mailer->addCC($mail->cc_email);
		}
		if(!empty($mail->bcc_email)) {
			if(!is_array($mail->bcc_email))
				$mail->bcc_email = explode(',', $mail->bcc_email);
			$this->mailer->addBCC($mail->bcc_email);
		}
which is processed just before the email is sent.
For the tests we made during the implementation, we did not find specific issue with that.
But I know that some other mail "gateway" like "mandrill" could not support some features ; like the "addStringAttachment" for example. But I guess that the addCC is implemented !

So using $mail->cc_email and $mail->bcc_email should work.
In some cases, the mailer could be reset between the moment when the email is parsed and the moment the email is sent, so using the $mail object is safer.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: sales@technoran.gr

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #177732

Dear Jerome the plugin which the member caveman upload here
www.hikashop.com/forum/4-how-to/23622-se...html?start=20#163655

works fine but only with one static email. I have try to change it and make it take the email accounts from the g87ob_hikashop_address -> emailsalesman but without success.

Do you have any idea how to do it?

Last edit: 9 years 4 months ago by sales@technoran.gr.

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
9 years 4 months ago #177742

Wait. I thought the custom field was a user custom field, not an address custom field.
In that case, you can use such code at the end of the preload of the email:
<?php $mail->bcc_email = $data->cart->billing_address->emailsalesman; ?>

The following user(s) said Thank You: sales@technoran.gr

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #178233

No it's not working this line
<?php $mail->bcc_email = $data->cart->billing_address->emailsalesman; ?>

The only thing that works now and it's not what i want is the plugin which the member caveman upload here
www.hikashop.com/forum/4-how-to/23622-se...html?start=20#163655

I don't know what to do.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
9 years 4 months ago #178314

Hi,

If you put an hard coded email ; does the $mail->bcc_email is working ?
If you put some code in the preload ; can you right access (display) the value of the custom field "emailsalesman" ?

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: sales@technoran.gr

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #178968

I have try <?php $mail->bcc_email = "This email address is being protected from spambots. You need JavaScript enabled to view it."; ?> and it doesn't work. When i select complete order it forwand me in a white screen.
Also i have try this one with the same result
$list=array('xxxxxxx@yahoo.com','xxxxxx@gmail.com');
foreach($list as $bccer){
$mailer->AddBCC($bccer);
}

Last edit: 9 years 4 months ago by sales@technoran.gr.

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #178997

Ok if i insert this this line in preload
$mail->bcc_email = ('This email address is being protected from spambots. You need JavaScript enabled to view it.');
it send bcc at this email account. But i want to forward it to multiple accounts and when i change this line to
$mail->bcc_email = ('xxxxxxx@yahoo.com','xxxxxxxx@gmail.com');
after select complete order it forward me in a white screen.
I have also test this
$list22=array('xxxxxxx@yahoo.com','xxxxxxxx@gmail.com');
foreach($list22 as $b) {
$mail->bcc_email = ($b);
}
but again nothing. So is it possible to add muitiple accounts as bcc?

Last edit: 9 years 4 months ago by sales@technoran.gr.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
9 years 4 months ago #179068

Hi,

The parenthesis are not creating an array.
To create an array, you have to use this :

$mail->bcc_email = array('xxxxxxx@yahoo.com','xxxxxxxx@gmail.com');

If you got full white page it means you have a PHP fatal error ; at this moment you should take a look at your PHP error log for more details (like an error syntax).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: sales@technoran.gr

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #179107

Jerome wrote: Hi,

The parenthesis are not creating an array.
To create an array, you have to use this :

$mail->bcc_email = array('xxxxxxx@yahoo.com','xxxxxxxx@gmail.com');

If you got full white page it means you have a PHP fatal error ; at this moment you should take a look at your PHP error log for more details (like an error syntax).

Regards,


Hi Jerome,

first of all i would like to thank you for remind me that i forgot to use the array so now it works fine.

but i cannot understand why this line works fine
$mail->bcc_email = array('xxxxxxx@yahoo.com','xxxxxxxx@gmail.com');

and this one send only to the second email account
$list22=array('xxxxxxx@yahoo.com','xxxxxxxx@gmail.com');
foreach($list22 as $b) {
$mail->bcc_email = ($b);
}

Also i would apriciate if you could help me find how to make it send to the email account which is in the following table->field
g87ob_hikashop_user ->emailsales

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
9 years 4 months ago #179160

Hi,

Your second code is not working because you're not using the bcc_email as an array but as a string.
Here a fixed version of the code

$list22=array('xxxxxxx@yahoo.com','xxxxxxxx@gmail.com');
$mail->bcc_email = array();
foreach($list22 as $b) {
   $mail->bcc_email[] = $b;
}
But it is the same thing that writing
$mail->bcc_email = array('xxxxxxx@yahoo.com','xxxxxxxx@gmail.com');
It is just some PHP ; nothing related to HikaShop.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: sales@technoran.gr

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #179323

Hi

So i would apriciate if you could help me to find how to make it send the admin notification email to the email account which is in the following
table->field
g87ob_hikashop_user ->emailsales

also one more strange thing. When my salesman choose to reply to the admin notification email which the hikashop send it with the php command line you told me, this email has as receiver the admin and the customers. Isn't strange that the email include the customers email when you choose to reply? I'm saying that because the admin notification email has to do only with the system administrator and not with the customer, correct?

Last edit: 9 years 4 months ago by sales@technoran.gr.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
9 years 4 months ago #179434

Hi,

You can use the following code:

$mail->bcc_email = array($data->cart->billing_address->emailsalesman);

By default the admin notification email is sent only to the system administrator, but with your required modification, as we are adding the customer ass bcc in the email, so when replying it is automatically used in the bcc field.

Please Log in or Create an account to join the conversation.

Time to create page: 0.108 seconds
Powered by Kunena Forum