<?php
/*
MailBeez Automatic Trigger Email Campaigns
http://www.mailbeez.com
Copyright (c) 2010 MailBeez
inspired and in parts based on
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
// make path work from admin
require_once(DIR_FS_CATALOG. 'mailhive/common/classes/mailbeez.php');
// could be in language-file
// just easier to define it in the mailbee
define('MAILBEEZ_TRUSTPILOT_TEXT_TITLE', 'Trustpilot buyers rating trigger');
//
// Are you a Shop-Hoster, Agency or Consultant working with osCommerce, Zen Cart, CRE Loaded, xtCommerce or similar system?
//
// Do you want to become Trustpilot affiliate and receive an attractive commission for new Trustpilot Partners?
// (A Trustpilot Partner is a shop using Trustpilot to collect buyers ratings)
//
// please contact:
//
// affiliate@mailbeez.com
//
//
//
$promotion_url = 'http://www.mailbeez.com/trustpilot';
if ( !defined('MAILBEEZ_TRUSTPILOT_TRIGGER_EMAIL') || (defined('MAILBEEZ_TRUSTPILOT_TRIGGER_EMAIL') && MAILBEEZ_TRUSTPILOT_TRIGGER_EMAIL == 'yourid@trustpilotservice.com') ) {
$promotion = '<link rel="stylesheet" type="text/css" href="' . $module_directory_ws . 'trustpilot/flags.css" ><div align="center" style="border: 1px solid #909090; "><div style="background-color: #232323; color: #c0c0c0";><b>What is your Reputation?</b><br>
Click on the flag of your country <br>
to visit your local Trustpilot-site:<br>
<div style="margin:auto; width: 220px; background-color: #232323; padding-top: 2px; margin-top: 5px;" >
<a class="ceebox" href="http://www.trustpilot.com"><span class="americanflag"></span></a>
<a class="ceebox" href="http://www.trustpilot.co.uk"><span class="britishflag"></span></a>
<a class="ceebox" href="http://www.trustpilot.de"><span class="germanflag"></span></a>
<a class="ceebox" href="http://www.trustpilot.at"><span class="austrianflag"></span></a>
<a class="ceebox" href="http://www.trustpilot.fr"><span class="frenchflag"></span></a>
<a class="ceebox" href="http://www.trustpilot.be"><span class="belgianflag"></span></a>
<a class="ceebox" href="http://www.trustpilot.nl"><span class="dutchflag"></span></a>
<a class="ceebox" href="http://www.trustpilot.it"><span class="italianflag"></span></a>
<a class="ceebox" href="http://www.trustpilot.ru"><span class="russianflag"></span></a>
<a class="ceebox" href="http://www.trustpilot.ro"><span class="romanianflag"></span></a>
<a class="ceebox" href="http://www.trustpilot.se"><span class="swedishflag"></span></a>
<a class="ceebox" href="http://www.trustpilot.dk"><span class="danishflag"></span></a><br clear="left">
</div>
<a href="' . $promotion_url . '" target="_blank">' . mh_image($module_directory_ws . 'trustpilot/trustpilot.png', '', '', '', 'vspace="5"') . '</a>
</div>
' . mh_image($module_directory_ws . 'trustpilot/line.png', '', '', '', 'width="100%" height="11"') . '
<div style="background-color: #ffffff";>
<div style="padding: 7px;">
<b>MailBeez is a Trustpilot-Partner</b><br>
<a href="' . $promotion_url . '" target="_blank"><u>Register here for<br>
a free month and up to <b>50% discount</b></u><br>
' . mh_image($module_directory_ws . 'trustpilot/promotion.png', '', '', '', 'vspace="10"') . '</a><br>
with registration through this link<br>
you support the development of MailBeez
</div>
</div>
</div>
<div style="border: 1px solid red; padding:5px; text-align: left; background-color: #F7F9FA;">
<ol style="padding: 10px; padding-left:30px;padding-right:30px;margin: 0px;">
<li>Install this MailBeez Module<br>
<li><a href="' . $promotion_url . '" target="_blank"><u>Register for a Trustpilot Partnership<br>
with up to 50% discount</u></a><br>
<li>Enter your personal Trustpilot Email
</ol>
Now you are ready to collect buyers ratings from your customers and display them on your site - find the widget on your Trustpilot Site
</div>
<br>(this box will disappear after you entered your trustpilot email address)';
} else {
$promotion = '';
}
define('MAILBEEZ_TRUSTPILOT_TEXT_DESCRIPTION', '<b>Turn Visitors into Customers.</b><br>
<br>
If you do establish trust, you gain a powerful competitive advantage. According to some estimates, trust is 10 times more important to consumers than cost.<br>
<br>
That\'s why Buyers Rating are important to increase your conversion rate. <br>
<br>
<blockquote><a href="http://download.trustpilot.dk/B2B/TP%20Automatic%20Feedback%20Service.The%20Guide_EN.pdf"><b>Download TP Feedback Service Guide (EN).PDF</b></a></blockquote>
This MailBeez Module generates up to 100x more ratings on Trustpilot. It sends a trigger email to Trustpilot.<br>
Trustpilot will then ask your customer by email to rate your service with a personalized no-sign-on rating link. <br>
Find your personal Trustpilot email address in your Trustpilot b2b site.<br>
<br>' . $promotion);
class trustpilot extends mailbeez {
// class constructor
function trustpilot() {
// call constructor
mailbeez::mailbeez();
// set some stuff:
$this->code = 'trustpilot';
$this->module = 'trustpilot'; // same as folder name
$this->version = '1.5'; // float value
$this->required_mb_version = 1.4; // required mailbeez version
$this->iteration = 1;
$this->title = MAILBEEZ_TRUSTPILOT_TEXT_TITLE;
$this->description = MAILBEEZ_TRUSTPILOT_TEXT_DESCRIPTION;
$this->sort_order = MAILBEEZ_TRUSTPILOT_SORT_ORDER;
$this->enabled = ((MAILBEEZ_TRUSTPILOT_STATUS == 'True') ? true : false);
$this->googleanalytics_enabled = 'False';
$this->googleanalytics_rewrite_mode = 'False';
$this->sender = MAILBEEZ_TRUSTPILOT_SENDER;
$this->sender_name = MAILBEEZ_TRUSTPILOT_SENDER_NAME;
$this->status_key = 'MAILBEEZ_TRUSTPILOT_STATUS';
//$this->icon = 'icon.png';
$this->documentation_key = $this->module; // leave empty if no documentation available
// $this->documentation_root = 'http:://yoursite.com/' // modify documentation root if necessary
$this->htmlBodyTemplateResource = 'body_html.tpl'; // located in folder of this module
$this->txtBodyTemplateResource = 'body_txt.tpl'; // located in folder of this module
$this->subjectTemplateResource = 'subject.tpl'; // located in folder of this module
$this->audience = array();
$this->additionalFields = array('customers_id' => '007', 'customers_email_address' => 'customer@mail.com', 'order_id' => '123456', 'order_date' => '12.12.2000', 'status_date' => '31.12.2000', 'language' => 'en-GB');
// list of additional fields to show in listing with testvalues used for Test-Mail
}
// class methods
function getAudience() {
$status = MAILBEEZ_TRUSTPILOT_ORDER_STATUS_ID;
// early check to avoid processing when email was already sent
$mb_chk = new mailbeez_mailer($this);
// MAILBEEZ_TRUSTPILOT_PASSED_DAYS
// MAILBEEZ_TRUSTPILOT_PASSED_DAYS_SKIP
$date_skip = $this->dbdate(MAILBEEZ_TRUSTPILOT_PASSED_DAYS_SKIP);
$date_passed = $this->dbdate(MAILBEEZ_TRUSTPILOT_PASSED_DAYS);
$query_raw = "select c.customers_firstname, c.customers_lastname, o.orders_id, o.customers_name,
o.customers_id, o.customers_email_address, o.date_purchased, s.date_added as status_date
from " . TABLE_ORDERS . " o
left join " . TABLE_CUSTOMERS . " c
on (o.customers_id = c.customers_id)
left join " . TABLE_ORDERS_STATUS_HISTORY . " s
on (o.orders_id = s.orders_id)
where o.orders_status = s.orders_status_id
and s.orders_status_id = '" . (int)$status . "'
and s.date_added <= '" . $date_passed . "'
and s.date_added > '" . $date_skip . "'
order by o.orders_id DESC";
$query = mh_db_query($query_raw);
while ($item = mh_db_fetch_array($query)) {
// mandatory fields:
// - firstname
// - lastname
// - email_address
// - customers-id -> block
// other keys are replaced while sending: $<key>
// early check to avoid processing when email was already sent
$chk_result = $mb_chk->check($this->module, $this->iteration, $item['customers_id'],$item['orders_id']);
if ($chk_result != false) {
// this iteration was already sent -> skip
continue;
}
$this->audience[$item['customers_id']] = array('firstname' => $item['customers_firstname'],
'lastname' => $item['customers_lastname'],
'customers_email_address' => $item['customers_email_address'],
'email_address' => MAILBEEZ_TRUSTPILOT_TRIGGER_EMAIL,
'customers_id' => $item['customers_id'],
'order_id' => $item['orders_id'],
'order_date' => mh_date_short($item['date_purchased']),
'status_date' => mh_date_short($item['status_date']),
'language' => MAILBEEZ_TRUSTPILOT_LANGUAGE
);
}
return $this->audience;
}
// installation methods
function keys() {
return array('MAILBEEZ_TRUSTPILOT_STATUS', 'MAILBEEZ_TRUSTPILOT_ORDER_STATUS_ID', 'MAILBEEZ_TRUSTPILOT_PASSED_DAYS', 'MAILBEEZ_TRUSTPILOT_PASSED_DAYS_SKIP', 'MAILBEEZ_TRUSTPILOT_SENDER', 'MAILBEEZ_TRUSTPILOT_SENDER_NAME', 'MAILBEEZ_TRUSTPILOT_TRIGGER_EMAIL', 'MAILBEEZ_TRUSTPILOT_SORT_ORDER', 'MAILBEEZ_TRUSTPILOT_LANGUAGE');
}
function install() {
mh_insert_config_value(array('configuration_title' => 'Send trustpilot trigger email',
'configuration_key' => 'MAILBEEZ_TRUSTPILOT_STATUS',
'configuration_value' => 'False',
'configuration_description' => 'Do you want to send trustpilot trigger email to ask your customer for a review?',
'set_function' => 'mh_cfg_select_option(array(\'True\', \'False\'), '
));
mh_insert_config_value(array('configuration_title' => 'Set Order Status',
'configuration_key' => 'MAILBEEZ_TRUSTPILOT_ORDER_STATUS_ID',
'configuration_value' => '3',
'configuration_description' => 'Set the status of orders to send trigger',
'set_function' => 'mh_cfg_pull_down_order_statuses(',
'use_function' => 'mh_get_order_status_name'
));
mh_insert_config_value(array('configuration_title' => 'your trustpilot email address',
'configuration_key' => 'MAILBEEZ_TRUSTPILOT_TRIGGER_EMAIL',
'configuration_value' => 'yourid@trustpilotservice.com',
'configuration_description' => 'your unique trustpilot email address',
'set_function' => ''
));
mh_insert_config_value(array('configuration_title' => 'Set days passed',
'configuration_key' => 'MAILBEEZ_TRUSTPILOT_PASSED_DAYS',
'configuration_value' => '5',
'configuration_description' => 'number of days to wait befor sending the emails',
'set_function' => ''
));
mh_insert_config_value(array('configuration_title' => 'Set days to skip after',
'configuration_key' => 'MAILBEEZ_TRUSTPILOT_PASSED_DAYS_SKIP',
'configuration_value' => '10',
'configuration_description' => 'number of days after which do skip the reminder',
'set_function' => ''
));
mh_insert_config_value(array('configuration_title' => 'sender email',
'configuration_key' => 'MAILBEEZ_TRUSTPILOT_SENDER',
'configuration_value' => STORE_OWNER_EMAIL_ADDRESS,
'configuration_description' => 'sender email',
'set_function' => ''
));
mh_insert_config_value(array('configuration_title' => 'sender name',
'configuration_key' => 'MAILBEEZ_TRUSTPILOT_SENDER_NAME',
'configuration_value' => STORE_NAME,
'configuration_description' => 'sender email',
'set_function' => ''
));
mh_insert_config_value(array('configuration_title' => 'Default Customer Language',
'configuration_key' => 'MAILBEEZ_TRUSTPILOT_LANGUAGE',
'configuration_value' => 'en-GB',
'configuration_description' => 'Please choose the language Trustpilot will ask your Customers.',
'set_function' => 'mh_cfg_select_option(array(\'da-DK\', \'de-DE\', \'en-GB\', \'es-ES\', \'fr-FR\', \'it-IT\', \'nb-NO\', \'nl-NL\', \'ro-RO\', \'ru-RU\', \'sv-SE\', \'automatic (see documentation)\'), '
));
mh_insert_config_value(array('configuration_title' => 'Sort order of display.',
'configuration_key' => 'MAILBEEZ_TRUSTPILOT_SORT_ORDER',
'configuration_value' => '10',
'configuration_description' => 'Sort order of display. Lowest is displayed first.',
'set_function' => ''
));
}
}
?>