我需要你们的指导..
我在里面添加了这个方法:Mage_Sales_Model_Order(它在本地文件夹中)。
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;
}
此方法专注于从单页结帐中获取送货[电子邮件]输入。并在方法下添加了这一行:samefile :: sendNewOrderEmail()
$mailer->setTemplateParams(array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml,
'emailadd' => $this->getShippingEmailAdd() <--- added line
)
);
这样我就可以在_ * .html模板中使用{{var emailadd}}。但我什么都没得到,我做错了什么?什么是实现我的目标的正确方法?
根据要求更新: 这是电子邮件输入,来自装运表单,该表格是单页结帐流程的一部分:
<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>
再一次,我的目标是在结账过程结束后获取电子邮件字段输入并将运送[email]值添加到Mage_Sales_Model_Order :: getShippingEmailAdd(),以便在我使用该方法时age_Sales_Model_Order :: sendNewOrderEmail()是这样的:
$mailer->setTemplateParams(array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml,
'emailadd' => $this->getShippingEmailAdd() <------ like this
)
);
所以我可以在_ * .html电子邮件模板中使用它{{var emailadd}}
就是这样。
答案 0 :(得分:1)
getShippingEmailAdd()
将返回''
if语句中的代码不会被执行。
$ShippingEmailAdd='';
if (!isset($ShippingEmailAdd))
{
// remove your code from here
$ShippingEmailAdd = 'executed';
}
else{
$ShippingEmailAdd = 'not executed';
}
echo $ShippingEmailAdd;
您将在此处http://writecodeonline.com/php/
进行测试尝试
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;
}