Jump to content
Latest News: (loading..)

Search the Community

Showing results for tags 'newsletter'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News and Announcements
    • News and Announcements
    • Partner Announcements
    • Ambassadors
  • Commercial Support
    • Developer Feedback
  • osCommerce Online Merchant v2.x
    • General Support
    • Installation and Configuration
    • Upgrading from Earlier Versions (v2.x to v2.x)
    • Add-Ons
    • Tips and Tricks
    • Security
  • Development
    • osCommerce Online Merchant v2.4
    • osCommerce Online Merchant Community Bootstrap Edition
    • osCommerce Online Merchant v3.x
    • Development Proposals
  • General
    • OSCOMMERCE.TV
    • Next Steps / Optimizations / Marketing
    • Live Shop Reviews
    • E-Commerce Laws
    • General Discussions
    • PHP / SQL / Web Design
  • oscBooks and oscTemplates's Announcements
  • PayPal's Announcements
  • Sage Pay's Announcements
  • Solomono - new level osCommerce templates's Announcements
  • German Community's OSCOM v2.x
  • German Community's Allgemein
  • German Community's OSCOM v3.x

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Real Name


Location


Interests


Website


Skype

Found 3 results

  1. Hi everybody, Mailchimp is a good way going forward but the latest api v3.0 is not figured out for oscommerce. I have done it for my business but no more time to build an app at this moment. Setup Enviroment Download from github the latest api: https://github.com/drewm/mailchimp-api Upload MailChimp.php and Batch.php from zip archive into YOUR_CATALOG/ext/api/mailchimp3/ folder. Install ht_mailchimp_360.php header tag for constants or edit by directly list_id and api in the code below. Create test.php file with build in class and test script codes for oscommerce enviroment in YOUR_CATALOG/ext/api/mailchimp3/ folder. <?php // see result in Mailchimp account API menu or use mailchimp class file logger // https://us2.admin.mailchimp.com/account/api/ chdir('../../../'); // ini_set('display_errors', 1); // Prepaires // do oscommerce setup require('ext/api/mailchimp3/MailChimp.php'); use DrewM\MailChimp; require('includes/application_top.php'); class OSCOM_MailChimp { private $_api; private $list_id; private $logfile = 'mailchimp.log'; private $logger_enabled = true; public function __construct() { $api_key = MODULE_HEADER_TAGS_MAILCHIMP_360_API_KEY; $this->list_id = MAILCHIMP_LIST_ID; $this->_api = new DrewM\MailChimp\MailChimp($api_key); } public function subscribe($email, $merge_fields = array()) { $subscriber_hash = $this->_api->subscriberHash($email); $this->_api->get("lists/" . $this->list_id . "/members/" . $subscriber_hash . ""); $response = $this->_api->getLastResponse(); if ($response['headers']['http_code'] == 404) { // add new user $result = $this->_api->post("lists/" . $this->list_id . "/members", [ 'email_address' => $email, 'status' => 'subscribed', 'merge_fields' => $merge_fields ]); } else { // modify user $this->_api->patch("lists/" . $this->list_id . "/members/" . $subscriber_hash . "", [ 'status' => 'subscribed' ]); } if ($this->logger_enabled) { $this->logger($this->_api->getLastError()); $this->logger($result); $this->logger($this->_api->getLastResponse()); $this->logger($this->_api->getLastRequest()); } } public function unsubscribe($email) { $subscriber_hash = $this->_api->subscriberHash($email); $this->_api->get("lists/" . $this->list_id . "/members/" . $subscriber_hash . ""); $response = $this->_api->getLastResponse(); if ($response['headers']['http_code'] == 200) { // modify user $this->_api->patch("lists/" . $this->list_id . "/members/" . $subscriber_hash . "", [ 'status' => 'unsubscribed' ]); if ($this->logger_enabled) { $this->logger($this->_api->getLastError()); $this->logger($result); $this->logger($this->_api->getLastResponse()); $this->logger($this->_api->getLastRequest()); } } } public function getListId() { return $this->list_id; } public function setListId($list_id) { $this->list_id = $list_id; } private function logger($msg) { file_put_contents($this->logfile, date("Y-m-d H:i:s") . " | " . print_r($msg, true) . "\n", FILE_APPEND); } } /* EXAMPLE CODE */ // use ?up (subscribe) or ?down (unsubscribe) params in URL request for testing $M = new OSCOM_MailChimp(); $merge_array = array('FNAME'=> 'Elek', 'LNAME'=> 'Test'); if (isset($_GET['up'])) { $M->subscribe('test.elek@freemail.hu', $merge_array); } elseif (isset($_GET['down'])) { $M->unsubscribe('test.elek@freemail.hu'); } require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Usage: http://YOUR_CATALOG/ext/api/mailchimp3/ test.php?up or http://YOUR_CATALOG/ext/api/mailchimp3/ test.php?down Webhook unsubscribe example codes for oscommerce: <?php /* Configuring Webhooks Webhooks are configured from your MailChimp account. Here are the basic steps: Log in to your MailChimp account Navigate to your Lists Click View Lists on the list you want to configure Click the List Tools menu option at the top Click Webhooks Configuration is simple: Enter a valid url for us to contact, then select the events and event sources (see below for descriptions) you want to have sent to you. */ chdir('../../../'); require('includes/application_top.php'); if (isset($_POST['type'])) { $customers_email = (isset($_POST['data']['email']) ? tep_db_prepare_input($_POST['data']['email']) : Null); if (tep_validate_email($customers_email)) { $check_query = tep_db_query("select customers_id from customers where customers_email_address = '" . tep_db_input($customers_email) . "'"); if (tep_db_num_rows($check_query)) { $customers = tep_db_fetch_array($check_query); if ($_POST['type'] == 'subscribe') { tep_db_query("update customers set customers_newsletter = '1' where customers_email_address = '" . tep_db_input($customers_email) . "'"); } elseif ($_POST['type'] == 'unsubscribe') { tep_db_query("update customers set customers_newsletter = '0' where customers_email_address = '" . tep_db_input($customers_email) . "'"); } tep_db_query("update customers_info set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customers['customers_id'] . "'"); } } } $my_key = 'your_secret_code!'; wh_log('==================[ Incoming Request ]=================='); wh_log("Full _REQUEST dump:\n".print_r($_REQUEST,true)); if ( !isset($_GET['key']) ){ wh_log('No security key specified, ignoring request'); } elseif ($_GET['key'] != $my_key) { wh_log('Security key specified, but not correct:'); wh_log("\t".'Wanted: "'.$my_key.'", but received "'.$_GET['key'].'"'); } else { //process the request wh_log('Processing a "'.$_POST['type'].'" request...'); switch($_POST['type']){ case 'subscribe' : subscribe($_POST['data']); break; case 'unsubscribe': unsubscribe($_POST['data']); break; case 'cleaned' : cleaned($_POST['data']); break; case 'upemail' : upemail($_POST['data']); break; case 'profile' : profile($_POST['data']); break; default: wh_log('Request type "'.$_POST['type'].'" unknown, ignoring.'); } } wh_log('Finished processing request.'); /*********************************************** Helper Functions ***********************************************/ function wh_log($msg){ $logfile = 'webhook.log'; file_put_contents($logfile,date("Y-m-d H:i:s")." | ".$msg."\n",FILE_APPEND); } function subscribe($data){ wh_log($data['email'] . ' just subscribed!'); } function unsubscribe($data){ wh_log($data['email'] . ' just unsubscribed!'); } function cleaned($data){ wh_log($data['email'] . ' was cleaned from your list!'); } function upemail($data){ wh_log($data['old_email'] . ' changed their email address to '. $data['new_email']. '!'); } function profile($data){ wh_log($data['email'] . ' updated their profile!'); } require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Hooks examle or direct oscommerce snipet code in create_account.php: //Mailchimp if (MODULE_HEADER_TAGS_MAILCHIMP_360_STATUS == 'True') { if ($newsletter == '1') { require_once('includes/classes/OSCOM_mailchimp.php'); $M = new OSCOM_MailChimp(); $merge_array = array('FNAME'=> $firstname, 'LNAME'=> $lastname ); $M->subscribe($email_address, $merge_array); } } Note: OSCOM_mailchimp.php contains only the same class code as you use in test.php use your own risk. Have a good work!
  2. A new Topic for the Contribution Newsletters & Subscribers for Osc 2.3 I still like this Contrib, but it still buggy. I hope some people with more programming experience will take a look at this Contrib and make it a little more stable.
  3. Hey everyone! I'm looking for a newsletter add-on that allows customers to sign up separately from the account creation page. The ones that I have found so far either have issues in the sql files for me, or they are in the wrong languages. So, please post any 2.3 Newsletter add-ons that you know of for me to try! Thank you so much! -Jennifer M.
×