I need guidance from you all..
I have this added method inside: Mage_Sales_Model_Order (it's in a local folder).
public function getShippingEmailAdd()
{
$ShippingEmailAdd='';
$postData = Mage::app()->getRequest()->getPost();
if (!isset($ShippingEmailAdd))
{
if (isset($postData['shipping:email'])) {
$ShippingEmailAdd =$postData['shipping:email'];
}else{
$ShippingEmailAdd = 'lol@email.com';
}
// $shipment_data = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getData();
// $ShippingEmailAdd = $shipment_data;
}
return $ShippingEmailAdd;
}
this method is focused on getting the shipping[email] input from the onepage checkout. and also added this one line under the method: samefile::sendNewOrderEmail()
$mailer->setTemplateParams(array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml,
'emailadd' => $this->getShippingEmailAdd() <--- added line
)
);
so that I could use {{var emailadd}} in order_*.html templates. but I get nothing, what did I do wrong? and what would be the right approach to achieve my goal?
UPDATE as Requested: this is the email input, coming from the shipment form which is part of the onepage checkout process:
<li>
<div class="input-box">
<label for="shipping:emailadd"><?php echo $this->__('Email Address') ?> <span class="required">*</span></label><br />
<input type="text" name="shipping[email]" id="shipping:emailadd" value="<?php echo $this->htmlEscape($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="validate-email required-entry input-text" />
</div>
<div class="input-box">
<label for="shipping:emailadd"><?php echo $this->__('Confirm Email') ?> <span class="required">*</span></label><br />
<input type="text" name="shipping[emailconfirm]" id="shipping:emailconfirm" value="<?php echo $this->htmlEscape($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="validate-email required-entry input-text" />
</div>
</li>
and again, what I'm aiming is to get the email field input after the checkout process has been sent and add the shipping[email] value to the Mage_Sales_Model_Order::getShippingEmailAdd() so that when I use it under the method age_Sales_Model_Order::sendNewOrderEmail() like this:
$mailer->setTemplateParams(array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml,
'emailadd' => $this->getShippingEmailAdd() <------ like this
)
);
so I can use it in the order_*.html email templates as {{var emailadd}}
that's it.
getShippingEmailAdd()
will return ''
The code within the if statement will not executed.
$ShippingEmailAdd='';
if (!isset($ShippingEmailAdd))
{
// remove your code from here
$ShippingEmailAdd = 'executed';
}
else{
$ShippingEmailAdd = 'not executed';
}
echo $ShippingEmailAdd;
You will test here http://writecodeonline.com/php/
Try
public function getShippingEmailAdd()
{
$postData = Mage::app()->getRequest()->getPost();
if (isset($postData['shipping:email'])) { // <- double check your form field name
$ShippingEmailAdd =$postData['shipping:email'];
}else{
$ShippingEmailAdd = 'lol@email.com';
}
return $ShippingEmailAdd;
}