Send order email to Ship To customer field.

  • Posts: 18
  • Thank you received: 0
10 years 6 months ago #155049

How can I send an order confirmation email to another email address?

My clients store is operating with sales reps who maintain several clients on the hikashop system. They have several ship to addresses and fill out orders on their behalf. Problem is both the Sales Rep and the Ship To require the order confirmation email.

I have currently added an address_email field where the sales rep can enter the Ship To's email address.

What code can I add that will email the order confirmation to the address_email field?

Thanks in advance,

YCB

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
10 years 6 months ago #155097

Hi,

Supposing that you have a recent version of HikaShop, you can add such code at the end of the order notification emails via the menu System>Emails in the HTML version:
<?php $data->customer->user_email = array($data->customer->user_email,$data->cart->billing_address->address_email); ?>

The following user(s) said Thank You: ycb

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

  • Posts: 18
  • Thank you received: 0
10 years 6 months ago #155172

Nicolas,

Thank you for the support.. It worked perfectly.

One more question.

How can it be automated to send order status notifications in the same manner?

I tried adding the same code to order status notification and it does not do the same trick.

Is this possible without copying and pasting another email address into the notification form?

Thanks!

YCB

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
10 years 6 months ago #155210

Hi,

It will work the same for the order status notification which is sent automatically by the system when an order is automatically confirmed.

For the order status notification which is sent from the confirmation popup when you change a status in the backend, that's as different change which is needed and which is more complex.
You need to edit the file "mailform" via the menu Display>Views and add such code at the beginning:

<?php
$class = hikashop_get('class.order');
$order = $class->loadFullOrder($this->element->order_id,false,false);
$this->element->mail->dst_email.=$order->billing_address->address_email;
?>

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

  • Posts: 191
  • Thank you received: 5
8 years 3 weeks ago #253990

Hello,

I have sales people putting through orders on behalf of clients and I need to setup exactly the same and I am having some trouble getting the email through to the shipping email address.

I setup a custom field address_email as a text field (no option for email field). I added the code to the order notification emails at the bottom of the html (after last div). I then added the code below in template isis, back end, mailform just before <table class="table">.

I did a test purchase, no email are being sent to the email added in the ship to.

Any suggestions on what I am doing wrong?

Thank you
Kind regards
Lene

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
8 years 3 weeks ago #254012

Hi,

What code exactly did you add in which email ?
And which version of HikaShop are you using ?
Did you disable any emails in the menu System>Emails ?

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

  • Posts: 191
  • Thank you received: 5
8 years 3 weeks ago #254087

Hi Nicolas,

I am using HikaShop Business 2.6.4 and Joomla 3.6.4.

I created a custom field named address_email.

The following code was added at the end of the email in system -> emails, order creation notification, order creation, notification, order notification:
<?php $data->customer->user_email = array($data->customer->user_email,$data->cart->billing_address->address_email); ?>

And I added the following code in template isis (set as default), back end, mailform just before <table class="table">.
<?php
$class = hikashop_get('class.order');
$order = $class->loadFullOrder($this->element->order_id,false,false);
$this->element->mail->dst_email.=$order->billing_address->address_email;
?>

The only emails disabled are 'wait list administrator notification; and 'subscription expired' notification.

Kind regards
Lene

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
8 years 3 weeks ago #254092

Hi,

Try like that instead:
<?php $data->customer->user_email = $data->cart->billing_address->address_email; ?>

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

  • Posts: 191
  • Thank you received: 5
8 years 3 weeks ago #254184

Hi Nicholas,

I tried replacing the string in the email to:
<?php $data->customer->user_email = $data->cart->billing_address->address_email; ?>

That resulted in no emails to both original order email and the shipping address. Switched back to the other and it goes to order email only.

Regards
Lene

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
8 years 3 weeks ago #254194

Hi,

Then that means that your problem is not with that code but with your custom field.
Either its column name is not address_email, or it's not from the table address, or it's empty for the billing address of the order.

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

  • Posts: 191
  • Thank you received: 5
8 years 3 weeks ago #254308

Hi Nicolas,

I have attached some images of what I have done, probably the easiest.

Thank you
Regards
Lene

Attachments:

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
8 years 3 weeks ago #254332

Hi,

In your order details screenshot, the value of the custom field is empty for the billing address and it is only filled for the shipping address. But in your code, you use billing_address instead of shipping_address. So it's normal that you don't get the email address from the shipping address in the receiver field.

The following user(s) said Thank You: lt635

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

  • Posts: 191
  • Thank you received: 5
8 years 3 weeks ago #254389

Hi Nicolas,

Got it :) , problem solved.

Thank you
Kind regards
Lene

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

  • Posts: 191
  • Thank you received: 5
8 years 2 weeks ago #254593

Hi Nicholas,

Sorry to bother you again.....

I added another custom field address_salesrep. I tried a couple of solutions from the forum but it still does not show. The field is showing in order address backend and the name that is added on checkout, I just need it to print on the order invoice.

Thank you
Kind regards
Lene

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
8 years 2 weeks ago #254600

Hi,

Again, to be able to help, we'll need to have screenshots of what you've done to be able to tell you what's wrong.
Without those details we can only guess.
Could you provide a screenshot of the settings of the custom field and one from the order you've being useing for your tests ?
And the code modification that you did in the email in order to display the field ?

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

  • Posts: 191
  • Thank you received: 5
8 years 2 weeks ago #254668

Hi Nicolas,

I have attached an image of the custom field created and the order page in the backend. What I an trying to achieve is for the sales rep to print on the invoice.

I tried adding this to the notification email:
{LINEVAR:address_salesrep}
{VAR:address_salesrep}

Thank you
Kind regards
Lene

Attachments:

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
8 years 2 weeks ago #254710

Hi,

These tags do not exist, so it's normal they don't work.
You want to use instead: {VAR:billing_address.address_salesrep}

The following user(s) said Thank You: lt635

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

  • Posts: 191
  • Thank you received: 5
8 years 2 weeks ago #254783

Hi Nicolas,

Fantastic! I knew something was missing...

Sorry, one last question....
With the email notification, I have a field so you can add one email under billing and one under shipping. If we did want the email to go to one person under billing and another email under shipping is this the best way to include it:

<?php $data->customer->user_email = array($data->customer->user_email,$data->cart->billing_address->address_email); ?>
<?php $data->customer->user_email = array($data->customer->user_email,$data->cart->shipping_address->address_email); ?>

I have tested it and it is working.

I am really happy, my client too, with the changes we have been able to make.

Thank you
Kind regards
Lene

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
8 years 2 weeks ago #254853

Hi,

The best is to do that:

<?php $data->customer->user_email = array($data->customer->user_email,$data->cart->shipping_address->address_email, $data->cart->billing_address->address_email); ?>

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

  • Posts: 191
  • Thank you received: 5
8 years 2 weeks ago #254925

Perfect :), thank you!

Kind regards
Lene

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

Time to create page: 0.100 seconds
Powered by Kunena Forum