Contributions
PHPList for OsCommerce
This is a contribution I found on the phplist forums.
Basically, it changes the newsletter options built-in to OsCommerce, with the PHPList database instead.
NOTE: I did not write this contribution. I have simply put it on OsCommerce for everyone to use.
I am going to change this so that on my Contact Us page, it gives the option to subscribe to the newsletter also.
Installation instructions are enclosed.
View the support thread here: http://forums.oscommerce.com/index.php?showtopic=191317
Expand All / Collapse All
This is just a script that will import any customer that has signed up for a newsletter into the phpList database. A word of warning - i've added in a firstname and lastname attribute into phpList. If you haven't done this then please modify the script to leave this out if you have any problems.
You can run this script as many times as you like, but i would recommend only the once, as it will update all users in the phplist database and add them back into the list (if they have unsubscribed through phplist)
Also, i added in a little bit of verbose so you can track a bit of what is going on.
Usage: upload script to site, and then run script through browser. Done.
note: this script is based on the code from this contribution - main credit goes there - i just coded a bit round the fringes
The 'Newsletter' field in the customers list in admin/Customers.php still reads from the old database.
In admin/customers.php Find:
while ($customers = tep_db_fetch_array($customers_query)) {
And add directly below it:
// PHPlist PHPlist Newsletter add-on
require(DIR_WS_INCLUDES . '/phplist_define.php'); //get the phplist specifics
$existing_email_query = tep_db_query("select id, email, foreignkey from " . PHPLIST_DB . "" . PHPLIST_TABLE_PREFIX . "user_user where email = '" . $customers['customers_email_address'] . "'"); //check for existing by email address
$existing_user_query = tep_db_query("select id, foreignkey, email from " . PHPLIST_DB . "" . PHPLIST_TABLE_PREFIX . "user_user where foreignkey = " . $customers['customers_id'] . ""); //check for existing by phplist userid in case they subscribed using another method.
$existing_email = tep_db_fetch_array($existing_email_query);
$existing_user = tep_db_fetch_array($existing_user_query);
if (tep_db_num_rows($existing_user_query) > 0) //check for user subscription
$newsletter_query = tep_db_query("select userid from " . PHPLIST_DB . "" . PHPLIST_TABLE_PREFIX . "listuser where listid = " . PHPLIST_LISTNO . " and userid = " . $existing_user['id'] . "");
else
$newsletter_query = tep_db_query("select userid from " . PHPLIST_DB . "" . PHPLIST_TABLE_PREFIX . "listuser," . PHPLIST_DB . "" . PHPLIST_TABLE_PREFIX . "user_user where listid = " . PHPLIST_LISTNO . " and userid = id and email = '" . $customers['customers_email_address'] . "'");
$customers['customers_newsletter'] = ((tep_db_num_rows($newsletter_query) < 1) ? '0' : '1');
// End PHPlist Newsletter add-on
Attached is the latest version with this fix added.
Known bugs:
if you don't have a surname attribute in PHPList, the included config file says just to leave the field blank. The script doesn't seem to check for this and caused me errors. I had to comment out lines in create_account.php which used the surname value when accessing the database.
This has not been done in the attached version, it's up to you...
Section 'Requirements' added to the txt-file.
Thomas
This is a contribution I found on the phplist forums.
Basically, it changes the newsletter options built-in to OsCommerce, with the PHPList database instead.
NOTE: I did not write this contribution. I have simply put it on OsCommerce for everyone to use.
I am going to change this so that on my Contact Us page, it gives the option to subscribe to the newsletter also.
Installation instructions are enclosed.
View the support thread here: http://forums.oscommerce.com/index.php?showtopic=191317
Note: Contributions are used at own risk.