Send confirmation mail to linked other adresses

  • Posts: 45
  • Thank you received: 0
9 years 2 weeks ago #220059

-- HikaShop version -- : 2.6.0 Business
-- Joomla version -- : 3.4.1

Hi,

I need to get the following done. When a (b2b) customer orders products and gets a confirmation email, I also need to send that email(copy) to his account manager. What makes it more difficult is that different customers have different account managers. So I can not just add an address in the BCC field.

I want to add the emailadress and name of the account manager to the database. This could be the case:
Customer 1 orders > copy confirmation to email Account Manager A
Customer 2 orders > copy confirmation to email Account Manager A
Customer 3 orders > copy confirmation to email Account Manager B
Etc.

Do you have some tips how to get this done?

Thanks very much!

EDIT: I checked out this thread , but that didn't do the trick for me.

Last edit: 9 years 2 weeks ago by Squashtoppertje. Reason: Added link

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

  • Posts: 13201
  • Thank you received: 2322
9 years 2 weeks ago #220106

Hi,

You can create a custom address field, display it or not in the frontend, fill its value and use this kind of code at the end of the preload part of the desired emails:

if(!empty($data->cart->customfield_name)){
    $this->mailer->addBCC($data->cart->customfield_name);

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

  • Posts: 45
  • Thank you received: 0
9 years 2 weeks ago #220175

Thanks. How can I fill the (variable) value of the custom address field? Use some field type?

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
9 years 2 weeks ago #220178

Hi,

What custom address field ? Could you give more background on what you're talking about ?
How did you configure your custom field ? Could you do a screenshot ?
What you do enter in it for example ?

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

  • Posts: 45
  • Thank you received: 0
9 years 2 weeks ago #220212

Hi Nicolas,

Well, I'm responding to the reaction of Xavier. He suggests to use a custom address field for my original question. But his answer is not clear (enough) for me.

This is what I like to accomplish:
When a (b2b) customer orders products and gets a confirmation email, I also need to send that email(copy) to his account manager. What makes it more difficult is that different customers have different account managers. So I can not just add an address in the BCC field.

I want to add the emailadress and name of the account manager to the database. This could be the case:
Customer 1 orders > copy confirmation to email Account Manager A
Customer 2 orders > copy confirmation to email Account Manager A
Customer 3 orders > copy confirmation to email Account Manager B
Etc.

Thanks for your support.

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
9 years 1 week ago #220288

Hi,

Why did you copy paste the content of your first message ?

Xavier told you to use an address custom field : but you can also use a "user custom field".
And because you want to store an email address ; I think that using a "text" will be just fine for the custom field type.
You can also use a dropdown and enter the different account managers ; it's up to you !

Now ; here the documentation for the custom fields :
www.hikashop.com/support/documentation/i...shop-field-form.html

Once you will know how you want your thing ; you'll decide which type of which kind of custom field you want to use.
If you have issues for the configuration or the email modification ; in that case you can reply to that thread and provide details about what you have already done.

But you asked how you could make that "BCC" address dynamic and Xavier gave you one solution.
I'm sorry if it was not clear enough for you but the solution was there ; and there is no need to asked once again the same question.

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.

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

  • Posts: 45
  • Thank you received: 0
9 years 1 week ago #220354

Hi Jerome,

I'm sorry, but I think this is a miss communication... Xavier did give me start, but unfortunately it was not completely clear to me. I gave the same information again because it seemed like Nicolas needed it.

But the point is that I do not want the customer to select his Account Manager. The system needs to do this without the customer seeing it. So I have to do some scripting to make it able to send the copy to the right account manager. The customers are in customer groups so I wanted to use this.

I'm thinking something like, in words, not code:
If customer = in customergroup A then BCC This email address is being protected from spambots. You need JavaScript enabled to view it.;
if customer = in customergroup B then BCC This email address is being protected from spambots. You need JavaScript enabled to view it..
etc.

But I hope for some code to get me started and it was not clear to me where in the custom (address?) fields to place it.

Thanks again.

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
9 years 1 week ago #220359

Hi,

Then based on what you say you want to do, there is no need to talk about custom fields.
The line you need is this:
$this->mailer->addBCC('This email address is being protected from spambots. You need JavaScript enabled to view it.');

Then, you can add additional code around it to check the user group of the customer.
You'll find many resources online for that since it's not something related to HikaShop but Joomla. For example:
forum.joomla.org/viewtopic.php?t=530721

So for example: <?php
jimport( 'joomla.access.access' );
$groups = JAccess::getGroupsByUser($data->cart->customer->user_cms_id);
if(in_array(18,$groups)) $this->mailer->addBCC('This email address is being protected from spambots. You need JavaScript enabled to view it.'); ?>

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

  • Posts: 45
  • Thank you received: 0
9 years 1 week ago #220596

Hi,

Well, I thought this over and decided to go for the solution Xavier provided after all. However, this does not seem to work.

What I did to test it was the following:
1. I added two custom fields, one addres field and one user field.
2. For a customer I filled these fields with an emailadres.
3. I added the code Xavier gave to the preload screen of the creation notification email.
4. Tested it, but no bcc mail was send (regular emails were send).

I added this code to the preload version:

if(!empty($data->cart->emailusercustom)){
    $this->mail->addBCC($data->cart->emailusercustom);
}
 if(!empty($data->cart->emailaddresscustom)){
    $this->mail->addBCC($data->cart->emailaddresscustom);
}
// Just to test:
$this->mailer->addBCC('example@test.com');

I added the last line to see if this was beeing send, but this didn't happen. FYI: if I enter a global bcc email address in the settings of the email, this is beeing send. So it's not that the server doesn't allow it.

How can I get this to work?

Thanks!

Last edit: 9 years 1 week ago by Squashtoppertje.

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
9 years 1 week ago #220638

Hi,

This code from Xavier would only work if your custom field was of the table "order" (meaning that the customer would fill it during the checkout).

For custom user fields, you want to use such variable $data->customer->emailusercustom instead of $data->cart->emailusercustom

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

  • Posts: 45
  • Thank you received: 0
9 years 1 week ago #220666

Hmmm, this doesn't work either.

Don't know if your code is wrong, but like said in my previous mail this code does not seem to work:
$this->mailer->addBCC('This email address is being protected from spambots. You need JavaScript enabled to view it.');

I have tested it to see if I got mail this way, but this did not happen. I put it in the preload-screen, at the end.

Are you sure this is right? Is there maybe another code to try, I really need this to work?

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

  • Posts: 45
  • Thank you received: 0
9 years 1 week ago #220791

Hi,

I also tried adding this code to the HTML-version of the e-mail, but no luck.

Furthermore I tried the following code in the preload version, but this throw a 500-error:

if(!empty($data->customer->emailteama)){
    $this->mail->addBCC($data->customer->emailteama);
}
 if(!empty($data->customer->emailteamb)){
    $this->mailer->addBCC($data->customer->emailteamb);
}

Don't know if this matters, as the basic $this->mailer->addBCC('This email address is being protected from spambots. You need JavaScript enabled to view it.'); does not result in an extra mail?

Could you please assist me with this?

Thanks.

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
9 years 1 week ago #221059

Hi,

The 500 error is because $this->mail doesn't have any addBCC function, so you can't have that code.
But yes, that code should work.
Alternatively, you can try this one:

if(!is_array($mail->bcc_email))
				$mail->bcc_email = explode(',', $mail->bcc_email);
$mail->bcc_email[]=$data->customer->emailteamb;

The following user(s) said Thank You: Squashtoppertje

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

  • Posts: 45
  • Thank you received: 0
9 years 1 week ago #221077

YESSSSS! THIS IS IT!! :cheer:

This works great. Thanks.

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

  • Posts: 45
  • Thank you received: 0
7 years 11 months ago #258086

Well, this did work. However, after updating Joomla to 3.6.4. this does not seem to work anymore. BCC-mail is not being send anymore.

Have you got any idea why and how to solve this?

Thanks!

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 11 months ago #258131

Hi,

Joomla 3.5.1 had some modifications in the mail system.
But latest version of HikaShop have all required patch to all it.
See :
www.hikashop.com/forum/checkout/883603-4...heckout-process.html
www.hikashop.com/forum/orders-management...tion-recipients.html

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.

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

Time to create page: 0.067 seconds
Powered by Kunena Forum