我是Magento和PHP的新手。我使用以下行来获取电子邮件,除了客户刚刚注册的情况外,它的工作正常。有什么建议?感谢。
$userEmail = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
答案 0 :(得分:2)
我假设此代码在客户对象数据正确保存之前运行。
有一行代码被调用:在OnePageCheckout中,它执行以下操作:
/**
* Involve new customer to system
*
* @return Mage_Checkout_Model_Type_Onepage
*/
protected function _involveNewCustomer()
{
$customer = $this->getQuote()->getCustomer();
if ($customer->isConfirmationRequired()) {
$customer->sendNewAccountEmail('confirmation', '', $this->getQuote()->getStoreId());
$url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
$this->getCustomerSession()->addSuccess(
Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.', $url)
);
} else {
$customer->sendNewAccountEmail('registered', '', $this->getQuote()->getStoreId());
$this->getCustomerSession()->loginById($customer->getId());
}
return $this;
}
如果客户只是注册,而不是使用结账流程,那么使用请求参数的功能就像Anton说的那样:
/app/code/core/Mage/Customer/Block/Form/Register.php
/**
* Restore entity data from session
* Entity and form code must be defined for the form
*
* @param Mage_Customer_Model_Form $form
* @return Mage_Customer_Block_Form_Register
*/
public function restoreSessionData(Mage_Customer_Model_Form $form, $scope = null)
{
if ($this->getFormData()->getCustomerData()) {
$request = $form->prepareRequest($this->getFormData()->getData());
$data = $form->extractData($request, $scope, false);
$form->restoreData($data);
}
return $this;
}
答案 1 :(得分:1)
你可以直接从请求参数中获取它吗?