如何检出用户已经在magento中注册的结帐页面?

时间:2018-10-16 05:55:14

标签: magento checkout

用户将在结帐页面中提供其电子邮件地址。我将必须确定用户是否已经注册。如果他已注册,则将要求输入密码进行登录,否则他将获得注册表格。 我该怎么做?

1 个答案:

答案 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'; 
        }
    }
}
相关问题