closeupman Posted November 28, 2013 Share Posted November 28, 2013 (edited) Hi, I was testing out the newsletter sign up and it's saying 'email is already registered' no matter what email I put. Any ideas why this is happening? Thanks www.sitinuriatstudio.com Edited December 1, 2013 by closeupman (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted November 28, 2013 Share Posted November 28, 2013 I tried it and while I did get email already registered, it did in fact send me an email thanking me for signing up for newsletter. what verson of ps are you using? what version of newsletter module? is this an upgraded shop? Link to comment Share on other sites More sharing options...
closeupman Posted November 28, 2013 Author Share Posted November 28, 2013 (edited) I'm using 1.5.5 Newsletter Block 1.4 No, it's not an upgraded shop. Thanks. ALSO, if i sign up for the newsletter on the sidebar, say from, http://www.sitinuriatistudio.com/large-sized-roses/?orderby=name&orderway=desc, I get a blank page Edited November 28, 2013 by closeupman (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted November 29, 2013 Share Posted November 29, 2013 I can look at this tomorrow..would you be so kind to message me if I don't get back to this? I don't want to forget.. Link to comment Share on other sites More sharing options...
ibndawood Posted November 30, 2013 Share Posted November 30, 2013 Is this issue resolved ? Link to comment Share on other sites More sharing options...
closeupman Posted November 30, 2013 Author Share Posted November 30, 2013 Assalamu Alykum Dawood, No, not yet. You can check out my website: sitinuriatistudio.com to see the problem. It will send the email registration to the person, but it shows in red,'your email is already registered still. Also, if they try to register from a category or product page, where my newsletter is on the side, it'll go back to my homepage and give that same error (at least better than going to a blank page as it had before, but still weird!). Link to comment Share on other sites More sharing options...
ibndawood Posted December 1, 2013 Share Posted December 1, 2013 Wa alaikum salaam warahmatullah! I had setup PS v1.5.5 and NewsLetter Module 1.4. We need to debug this problem step by step because I really don't know what the problem is exactly. Can u send me your BlockNewsLetter Module and send it to me ? I'll try to reproduce the error in my local setup and then insha Allah I will have an answer. Link to comment Share on other sites More sharing options...
ibndawood Posted December 1, 2013 Share Posted December 1, 2013 (edited) As salaamu alaikum, I have found the bug and here is the fix. I wrote this in another forum reproducing it here. This is age old bug. Its amazing this bug escaped the eyes of prestashop developers. In Programming, equal to is == (double equal to) and a single = is assignment. So search for line : if (!$registered = Db::getInstance()->getRow($sql)) return self::GUEST_NOT_REGISTERED; Replace the above with this piece of code if (!$registered == Db::getInstance()->getRow($sql)) return self::GUEST_NOT_REGISTERED; Notice the doubel equal to. This should fix your bug. Edited December 2, 2013 by ibndawood (see edit history) 1 Link to comment Share on other sites More sharing options...
closeupman Posted December 1, 2013 Author Share Posted December 1, 2013 Wa'alkum Salam Brother, I tried that and I get, "An error occurred during the subscription process." So I've switched it back now. I've attached my newsletter module, maybe you can try it with it and see why you get that error with mine and not yours. Thanks. blocknewsletter.php Link to comment Share on other sites More sharing options...
ibndawood Posted December 1, 2013 Share Posted December 1, 2013 (edited) Wow. Can't believe the whole blocknewsletter module itself is so flawed. Too many places with assignment (=) instead of equal to (==). I have changed them in all the places. Here is the updated file. blocknewsletter.php This should work insha Allah. Edited December 2, 2013 by ibndawood (see edit history) 1 Link to comment Share on other sites More sharing options...
El Patron Posted December 1, 2013 Share Posted December 1, 2013 Wow. Can't believe the whole blocknewsletter module itself is so flawed. Too many places with assignment (=) instead of equal to (==). I have changed them in all the places. Here is the updated file. blocknewsletter.php This should work insha Allah. if this fixes the issue, then a good time to add to git hub. 1 Link to comment Share on other sites More sharing options...
closeupman Posted December 1, 2013 Author Share Posted December 1, 2013 Jazakallah, That fixes it. I'll have to check the original to the new one to see what you did. Cuz you must've done more like you said, because it didn't work for me when I did that one fix. Wow. Can't believe the whole blocknewsletter module itself is so flawed. Too many places with assignment (=) instead of equal to (==). I have changed them in all the places. Here is the updated file. blocknewsletter.php This should work insha Allah. 1 Link to comment Share on other sites More sharing options...
ibndawood Posted December 2, 2013 Share Posted December 2, 2013 (edited) Hi El Patron, Yes I will try a pull request in github. Closeupman, Yes there are about 7 places this mistake is repeated. I changed in all those places. Here is the detailed account : http://blog.prestastrap.com/block-newsletter-module-returns-this-email-address-is-already-registered-error/ Edited December 2, 2013 by ibndawood (see edit history) Link to comment Share on other sites More sharing options...
ibndawood Posted December 2, 2013 Share Posted December 2, 2013 I am testing on the changes. I think there are few places where the single = is intentional. I will do a complete test and get back to you. Link to comment Share on other sites More sharing options...
ibndawood Posted December 2, 2013 Share Posted December 2, 2013 (edited) Guys, I jumped the gun saying the prestashop developers had made the most basic mistake in programming. But its my mistake I failed to look into the code thoroughly. I did look into it and I found out that those assignment operators were intentional. Ok so what was causing the problem. Quick answer : The Hooks. i.e. if the module is hooked to more than one place then this error will occur. Long Answer : Lets assume you have hooked block newsletter to Left Column and to Footer or Home. You hide the left column in the home page (note : you are only hiding the left column. This doesn’t mean the left column hook is not executed) and just display the newsletter block in the home page. When you submit the email. This is what happens. * First the left column hook is executed, which will take your email and save it to the database. * Next footer (or home) hook is executed. So what happens now while executing the footer hook (or home) is that the module tries to save the email again. Since we had already saved the email while executing the left column hook. We get “This email address is already registered” error. What is the fix ? We’ll have to make sure that the Email save process is called only when its corresponding hook is called and should do nothing when other hooks are executed. That is when you click on submit from the form in the footer, the save process should be called only in hookFooter and not during executing of other hooks. I have implemented the fix here : blocknewsletter.zip Once again, I am sorry for my carelessness. Note : If your theme overrides blocknewsletter module then make sure you copy the blocknewsletter.tpl file to themes/<theme-name>/modules/blocknewsletter/ Please let me know if you have any problems. Edited December 2, 2013 by ibndawood (see edit history) 2 Link to comment Share on other sites More sharing options...
ibndawood Posted December 2, 2013 Share Posted December 2, 2013 I corrected my mistake and updated my blog : http://blog.prestastrap.com/block-newsletter-module-returns-this-email-address-is-already-registered-error-2/ Link to comment Share on other sites More sharing options...
xsure Posted May 27, 2014 Share Posted May 27, 2014 Hi! I know that subject is solved. But I've spent several days with that problem in my template build and tested on PS v.1.5.6.2 and BlockNewsletter v.1.4. After long time search and tries, ibndawwod pointed a good aproach but doesn't solved it in my case. The problem is certainly that the module is read more than once. I make the call with the smarty method: {hook h='displayLeftColumn' mod='blocknewsletter'} Finally I solved with 2 minor changes, both in function _prepareHook in blocknewsletter.php:Original file: private function _prepareHook($params) { if (Tools::isSubmit('submitNewsletter')) { $this->newsletterRegistration(); if ($this->error) { $this->smarty->assign(array('color' => 'red', 'msg' => $this->error, 'nw_value' => isset($_POST['email']) ? pSQL($_POST['email']) : false, 'nw_error' => true, 'action' => $_POST['action']) ); } else if ($this->valid) { $this->smarty->assign(array('color' => 'green', 'msg' => $this->valid, 'nw_error' => false) ); } } $this->smarty->assign('this_path', $this->_path); } I've changed the way to asign values to $this->context->smarty->assign and then, for checking if the user has been registered just now, I look if msg value has been setted. That's my final code: private function _prepareHook($params) { $variable = $this->context->smarty->getTemplateVars('msg'); if (Tools::isSubmit('submitNewsletter') && !isset($variable)) { $this->newsletterRegistration(); if ($this->error) { $this->context->smarty->assign(array('color' => 'red', 'msg' => $this->error, 'nw_value' => isset($_POST['email']) ? pSQL($_POST['email']) : false, 'nw_error' => true, 'action' => $_POST['action']) ); } else if ($this->valid) { $this->context->smarty->assign(array('color' => 'green', 'msg' => $this->valid, 'nw_error' => false) ); } } $this->context->smarty->assign('this_path', $this->_path); } If I've done something really wrong, I'll be glad if one of the experts can tell it. Otherwise I hope this helps to others. Link to comment Share on other sites More sharing options...
gentzy Posted July 11, 2014 Share Posted July 11, 2014 Had this same issue. Didn't have to go through the stress of doing serious modification. All i did was to unhook the block newsletter module from the footer of my page. And that was it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now