I would like to customise the order notification emails. I have customised the front end invoice and I would like the customer email to be of a very similar format. I would also like the administrator notification to include allot more detail, essentially to eliminate the need for my accounts team to access the backend of our website.
So with this in mind I have a couple of questions.
1. When are the following emails sent and to whom are they sent?
Order administrator notification
Order creation notification
Order status notification
Order notification
User account
2. Within these templates I see that the variable $data is used to obtain order_number, order_payment_method, order_full_price ect. Can you please point me in the direction of where this is all declared so I can get a comprehensive list of what data is available to call upon when customising the emails? For example I would like to include the coupon code, customer email and tax codes used.
1.
Order administrator notification -> to the admin when the order is created
Order creation notification -> to the user when the order is created
Order status notification -> to the user when the order is confirmed
Order notification -> to the user when the admin send an email for an order from the back end
User account -> to the user when he creates a new account on HikaShop registration page/checkout page
2.
The $data comes from different places. One example is in the after_confirm function of the file components/com_hikashop/controller/checkout.php
The coupon code is in: $data->order_discount_code
The email is in: $data->customer->user_email
What do you mean by tax code ?
By Tax codes I just meant which Tax rate was applied.
This should be ok though as I only have one and therefore if there is a Tax value then I know the tax rate.
For the email you need to do like that:
echo 'Email: '.$data->customer->user_email[0];
For the phone number you can do like that:
$address = $data->order_addresses[$data->cart->billing_address->address_id];
echo 'Phone: '.$address->address_phone;
This does not return the customers email it returns the administrator email. In other words the email to which the notification is being sent.
I would like to display the email address of the customer who bought the products.
Ah indeed, for the order admin notification the address receiving the email is the admin email. I thought you were editing the user emails...
For the admin email, you need to use the code:
$user = hikashop::loadUser(true);
echo $user->user_email;
Mmm that's strange. The loadUser function can only return the current user information...
You could try like that:
$userCMS =& JFactory::getUser();
echo $userCMS->get('email');
Nicolas, i followed this thread to add the customer's email to the admin email template. i got the same results as divine. BUT i couldnt get the last piece of code to work either.
$userCMS =& JFactory::getUser();
echo $userCMS->get('email');
returns null.
the others returned exactly what divine said. an array and then the admin email.
i am using the business edition (latest). joomla 1.5.23
The code
$userCMS =& JFactory::getUser();
echo $userCMS->get('email');
will only return null if the user is not logged in. So I presume that it's the case ?
alternatively, you can try that:
$userClass = hiakshop_get('class.user');
$user = $userClass->get($data->order_user_id);
echo $user->user_email;
hi there, thanks, this returns the following error:
Call to undefined function hiakshop_get() in /..mypathhere../media/com_hikashop/mail/order_admin_notification.html.modified.php on line 10
nicolas, with the typo fixed (i should have seen that)... it returns array.
when i dump the array it returns only one item. our email address not the customers email address.
help!
we really need this.
thanks, Liz
Then it must be a problem of cache. Try like that :
$userClass = hiakshop_get('class.user');
$userClass->get(false);
$user = $userClass->get($data->order_user_id);
echo $user->user_email;
That will reset the cache before loading the user information from the database.
I just used this code lately..
$userClass = hikashop_get('class.user');
$userClass->get(false);
$user = $userClass->get($data->order_user_id);
echo $user->user_email;
This gotta work for u..