Jump to content

newsletter


Recommended Posts

HI ALL

Does anybody use the newsletter module. if so can you show/tell me the settings you use. People are unable to register for a newsletter on my site IF they have not registered as a customer.

If they have registered as a customer there seems no need to have a newsletter box.

www.bordersbedsandshrubberies.co.uk

thanks all

hippooflove

Link to comment
Share on other sites

Hiya
Don't think it's to do with BO settings.
This is some of the code from my blocknewsletter.php. It's the bit that refers to the newletter registrations.

private function newsletterRegistration()
    {
        if (!Validate::isEmail(pSQL($_POST['email'])))
           return $this->error = $this->l('Invalid e-mail address');
        /* Unsubscription */
        elseif ($_POST['action'] == '1')
        {
             $registerStatus = $this->isNewsletterRegistered(pSQL($_POST['email']));
             if ($registerStatus < 1)
                 return $this->error = $this->l('E-mail address not registered');
             /* If the user ins't a customer */
             elseif ($registerStatus == 1)
             {
                 if (!Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'newsletter WHERE `email` = \''.pSQL($_POST['email']).'\''))
                     return $this->error = $this->l('Error during unsubscription');
                 return $this->valid = $this->l('Unsubscription successful');
             }
             /* If the user is a customer */
             elseif ($registerStatus == 2)
            {
                 if (!Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'customer SET `newsletter` = 0 WHERE `email` = \''.pSQL($_POST['email']).'\''))
                     return $this->error = $this->l('Error during unsubscription');
                 return $this->valid = $this->l('Unsubscription successful');
             }
       }
        /* Subscription */
        elseif ($_POST['action'] == '0')
        {
             $registerStatus = $this->isNewsletterRegistered(pSQL($_POST['email']));
           if ($registerStatus > 0)
               return $this->error = $this->l('E-mail address already registered');
           /* If the user ins't a customer */
           elseif ($registerStatus == -1)
           {
               global $cookie;
               if (!Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'newsletter VALUES (\'\', \''.pSQL($_POST['email']).'\', NOW(), \''.pSQL($_SERVER['REMOTE_ADDR']).'\', 
                   (SELECT c.http_referer FROM '._DB_PREFIX_.'connections c WHERE c.id_guest = '.intval($cookie->id_guest).' ORDER BY c.date_add DESC LIMIT 1))'))
                   return $this->error = $this->l('Error during subscription');
               $this->sendVoucher(pSQL($_POST['email']));
               return $this->valid = $this->l('Subscription successful');
           }
           /* If the user is a customer */
           elseif ($registerStatus == 0)
           {
                if (!Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'customer SET `newsletter` = 1, newsletter_date_add = NOW(), `ip_registration_newsletter` = \''.pSQL($_SERVER['REMOTE_ADDR']).'\' WHERE `email` = \''.pSQL($_POST['email']).'\''))
                     return $this->error = $this->l('Error during subscription');
               $this->sendVoucher(pSQL($_POST['email']));
               return $this->valid = $this->l('Subscription successful');
           }
       }
    }




Check it against yours and see what the difference is, it works fine on my site.

:)

Link to comment
Share on other sites

thanks for taking the time to answer Chrissie.

I have looked at my code and it does look the same as yours. I will check it over again a few more times though. then its back to the drawing board.

can I just check with you that people can get your newsletter even if they have not registered as a customer.

cheers

Hippooflove

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
i had tried....if not register as customer their email will not included in mailing list :(

anyone know how to fix this ?


I DO!!! I have been looking for this too and have found the answer in the Czech forum, using google translate. It turns out that the newsletter table never got created in the database, which is why I could only register with customers that already existed in my customer database. It had nowhere to put the customers that had only used the subscription module and thus the error.

Here's what you need to do:

1. Go to the Prestashop backend and uninstall ALL Newsletter applications, I had three: Newsletterv2.0, Newsletter block v1.4, Newsletter v1.0. UNISTALL them by clicking the checkboxes next to them and do them all at once in a batch.

2. Next, install only: Newsletterv2.0 & Newsletter block v1.4 (NOT Newsletter v1.0) You may or may not get an error, doesn't matter.

3. Next go to your database admin tool. I use PHPMyAdmin where I click on my shop's database and then SQL at the top

4. Enter the following query via SQL, make sure you change the YOURDATABASENAME in the below code to the full name of your database:

CREATE TABLE `YOURDATABASENAME`.`ps_newsletter` (
     `id` INT( 6 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
     `email` VARCHAR( 255 ) NOT NULL ,
     `newsletter_date_add` DATETIME NULL ,
     `ip_registration_newsletter` VARCHAR( 15 ) NOT NULL ,
     `http_referer` VARCHAR( 255 ) NULL
) ENGINE = MYISAM default CHARSET=utf8



5. ???????

6. PROFIT!!!!

I can confirm this worked for me on the newest prestashop! Now to export the customers, you go to the Modules in Backend and click configure on the Newsletterv2.0 module.

The "Export Newsletter Subscribers" option will only export the customers in the table you just created. The "Export customers" section will only export data from the customers table, no matter what you chose, it will omit the newsletter table. All you need to do if combine the two tables and you have your subscriber base!

Will accept beer as donations.

Link to comment
Share on other sites

  • 4 weeks later...

I've tried all of the above and I'm still not getting my subscribers added to the database.

The database exists but when I try to subscribe it doesn't add the details to the database!?

I can't work this one out at all. When I go to Newsletter v2.0 and export the CSV it says there is nothing to export. The customer database is fine and working but the newsletter block one is not.

Link to comment
Share on other sites

  • 2 weeks later...
  • 5 months later...

Hi, I was wondering if someone cracked this problem. I also get the same message, saying that I have nothing in my Newsletter Block to export although I have filled in email addresses. The thing is I tested it when I am not logged in as a customer. Surely there must be a remedy for someone who does not want to register to subscribe to the newsletter.

The DB table is there, but when I view it in PHPMyAdmin, nothing has been inserted, is there a fix for non customers to subscribe?

Any help would be appreciated.

Link to comment
Share on other sites

  • 1 month later...
×
×
  • Create New...