I want to get the first and last name in a custom contact form in Magento 1.9.x
in my custom_contact.phtml file I have this:
<?php
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
// Get the customer object from customer session
$customer = Mage::getSingleton('customer/session')->getCustomer();
$custID = $customer->getID();//get customer id
$custFirstName = $customer->getFirstname();
$custLastName = $customer->getLastname();
$custEmail = $customer->getEmail();//get customer email
}
?>
<div class="field">
<label for="xfirstname" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('First Name') ?></label>
<div class="input-box">
<input type="text" name="xcustom" id="xcustom" value="" style="display:none !important;" />
<input name="xfirstname" id="xfirstname" title="<?php echo Mage::helper('contacts')->__('First Name') ?>" value="<?php echo $custFirstName ?>" class="input-text required-entry" type="text" />
</div>
</div>
<div class="field">
<label for="xlastname" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Last Name') ?></label>
<div class="input-box">
<input name="xlastname" id="xlastname" title="<?php echo Mage::helper('contacts')->__('Last Name') ?>" value="<?php echo $custLastName ?>" class="input-text required-entry" type="text" />
</div>
</div>
and I add this conditions in the transactional email:
{{if xcustom}}First Name: {{var customer.xfirstname}}{{else}}{{/if}}
{{if xcustom}}First Name: {{var customer.xlastname}}{{else}}{{/if}}
Name: {{var data.name}}
Email: {{var data.email}}
Telephone: {{var data.telephone}}
Comment: {{var data.comment}}
but Firsname and Lastname content not exist in my email. Can someone help me?