用户将在结帐页面中提供其电子邮件地址。我将必须确定用户是否已经注册。如果他已注册,则将要求输入密码进行登录,否则他将获得注册表格。 我该怎么做?
答案 0 :(得分:0)
给出了示例代码
以phtml
<script type="text/javascript">
oData.email = 'customeremail@domain.com';
jQuery.ajax({
url:postUrl,
type: "POST",
data: oData,
dataType: "json",
success:function(data) {
// here enable the password enter text field
}
});
</script>>
在Ajax控制器中
public function checkCustomerExistAction()
{
if ($this->isXmlHttpRequest()) {
echo 'Ajax Expired';
return;
$websiteId = Mage::app()->getWebsite()->getId();
$email = $this->getRequest()->getPost('email');
$customer = Mage::getModel('customer/customer');
$customer->setWebsiteId($websiteId);
$customer->loadByEmail($email);
// here check the customer exist or not
if ($customer->getId()) {
echo $customer->getId();
// here you can use your own logic
}
else {
echo '0';
}
}
}