Skip to main content

Customer name to appear on email

More
15 years 3 months ago - 15 years 3 months ago #19958 by JIK
Hi,

I'm using the "No registration" method and I need to know how to get the customer's name to appear in the Order Creation Email (Business Ed.) The customer is supplying a first and last name during checkout.

Looking at the code for the email I have changed the field from name to firstname but still no joy.
Code:
echo JText::sprintf('HI_CUSTOMER',@$data->customer->firstname);

How do I call the customer's firstname so that the email reads "Hi John," instead of just "Hi ,"

Cheers!
Last edit: 15 years 3 months ago by nicolas.

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

More
15 years 3 months ago #19979 by nicolas
You should try something like that instead:
Code:
echo JText::sprintf('HI_CUSTOMER',@{$data->order_addresses[$data->cart->billing_address->address_id]}->address_firstname);

Note for others: The emails can be edited via the menu System->Emails in the business edition.
The following user(s) said Thank You: klimmbimm

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

More
14 years 5 months ago - 14 years 5 months ago #48757 by klimmbimm

nicolas wrote: You should try something like that instead:

Code:
echo JText::sprintf('HI_CUSTOMER',@{$data->order_addresses[$data->cart->billing_address->address_id]}->address_firstname);


This code works for me if I leave out the {}.


So I am doing it like this:
Code:
<?php $title = @$data->order_addresses[$data->cart->billing_address->address_id]->address_title; if($title === "Herr") { echo JText::sprintf('Sehr geehrter Herr %s,', @$data->order_addresses[$data->cart->billing_address->address_id]->address_lastname); } else if($title === "Frau") { echo JText::sprintf('Sehr geehrte Frau %s,', @$data->order_addresses[$data->cart->billing_address->address_id]->address_lastname); } else { echo JText::sprintf('HI_CUSTOMER',@$data->customer->name); } ?>

At the moment I am wondering why it goes through the last "else" in the ORDER_STATUS_NOTIFICATION. It seems that $title is blank. Why? And how to read out the title then?
In the ORDER_CREATION_NOTIFICATION it works fine.
Last edit: 14 years 5 months ago by klimmbimm.

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

More
14 years 5 months ago #48793 by nicolas
That code is indeed for the order creation notification.
For the order status notification, you will have to use such code instead:
$data->cart->billing_address->address_title
but only AFTER the loadFullOrder function call in the email.
The following user(s) said Thank You: klimmbimm

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

Time to create page: 0.136 seconds
Powered by Kunena Forum