Jump to content
xt:Commerce Community Forum

cleverreach Geburtsdatum automatisch übergeben


konair

Recommended Posts

Hallo,

wie ist es möglich, dass bei Newsletter-Anmeldung auch direkt das Geburtsdatum mit übergeben wird?

Es sollte doch in dieser Datei zu ändern sein?

class cleverreach{

function exportOrders($limit=0) {
global $db,$store_handler;
if(XT_CLEVERREACH_API_KEY != "" && XT_CLEVERREACH_LIST_ID != ""){
$crapi = cleverreach::api();

$rs = $db->Execute("SELECT * FROM ".TABLE_CUSTOMERS." as c
left join ".TABLE_CUSTOMERS_ADDRESSES." as ca on c.customers_id = ca.customers_id where c.shop_id =".$store_handler->shop_id." limit ".$limit.", 50");
$users = $rs->getArray();

$count_users = 0;
$count_orders = 0;
$userData = array();
$orderData = array();
foreach($users as $u){

//cleverreach::syncCRCustomer($this->make_safe($u["customers_email_address"]));

$userData_pointer = &$userData[];

if($u["customers_gender"] == "m"){
$salutation = "Herr";
}elseif($u["customers_gender"] == "f"){
$salutation = "Frau";
}else{
$salutation = "";
}
$userData_pointer = array(
'email' => $this->make_safe($u["customers_email_address"]),
'registered' => $this->make_safe(strtotime($u["date_added"])),
'activated' => $this->make_safe(strtotime($u["date_added"])),
'source' => $this->make_safe('VEYTON'),
'attributes' => array(
0 => array("key" => "salutation", "value" => $this->make_safe($salutation)),
1 => array("key" => "firstname", "value" => $this->make_safe($u["customers_firstname"])),
2 => array("key" => "lastname", "value" => $this->make_safe($u["customers_lastname"])),
3 => array("key" => "street", "value" => $this->make_safe($u["customers_street_address"])),
4 => array("key" => "zip", "value" => $this->make_safe($u["customers_postcode"])),
5 => array("key" => "city", "value" => $this->make_safe($u["customers_city"])),
6 => array("key" => "country", "value" => $this->make_safe($u["customers_country_code"])),
7 => array("key" => "company", "value" => $this->make_safe($u["customers_company"])),
8 => array('key' => 'shop_id', 'value' => $u["shop_id"]),
9 => array('key' => 'newsletter', 'value' => $u["cr_newsletter"])));

$rs_order = $db->Execute("select * from ".TABLE_ORDERS." as o
left join ".TABLE_ORDERS_PRODUCTS." as op on o.orders_id = op.orders_id where o.customers_id = '".$u["customers_id"]."'");

$orders = $rs_order->getArray();
foreach($orders as $o){
$orderData_pointer = &$orderData[];
$orderData_pointer["order_id"] = $o["orders_id"];
$orderData_pointer["product"] = $o["products_name"];
$orderData_pointer["product_id"] = $o["products_id"];
$orderData_pointer["price"] = $o["products_price"];
$orderData_pointer["amount"] = (integer)$o["products_quantity"];
$orderData_pointer["purchase_date"] = strtotime($o["date_purchased"]);
$orderData_pointer["source"] = "Veyton Order";
}
$userData_pointer["orders"] = $orderData;
}

$result_u = $crapi->receiverAddBatch(XT_CLEVERREACH_API_KEY, XT_CLEVERREACH_LIST_ID, $userData);
if($result_u->status == "SUCCESS")
echo "update_import();";
}
}

public function setSubscriber($email, $state){
global $db;
$rs = $db->Execute("UPDATE ".TABLE_CUSTOMERS." SET cr_newsletter = ".$state." where customers_email_address = '".$email."'");
}

public function isSubscriber($email){
global $db;
$rs = $db->Execute("SELECT cr_newsletter FROM ".TABLE_CUSTOMERS." where customers_email_address = '".$email."'");

$result = $rs->getArray();
return $result["cr_newsletter"];
}

public function isCRSubscriber($email){
$client = cleverreach::api();

$result = $client->receiverGetByEmail(XT_CLEVERREACH_API_KEY, XT_CLEVERREACH_LIST_ID, $email);

if($result->status == "SUCCESS"){
if(!$result->data->deactivated){
return 1;
}
return 0;
}
return -1;
}

public function syncCRCustomer($email){
if($email)
switch(cleverreach::isCRSubscriber($email)){
case 0:{
cleverreach::setSubscriber($email, 0);
}break;
case 1:{
cleverreach::setSubscriber($email, 1);
}break;
}
}

function make_safe($in){
//$in = utf8_encode($in);
$in = str_replace("&", "&",$in);
$in = str_replace("&", "& ",$in);
$in = str_replace("<", "<",$in);
$in = str_replace(">", ">",$in);
return $in;
}

function _displayNLcheckBox($data) {
global $xtPlugin, $xtLink, $db;

$tpl = 'newsletter_checkbox.html';
$tmp_data = '';
$template = new Template();
$template->getTemplatePath($tpl, 'xt_cleverreach', '', 'plugin');

$tmp_data = $template->getTemplate('xt_cleverreach_smarty', $tpl, $tpl_data);
return $tmp_data;

}

function api(){
$return = false;

try {
$return = new SoapClient(XT_CLEVERREACH_API_URL);
} catch (Exception $e) {

}

return $return;
}

function prepare_list($apiKey, $listID){
if($apiKey && $listID){
try {

$client = cleverreach::api();
$return = $client->groupGetDetails($apiKey, $listID);
if($return->status == "SUCCESS"){
$fields = array("firstname" => "firstname",
"lastname" => "lastname",
"street" => "street",
"zip" => "zip",
"city" => "city",
"country" => "country",
"salutation" => "salutation",
"title" => "title",
"company" => "company",
"newsletter" => "newsletter",
"group_id" => "group_id",
"group_name" => "group_name",
"gender" => "gender",
"store" => "store");
foreach($return->data->attributes as $a){
if(in_array($a->key, $fields)){
unset($fields[$a->key]);
}
}
foreach($fields as $f){
$return = $client->groupAttributeAdd($apiKey, $listID, $f, "text", "");
}
}

//filter anlegen

$rule[0] = array("field" => "newsletter",
"operator" => "AND",
"logic" => "EQ",
"condition" => "1");

cleverreach::api()->groupFilterAdd($apiKey, $listID, "Veyton_newsletter", $rule);

$rule[0] = array("field" => "purchase_date",
"operator" => "AND",
"logic" => "NOTISNULL",
"condition" => "");

cleverreach::api()->groupFilterAdd($apiKey, $listID, "Veyton_customers", $rule);
} catch (Exception $e) {
}
}
}
}
?>
[/PHP]

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...