gpt4 book ai didi

Magento 新闻通讯订阅 - 如果已订阅则显示错误

转载 作者:行者123 更新时间:2023-12-02 10:51:46 25 4
gpt4 key购买 nike

您好,我在 magento 中使用默认的新闻通讯订阅包。如果用户已经在我们这里注册,我需要显示错误我见过这样的选项

    $emailExist = Mage::getModel('newsletter/subscriber')->load($email, 'subscriber_email');
if ($emailExist->getId()) {
Mage::throwException($this->__('This email address is already exist.'));
}

从这里开始Show error message in guest subscriber if user already subscribe with that Id

但这对我不起作用,但我仍然收到同样的感谢订阅消息。谢谢

最佳答案

检查这个............

$NewSellt= Mage::getModel('newsletter/subscriber')->subscribe($email);
if($NewSellt->getId()>0){
//if exits

}

如果客户是注册用户

$ownerId = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
->loadByEmail($email)
->getId();
if ($ownerId !== null && $ownerId != $customerSession->getId()) {
//'This email address is already assigned to another user.
}

关于Magento 新闻通讯订阅 - 如果已订阅则显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23362583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com