Forums / All Other Contributions/Addons / Snap Affiliates v2.0 for v1.5.0 and later

Snap Affiliates v2.0 for v1.5.0 and later

Views: 68,399

Results 41 to 60 of 464
27 Mar 2013, 6:37 PM
#41
jeff_mash avatar

jeff_mash

Totally Zenned

Join Date:
Aug 2004
Posts:
732
Plugin Contributions:
0

Snap Affiliates v2.0 for v1.5.0 and later

UPDATE: I don't know what happened, but I deleted the cookie, tried again, and now it seems to work. The cookie looks the same to me as the one I deleted, so I don't know what could have been different. If I see any other issues though, I will bring them up here.

  • Jeff
27 Mar 2013, 6:46 PM
#42
picandnix avatar

picandnix

Totally Zenned

Join Date:
Dec 2010
Location:
UK
Posts:
1,780
Plugin Contributions:
2

Re: Snap Affiliates v2.0 for v1.5.0 and later

Jeff_Mash:

I am using v2.10. I accidentally posted in the other thread before seeing this one. I appreciate any help you (or anyone) can contribute to my problem. I'm sure it's something silly, but for the life of me, I don't know why it isn't tracking affiliate sales. I do use the Ultimate SEO add-on, but from what I have read, this newer version should work. I don't get any 404 errors or anything with custom URL's. In fact, my URLS look like this and load fine (edited out my domain, but hover over the link to see the format):

http://www.MYDOMAIN.com/store/space-trix-by-fun-inc-trick-p-15698.html&referrer=CNWR_144491364328461

But when I place an order using that link, and then when I log into my referral account, it doesn't have record of the sale.

Does your store orders area have a record of the sale though?

27 Mar 2013, 6:56 PM
#43
picandnix avatar

picandnix

Totally Zenned

Join Date:
Dec 2010
Location:
UK
Posts:
1,780
Plugin Contributions:
2

Re: Snap Affiliates v2.0 for v1.5.0 and later

Jeff_Mash:

UPDATE: I don't know what happened, but I deleted the cookie, tried again, and now it seems to work. The cookie looks the same to me as the one I deleted, so I don't know what could have been different. If I see any other issues though, I will bring them up here.

Nice one :smile:

27 Mar 2013, 7:24 PM
#44
jeff_mash avatar

jeff_mash

Totally Zenned

Join Date:
Aug 2004
Posts:
732
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

I did notice one issue though. Perhaps you could clarify if it's a bug, or something that can easily be corrected.

The way the module works is that it provides you with TWO WAYS of referring a person to the website:

  1. You can use the SITE LINK

  2. Or you can use the DEEP LINK GENERATOR

However, a cookie is only being created when our user clicks on the site link. It does NOT create the cookie of they click on the deep link generated link.

Here are the two formats of the URL:

SITE LINK FORMAT:
http://www.domain.com/store/&referrer=CNWR_144491364328461 <-----THIS WORKS. COOKIE IS CREATED

DEEP LINK FORMAT:
http://www.domain.com/store/space-trix-by-p-15698.html&referrer=CNWR_144491364328461 <---NO COOKIE CREATED

Any idea why that would be? Should the ampersand be changed to a question mark on the DEEP LINK format? Should a trailing backslash be used before it?

  • Jeff
28 Mar 2013, 12:38 AM
#45
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

Jeff_Mash:

I did notice one issue though. Perhaps you could clarify if it's a bug, or something that can easily be corrected.

The way the module works is that it provides you with TWO WAYS of referring a person to the website:

  1. You can use the SITE LINK

  2. Or you can use the DEEP LINK GENERATOR

However, a cookie is only being created when our user clicks on the site link. It does NOT create the cookie of they click on the deep link generated link.

Here are the two formats of the URL:

SITE LINK FORMAT:
http://www.domain.com/store/&referrer=CNWR_144491364328461 <-----THIS WORKS. COOKIE IS CREATED

DEEP LINK FORMAT:
http://www.domain.com/store/space-trix-by-p-15698.html&referrer=CNWR_144491364328461 <---NO COOKIE CREATED

Any idea why that would be? Should the ampersand be changed to a question mark on the DEEP LINK format? Should a trailing backslash be used before it?
Jeff, what URL rewriter are you using? There are known problems with this add-on and the various flavors of rewriters. What version of the affiliates plugin are you using?

28 Mar 2013, 5:05 PM
#46
jeff_mash avatar

jeff_mash

Totally Zenned

Join Date:
Aug 2004
Posts:
732
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

lat9:

Jeff, what URL rewriter are you using? There are known problems with this add-on and the various flavors of rewriters. What version of the affiliates plugin are you using?

I am using ULTIMATE SEO add-on, and the latest version of Snap Affiliates v2.1.0.

I believe this is the SEO add on right here:
http://www.zen-cart.com/downloads.php?do=file&id=132

  • Jeff
29 Mar 2013, 2:44 PM
#47
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

Jeff (and any others that are having "issues" with the rewriters), try replacing your copy of /includes/templates/YOUR_TEMPLATE/templates/tpl_referrer_tools_default.php with

<?php
// +----------------------------------------------------------------------+
// |Snap Affiliates for Zen Cart                                          |
// +----------------------------------------------------------------------+
// | Copyright (c) 2013, Vinos de Frutas Tropicales (lat9) for ZC 1.5.0+  |
// |                                                                      |
// | Original: Copyright (c) 2009 Michael Burke                           |
// | http://www.filterswept.com                                           |
// |                                                                      |
// | This source file is subject to version 2.0 of the GPL license.       |
// +----------------------------------------------------------------------+

function get_referrer_link($base) {
  global $referrer;
  $result = '';

  if (!$referrer->EOF) {
    $result = zen_href_link($base, 'referrer=' . $referrer->fields['referrer_key'], 'NONSSL'); /*v2.1.1c*/
  }
  return $result;
}

function get_referrer_image($width, $height, $filename) {
  $image_html = '';
  $alt = TEXT_IMAGE_ALT_TEXT;
  $image_html .= '<div class="imagewrap">';
  $image_html .= '<div class="imagetitle">' . sprintf(TEXT_X_BY_Y_PIXELS, $width, $height) . '</div>';
  $image_html .= "<img class=\"referrer_image\" src=\"$filename\" width=\"$width\" height=\"$height\" alt=\"$alt\" /><br />";
  $image_html .= '<textarea rows="3" cols="1"><a href="' . get_referrer_link(FILENAME_DEFAULT) . "\"><img src=\"$filename\" width=\"$width\" height=\"$height\" alt=\"$alt\" /></a></textarea><br />";
  $image_html .= '</div>';

  return $image_html;
}
?>
<div class="centerColumn" id="referrerToolsDefault">

<div id="refSignupLinks">
  <a href="<?php echo zen_href_link(FILENAME_REFERRER_MAIN, '', 'SSL');?>"><?php echo TEXT_ORDERS_PAYMENTS; ?></a> | <?php echo TEXT_MARKETING_TOOLS; ?> | <a href="<?php echo zen_href_link(FILENAME_REFERRER_SIGNUP, 'terms', 'SSL');?>"><?php echo TEXT_REFERRER_TERMS; ?></a>
</div>

<h3><?php echo HEADING_SITE_LINK; ?></h3>
<p><?php echo TEXT_SITE_LINK; ?></p>
<p class="centered"><a href="<?php echo get_referrer_link(FILENAME_DEFAULT); ?>"><?php echo TEXT_MARKETING_TEXT; ?></a></p>
<textarea rows="3" cols="1"><a href="<?php echo get_referrer_link(FILENAME_DEFAULT); ?>"><?php echo TEXT_MARKETING_TEXT; ?></a></textarea>

<h3><?php echo HEADING_DEEP_LINK; ?></h3>
<?php require($define_page); ?>

<textarea rows="3" cols="1" style="color: grey;" onfocus="removeTip(this);" onblur="addTipIfBlank(this);" id="referrerLinkDump"><?php echo TEXT_PASTE_LINK_HERE; ?></textarea>
<input type="button" onclick="transform();" value="Transform" />

<?php
if (is_array($snap_banners) && count($snap_banners) != 0) {
?>
<br /><br />
<h3><?php echo HEADING_BANNERS; ?></h3>
<p><?php echo TEXT_BANNERS; ?></p>
<?php 
  foreach ($snap_banners as $current_banner) {
    echo get_referrer_image($current_banner['width'], $current_banner['height'], $current_banner['name']);
  }
}
?>
</div>

and your copy of /includes/modules/pages/referrer_tools/jscript_tools.php with:

<script type="text/javascript"><!--
var referrerPrefix = "<?php echo SNAP_KEY_PREFIX; ?>";
var referrerKey = "<?php echo $referrer->fields['referrer_key']; ?>";
var link_hint = "<?php echo TEXT_PASTE_LINK_HERE; ?>";

function transform() {
  var textArea = document.getElementById("referrerLinkDump");
  var linkPrefix = '&';

  if( textArea ) {
    if( textArea.value.indexOf( "&referrer=" + referrerPrefix ) == -1 && textArea.value.indexOf( "?referrer=" + referrerPrefix) == -1 && textArea.value != link_hint ) {
      if( textArea.value.indexOf( '?' ) == -1) {
        linkPrefix = '?';
      }
      if( textArea.value.indexOf( "&" ) == -1 && textArea.value.indexOf( "?" ) == -1 && textArea.value.charAt( textArea.value.length-1 ) != "/" )  {
        textArea.value += "/";
      }
      textArea.value += linkPrefix + "referrer=" + referrerKey;
    }
  }
}

function removeTip(textArea) {
  if( textArea.value == link_hint ) {
    textArea.style.color = "black";
    textArea.value = "";
  }
}

function addTipIfBlank(textArea) {
  if( textArea.value == "" ) {
    textArea.value = link_hint;
    textArea.style.color = "grey";
  }
}
//--></script>

I believe that those changes will allow your static URLs to accept the referrer variable.

When all looks good, I'll package the changes and upload.

29 Mar 2013, 6:40 PM
#48
jeff_mash avatar

jeff_mash

Totally Zenned

Join Date:
Aug 2004
Posts:
732
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

That seemed to work for me! I can verify that the cookie is now created using the Deep Link Generator with the Ultimate SEO add-on.

Thanks for fixing the issue, and I'm glad I could help contribute to making the module even better than it was before!

  • Jeff
1 Apr 2013, 4:49 PM
#49
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

I've uploaded v2.1.1 to the Plugins area; it contains the two updated files for the referrer_tools page.

8 Apr 2013, 10:56 PM
#50
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

I did bad!

The auto-install that I introduced in v2.1.0, on fresh installs, does not recognize that it's been installed and keeps creating the Affiliate Program configuration_group item over and over and over and over ... (you get the idea).

Here's an update to /YOUR_ADMIN/includes/functions/extra_functions/init_referrers.php that provides the appropriate cleanup.

<?php
// +----------------------------------------------------------------------+
// |Snap Affiliates for Zen Cart                                          |
// +----------------------------------------------------------------------+
// | Copyright (c) 2013, Vinos de Frutas Tropicales (lat9) for ZC 1.5.0+  |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license.       |
// +----------------------------------------------------------------------+

if (!defined('IS_ADMIN_FLAG')) {
    die('Illegal Access');
}
define('SNAP_MODULE_CURRENT_VERSION', '2.1.2');  /*v2.1.2c*/
define('SNAP_MODULE_UPDATE_DATE', '2013-04-08'); /*v2.1.2c*/

//----
// Create each of the database tables for the referrers plugin, if they don't already exist.
//
$sql = "CREATE TABLE IF NOT EXISTS " . TABLE_REFERRERS . " (
  referrer_customers_id int(11) not null primary key,
	referrer_key varchar(32) not null,
	referrer_homepage text not null,
	referrer_approved tinyint(4) not null,
	referrer_banned tinyint(4) not null,
	referrer_commission float not null
  )";
$db->Execute($sql);

$sql = "CREATE TABLE IF NOT EXISTS " . TABLE_COMMISSION . " (
	commission_orders_id int(11) not null primary key,
	commission_referrer_key varchar(96) not null,
	commission_rate float not null,
	commission_paid datetime not null
  )";
$db->Execute($sql);

//----
// Create the Configuration->Affiliate Program item, if it's not already there.
//
$configurationGroupTitle = 'Affiliate Program';
$currentVersion = SNAP_MODULE_CURRENT_VERSION;
$currentDescription = SNAP_MODULE_UPDATE_DATE . ', Vinos de Frutas Tropicales';

//-bof-v2.1.2c-Provide fix-up for problem with previous versions' auto-install
$configuration = $db->Execute("SELECT configuration_group_id FROM " . TABLE_CONFIGURATION_GROUP . " WHERE configuration_group_title = '$configurationGroupTitle' ORDER BY configuration_group_id ASC;");
if ($configuration->EOF) {
  $db->Execute("INSERT INTO " . TABLE_CONFIGURATION_GROUP . " 
                 (configuration_group_title, configuration_group_description, sort_order, visible) 
                 VALUES ('$configurationGroupTitle', 'Set Affiliate Program Options', '1', '1');");
  $configuration_group_id = $db->Insert_ID();
  
  $db->Execute("UPDATE " . TABLE_CONFIGURATION_GROUP . " SET sort_order = $configuration_group_id WHERE configuration_group_id = $configuration_group_id;");

  
} elseif ($configuration->RecordCount() != 1) {
  $configuration_group_id = $configuration->fields['configuration_group_id'];
  $db->Execute("UPDATE " . TABLE_CONFIGURATION . " SET configuration_group_id = $configuration_group_id WHERE configuration_key LIKE 'SNAP%'");
  $db->Execute("DELETE FROM " . TABLE_CONFIGURATION_GROUP . " WHERE (configuration_group_id != $configuration_group_id AND configuration_group_title = '$configurationGroupTitle')");

} else {
  $configuration_group_id = $configuration->fields['configuration_group_id'];
}
//-eof-v2.1.2c-Provide fix-up for problem with previous versions' auto-install

//-----
// If the currently-installed version of the plugin doesn't match the current install's
// version (or it's the first time) ...
//
// Loop through each of the configuration items, inserting them into the database if the
// previously-installed plugin version is less than this current install's version and
// the configuration key doesn't already exist (it "shouldn't", but this provides a bit of 
// an additional safety net).
//
// Once that's complete, update the database configuration to the current install's version.
//
if (!defined('SNAP_MODULE_VERSION') || SNAP_MODULE_VERSION !== $currentVersion) {  /*v2.1.2c*/

  /*----
  ** This array contains the Configuration->Affiliate Program group's options.  Each item will be entered with a
  ** last_modifed and date_added date of 'now()' by the foreach loop that follows.  This structure allows new
  ** configuration items to be added without affecting the store's current setting for the newly-created items.
  */
  $snap_config_items = array (
    array ( 'version' => '1.1', 'title' => 'Module Version', 'key' => 'SNAP_MODULE_VERSION', 'value' => $currentVersion, 'description' => $currentDescription, 'sort_order' => 10, 'use_function' => 'NULL', 'set_function' => 'trim('),
    array ( 'version' => '1.1', 'title' => 'Default Commission', 'key' => 'SNAP_DEFAULT_COMMISSION', 'value' => '0.1', 'description' => 'The default commission rate for your store\'s Affiliate Program.  The value should be specified as a floating-point number in the range 0.0 to 1.0.  The default value (<strong>0.1</strong>) represents a 10% commission rate.<br />', 'sort_order' => 12,  'use_function' => 'NULL', 'set_function' => 'NULL'),
    array ( 'version' => '1.1', 'title' => 'Order Total Exclusions', 'key' => 'SNAP_ORDER_TOTALS_EXCLUSIONS', 'value' => 'ot_shipping,ot_tax', 'description' => 'Exclude these Order Totals classes from an affiliate\'s commission. Enter the values as a comma-separated list with no intervening blanks.<br /><br />Default: <b>ot_shipping,ot_tax</b>.', 'sort_order' => 14, 'use_function' => 'NULL', 'set_function' => 'NULL'),
    array ( 'version' => '1.1', 'title' => 'Affiliate Key Prefix', 'key' => 'SNAP_KEY_PREFIX', 'value' => 'CNWR_', 'description' => 'Enter the prefix value to use for affiliate keys associated with your store\'s Affiliate Program. <strong>Note:</strong> If you change this value after you have started your program, existing affiliates will no longer earn their commissions!<br /><br />Default: <strong>CNWR_</strong>', 'sort_order' => 16, 'use_function' => 'NULL', 'set_function' => 'NULL'),
    array ( 'version' => '1.1', 'title' => 'Send Affiliate Emails To', 'key' => 'SNAP_ADMIN_EMAIL', 'value' => 'Enter email address here', 'description' => 'Enter the email address to which affiliate-related sign-up emails should be sent.<br />', 'sort_order' => 18, 'use_function' => 'NULL', 'set_function' => 'NULL'),
    array ( 'version' => '1.1', 'title' => 'Affiliate Program Images', 'key' => 'SNAP_AFFILIATE_IMAGES', 'value' => '', 'description' => 'Identify the images that your affiliates can use in their back-links.  Each file must be present in your store\'s /images/referrers directory and be named <em>ref.ww.hh.ext</em> where <em>ww</em> is the image width, <em>hh</em> is the image height and <em>ext</em> is the image extension (gif or jpg).<br /><br />Use the format /ww,hh,ext/[ww,hh,ext/...] to identify the files.  For example, if your store uses the files named ref.60.60.gif and ref.120.60.jpg for your program, you will enter this field as <b>/60,60,gif/120,60,jpg/</b><br />', 'sort_order' => 19, 'use_function' => 'NULL', 'set_function' => 'zen_cfg_textarea('),
    array ( 'version' => '1.1', 'title' => 'Include in Information Sidebox?', 'key' => 'SNAP_INFORMATION_SIDEBOX', 'value' => 'true', 'description' => 'Identifies whether (\'true\') or not (\'false\') to include a link to your Affiliate Program in the Information sidebox.<br /><br />Default: <strong>\'true\'</strong>.', 'sort_order' => 20, 'use_function' => 'NULL', 'set_function' => 'zen_cfg_select_option(array(\'true\', \'false\'),'),
    array ( 'version' => '2.1.0', 'title' => 'Affiliate Display Count', 'key' => 'SNAP_MAX_REFERRER_DISPLAY', 'value' => '50', 'description' => 'Specifies the maximum number of affiliates to show on each page of your admin\'s <em>Customers->Referrers</em>.<br /><br />Default: <strong>50</strong><br /><br />', 'sort_order' => 22, 'use_function' => 'NULL', 'set_function' => 'NULL'), /*v2.1.0a*/
    array ( 'version' => '2.1.0', 'title' => 'Allow Self-Commissions', 'key' => 'SNAP_AFFILIATE_KEY_USE', 'value' => 'false', 'description' => 'Identifies whether (\'true\') or not (\'false\') an affiliate receives commission for purchases made using their own <em>affiliate key</em>.<br /><br />Default: <strong>\'false\'</strong>.', 'sort_order' => 24, 'use_function' => 'NULL', 'set_function' => 'zen_cfg_select_option(array(\'true\', \'false\'),'), /*v2.1.0a*/
    array ( 'version' => '2.1.0', 'title' => 'Order Status Exclusions', 'key' => 'SNAP_ORDER_STATUS_EXCLUSIONS', 'value' => '', 'description' => 'Exclude orders with the following <em>Order Status</em> values from affiliate commissions. Specify the values as a packed (i.e. no spaces) comma-separated list.<br /><br />Default: <br /><br />', 'sort_order' => 26, 'use_function' => 'NULL', 'set_function' => 'NULL'), /*v2.1.0a*/

  );

  if (!defined('SNAP_MODULE_VERSION')) define ('SNAP_MODULE_VERSION', '0');  /*v2.1.2a*/
  
  foreach ($snap_config_items as $config_item) {
    if (SNAP_MODULE_VERSION < $config_item['version'] && !defined($config_item['key'])) {
      $sql = "INSERT INTO " . TABLE_CONFIGURATION . " 
        (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) 
        VALUES
        ('" . $config_item['title'] . "', '" . zen_db_input($config_item['key']) . "', '" . zen_db_input($config_item['value']) . "', '" . zen_db_input($config_item['description']) . "', $configuration_group_id, " . (int)$config_item['sort_order'] . ", NOW(), NOW(), " . (($config_item['use_function'] == 'NULL') ? 'NULL' : ("'" . zen_db_input($config_item['use_function']) . "'")) . ', ' . (($config_item['set_function'] == 'NULL') ? 'NULL' : ("'" . zen_db_input($config_item['set_function']) . "'")) . ');';
      $db->Execute($sql);
    }
  }

  $db->Execute("UPDATE " . TABLE_CONFIGURATION . " SET configuration_value = '$currentVersion', configuration_description = '$currentDescription' WHERE configuration_group_id = $configuration_group_id AND configuration_key = 'SNAP_MODULE_VERSION';");

  unset($snap_config_items);
}

//----
// If the installation supports admin-page registration (i.e. v1.5.0 and later), then
// register the Affiliate Program configuration and the Referrers tool into the admin menu structure.
//
if (function_exists('zen_register_admin_page')) {
  if (!zen_page_key_exists('configurationAffiliates')) {
    zen_register_admin_page('configurationAffiliates', 'BOX_CONFIGURATION_AFFILIATES', 'FILENAME_CONFIGURATION', "gID=$configuration_group_id", 'configuration', 'Y', $configuration_group_id);
  }
  
  if (!zen_page_key_exists('customersReferrers')) {
    zen_register_admin_page('customersReferrers', 'BOX_CUSTOMERS_REFERRERS', 'FILENAME_REFERRERS', '', 'customers', 'Y', 20);
  }    
}

I'll upload a v2.1.2 BUGFIX to the plugins area, probably tomorrow morning.

9 Apr 2013, 12:22 PM
#51
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

When I'm on a roll, I'm on a roll ...

Let's try this version (2.1.2a) instead, since it actually works.:blush:

<?php
// +----------------------------------------------------------------------+
// |Snap Affiliates for Zen Cart                                          |
// +----------------------------------------------------------------------+
// | Copyright (c) 2013, Vinos de Frutas Tropicales (lat9) for ZC 1.5.0+  |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license.       |
// +----------------------------------------------------------------------+

if (!defined('IS_ADMIN_FLAG')) {
    die('Illegal Access');
}
define('SNAP_MODULE_CURRENT_VERSION', '2.1.2a'); /*v2.1.2c*/
define('SNAP_MODULE_UPDATE_DATE', '2013-04-09'); /*v2.1.2c*/

//----
// Create each of the database tables for the referrers plugin, if they don't already exist.
//
$sql = "CREATE TABLE IF NOT EXISTS " . TABLE_REFERRERS . " (
  referrer_customers_id int(11) not null primary key,
	referrer_key varchar(32) not null,
	referrer_homepage text not null,
	referrer_approved tinyint(4) not null,
	referrer_banned tinyint(4) not null,
	referrer_commission float not null
  )";
$db->Execute($sql);

$sql = "CREATE TABLE IF NOT EXISTS " . TABLE_COMMISSION . " (
	commission_orders_id int(11) not null primary key,
	commission_referrer_key varchar(96) not null,
	commission_rate float not null,
	commission_paid datetime not null
  )";
$db->Execute($sql);

//----
// Create the Configuration->Affiliate Program item, if it's not already there.
//
$configurationGroupTitle = 'Affiliate Program';
$currentVersion = SNAP_MODULE_CURRENT_VERSION;
$currentDescription = SNAP_MODULE_UPDATE_DATE . ', Vinos de Frutas Tropicales';

//-bof-v2.1.2c-Provide fix-up for problem with previous versions' auto-install
$configuration = $db->Execute("SELECT configuration_group_id FROM " . TABLE_CONFIGURATION_GROUP . " WHERE configuration_group_title = '$configurationGroupTitle' ORDER BY configuration_group_id ASC;");
if ($configuration->EOF) {
  $db->Execute("INSERT INTO " . TABLE_CONFIGURATION_GROUP . " 
                 (configuration_group_title, configuration_group_description, sort_order, visible) 
                 VALUES ('$configurationGroupTitle', 'Set Affiliate Program Options', '1', '1');");
  $configuration_group_id = $db->Insert_ID();
  
  $db->Execute("UPDATE " . TABLE_CONFIGURATION_GROUP . " SET sort_order = $configuration_group_id WHERE configuration_group_id = $configuration_group_id;");

  
} elseif ($configuration->RecordCount() != 1) {
  $configuration_group_id = $configuration->fields['configuration_group_id'];
  $db->Execute("UPDATE " . TABLE_CONFIGURATION . " SET configuration_group_id = $configuration_group_id WHERE configuration_key LIKE 'SNAP%'");
  $db->Execute("DELETE FROM " . TABLE_CONFIGURATION_GROUP . " WHERE (configuration_group_id != $configuration_group_id AND configuration_group_title = '$configurationGroupTitle')");

} else {
  $configuration_group_id = $configuration->fields['configuration_group_id'];
}
//-eof-v2.1.2c-Provide fix-up for problem with previous versions' auto-install

//-----
// If the currently-installed version of the plugin doesn't match the current install's
// version (or it's the first time) ...
//
// Loop through each of the configuration items, inserting them into the database if the
// previously-installed plugin version is less than this current install's version and
// the configuration key doesn't already exist (it "shouldn't", but this provides a bit of 
// an additional safety net).
//
// Once that's complete, update the database configuration to the current install's version.
//
if (!defined('SNAP_MODULE_VERSION') || SNAP_MODULE_VERSION !== $currentVersion) {  /*v2.1.2c*/

  /*----
  ** This array contains the Configuration->Affiliate Program group's options.  Each item will be entered with a
  ** last_modifed and date_added date of 'now()' by the foreach loop that follows.  This structure allows new
  ** configuration items to be added without affecting the store's current setting for the newly-created items.
  */
  $snap_config_items = array (
    array ( 'version' => '1.1', 'title' => 'Module Version', 'key' => 'SNAP_MODULE_VERSION', 'value' => $currentVersion, 'description' => $currentDescription, 'sort_order' => 10, 'use_function' => 'NULL', 'set_function' => 'trim('),
    array ( 'version' => '1.1', 'title' => 'Default Commission', 'key' => 'SNAP_DEFAULT_COMMISSION', 'value' => '0.1', 'description' => 'The default commission rate for your store\'s Affiliate Program.  The value should be specified as a floating-point number in the range 0.0 to 1.0.  The default value (<strong>0.1</strong>) represents a 10% commission rate.<br />', 'sort_order' => 12,  'use_function' => 'NULL', 'set_function' => 'NULL'),
    array ( 'version' => '1.1', 'title' => 'Order Total Exclusions', 'key' => 'SNAP_ORDER_TOTALS_EXCLUSIONS', 'value' => 'ot_shipping,ot_tax', 'description' => 'Exclude these Order Totals classes from an affiliate\'s commission. Enter the values as a comma-separated list with no intervening blanks.<br /><br />Default: <b>ot_shipping,ot_tax</b>.', 'sort_order' => 14, 'use_function' => 'NULL', 'set_function' => 'NULL'),
    array ( 'version' => '1.1', 'title' => 'Affiliate Key Prefix', 'key' => 'SNAP_KEY_PREFIX', 'value' => 'CNWR_', 'description' => 'Enter the prefix value to use for affiliate keys associated with your store\'s Affiliate Program. <strong>Note:</strong> If you change this value after you have started your program, existing affiliates will no longer earn their commissions!<br /><br />Default: <strong>CNWR_</strong>', 'sort_order' => 16, 'use_function' => 'NULL', 'set_function' => 'NULL'),
    array ( 'version' => '1.1', 'title' => 'Send Affiliate Emails To', 'key' => 'SNAP_ADMIN_EMAIL', 'value' => 'Enter email address here', 'description' => 'Enter the email address to which affiliate-related sign-up emails should be sent.<br />', 'sort_order' => 18, 'use_function' => 'NULL', 'set_function' => 'NULL'),
    array ( 'version' => '1.1', 'title' => 'Affiliate Program Images', 'key' => 'SNAP_AFFILIATE_IMAGES', 'value' => '', 'description' => 'Identify the images that your affiliates can use in their back-links.  Each file must be present in your store\'s /images/referrers directory and be named <em>ref.ww.hh.ext</em> where <em>ww</em> is the image width, <em>hh</em> is the image height and <em>ext</em> is the image extension (gif or jpg).<br /><br />Use the format /ww,hh,ext/[ww,hh,ext/...] to identify the files.  For example, if your store uses the files named ref.60.60.gif and ref.120.60.jpg for your program, you will enter this field as <b>/60,60,gif/120,60,jpg/</b><br />', 'sort_order' => 19, 'use_function' => 'NULL', 'set_function' => 'zen_cfg_textarea('),
    array ( 'version' => '1.1', 'title' => 'Include in Information Sidebox?', 'key' => 'SNAP_INFORMATION_SIDEBOX', 'value' => 'true', 'description' => 'Identifies whether (\'true\') or not (\'false\') to include a link to your Affiliate Program in the Information sidebox.<br /><br />Default: <strong>\'true\'</strong>.', 'sort_order' => 20, 'use_function' => 'NULL', 'set_function' => 'zen_cfg_select_option(array(\'true\', \'false\'),'),
    array ( 'version' => '2.1.0', 'title' => 'Affiliate Display Count', 'key' => 'SNAP_MAX_REFERRER_DISPLAY', 'value' => '50', 'description' => 'Specifies the maximum number of affiliates to show on each page of your admin\'s <em>Customers->Referrers</em>.<br /><br />Default: <strong>50</strong><br /><br />', 'sort_order' => 22, 'use_function' => 'NULL', 'set_function' => 'NULL'), /*v2.1.0a*/
    array ( 'version' => '2.1.0', 'title' => 'Allow Self-Commissions', 'key' => 'SNAP_AFFILIATE_KEY_USE', 'value' => 'false', 'description' => 'Identifies whether (\'true\') or not (\'false\') an affiliate receives commission for purchases made using their own <em>affiliate key</em>.<br /><br />Default: <strong>\'false\'</strong>.', 'sort_order' => 24, 'use_function' => 'NULL', 'set_function' => 'zen_cfg_select_option(array(\'true\', \'false\'),'), /*v2.1.0a*/
    array ( 'version' => '2.1.0', 'title' => 'Order Status Exclusions', 'key' => 'SNAP_ORDER_STATUS_EXCLUSIONS', 'value' => '', 'description' => 'Exclude orders with the following <em>Order Status</em> values from affiliate commissions. Specify the values as a packed (i.e. no spaces) comma-separated list.<br /><br />Default: <br /><br />', 'sort_order' => 26, 'use_function' => 'NULL', 'set_function' => 'NULL'), /*v2.1.0a*/

  );

  $installedVersion = (defined('SNAP_MODULE_VERSION')) ? SNAP_MODULE_VERSION : '0';  /*v2.1.2c*/
  
  foreach ($snap_config_items as $config_item) {
    if ($installedVersion < $config_item['version'] && !defined($config_item['key'])) {  /*v2.1.2c*/
      $sql = "INSERT INTO " . TABLE_CONFIGURATION . " 
        (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) 
        VALUES
        ('" . $config_item['title'] . "', '" . zen_db_input($config_item['key']) . "', '" . zen_db_input($config_item['value']) . "', '" . zen_db_input($config_item['description']) . "', $configuration_group_id, " . (int)$config_item['sort_order'] . ", NOW(), NOW(), " . (($config_item['use_function'] == 'NULL') ? 'NULL' : ("'" . zen_db_input($config_item['use_function']) . "'")) . ', ' . (($config_item['set_function'] == 'NULL') ? 'NULL' : ("'" . zen_db_input($config_item['set_function']) . "'")) . ');';
      $db->Execute($sql);
    }
  }

  $db->Execute("UPDATE " . TABLE_CONFIGURATION . " SET configuration_value = '$currentVersion', configuration_description = '$currentDescription' WHERE configuration_group_id = $configuration_group_id AND configuration_key = 'SNAP_MODULE_VERSION';");

  unset($snap_config_items);
}

//----
// If the installation supports admin-page registration (i.e. v1.5.0 and later), then
// register the Affiliate Program configuration and the Referrers tool into the admin menu structure.
//
if (function_exists('zen_register_admin_page')) {
  if (!zen_page_key_exists('configurationAffiliates')) {
    zen_register_admin_page('configurationAffiliates', 'BOX_CONFIGURATION_AFFILIATES', 'FILENAME_CONFIGURATION', "gID=$configuration_group_id", 'configuration', 'Y', $configuration_group_id);
  }
  
  if (!zen_page_key_exists('customersReferrers')) {
    zen_register_admin_page('customersReferrers', 'BOX_CUSTOMERS_REFERRERS', 'FILENAME_REFERRERS', '', 'customers', 'Y', 20);
  }    
}
12 Apr 2013, 8:47 AM
#52
christospur avatar

christospur

New Zenner

Join Date:
Sep 2012
Posts:
40
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

Hello,

I wish to install the SNAP Affiliates and use it for 1.3.9h but what i wanted to know was:

a) Can you create a tiered structure so that people earn different stages of commission if they sell more? (sell 10 get 5%, sell 20 get 10%, sell 30 get 12.5% etc...)

b) Can you limit the programme for use with certain items only?

c) Will the 1.5 version work for me?

12 Apr 2013, 10:22 AM
#53
picandnix avatar

picandnix

Totally Zenned

Join Date:
Dec 2010
Location:
UK
Posts:
1,780
Plugin Contributions:
2

Re: Snap Affiliates v2.0 for v1.5.0 and later

christospur:

Hello,

I wish to install the SNAP Affiliates and use it for 1.3.9h but what i wanted to know was:

a) Can you create a tiered structure so that people earn different stages of commission if they sell more? (sell 10 get 5%, sell 20 get 10%, sell 30 get 12.5% etc...)

b) Can you limit the programme for use with certain items only?

c) Will the 1.5 version work for me?

the 1.5 version isn't built to work on 1.3

12 Apr 2013, 1:27 PM
#54
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

christospur:

Hello,

I wish to install the SNAP Affiliates and use it for 1.3.9h but what i wanted to know was:

a) Can you create a tiered structure so that people earn different stages of commission if they sell more? (sell 10 get 5%, sell 20 get 10%, sell 30 get 12.5% etc...)

b) Can you limit the programme for use with certain items only?

c) Will the 1.5 version work for me?
christospur, the answers to all your questions are (at this time): No.

Other people have requested your item (b) to limit the program only to certain items or, alternatively, to exclude some items from commission. I don't think I have heard the request to have a tiered structure before -- either based on number of items or using a sales-amount threshold -- but if others would like this I can place it on the things-to-do list.

As picandnix indicated, this version will not work on the 1.3.x versions of Zen Cart.

15 Apr 2013, 10:14 AM
#55
christospur avatar

christospur

New Zenner

Join Date:
Sep 2012
Posts:
40
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

The original Snap Affiliates by Michael, seems to allow for it to be limited to individual items:

"Affiliates can link anywhere into your Zen Cart store and still receive credit for sales; from the front page down to individual items."

It also seemed to allow for variable commission rates:

"Variable commission rates; a valuable tool for motivating and rewarding affiliates."

In working practise, is this not the case?

15 Apr 2013, 11:13 AM
#56
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

christospur:

The original Snap Affiliates by Michael, seems to allow for it to be limited to individual items:

"Affiliates can link anywhere into your Zen Cart store and still receive credit for sales; from the front page down to individual items."

It also seemed to allow for variable commission rates:

"Variable commission rates; a valuable tool for motivating and rewarding affiliates."

In working practise, is this not the case?
christospur, the key phrase is seems to.

The first phrase you quoted would be better written: "Affiliates can link anywhere into your Zen Cart store, from the front page down to individual items, and still receive credit for sales.". Neither version of the plugin limits the commission earned by an affiliate to individual items.

I believe that the "variable commission rates" that are quoted in the description for this plugin's parent refer to the fact that you can vary the commission rates from one affiliate to the other. A specific affiliate's commission rate, however, is fixed; it does not vary from one product to the next.

21 Apr 2013, 9:54 PM
#57
leif_oskarsson avatar

leif_oskarsson

New Zenner

Join Date:
Apr 2013
Location:
Clearwater, Florida, United States
Posts:
1
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

i can not see affiliate link even after saying yes in admin settings to include on information box.
everything else is working but have no link?
see http://www.pokerlifegear.com/shop

22 Apr 2013, 10:57 AM
#58
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Snap Affiliates v2.0 for v1.5.0 and later

Leif Oskarsson:

i can not see affiliate link even after saying yes in admin settings to include on information box.
everything else is working but have no link?
see http://www.pokerlifegear.com/shop
Did you rename the file folder /includes/modules/sideboxes/YOUR_TEMPLATE/information.php to /includes/modules/robbor_black/information.php?

There are a bunch of template overrides in this plugin and it's very easy to miss one ...

23 May 2013, 8:17 AM
#59
kezan98 avatar

kezan98

Zen Follower

Join Date:
Nov 2007
Location:
UK
Posts:
98
Plugin Contributions:
0

Re: Snap Affiliates v2.0 for v1.5.0 and later

I wonder if anyone can help.

I'm using the latest version of this plugin on zencart 1.5 with ceons ultimate seo and while I get no 404 errors and the cookie seems to be set, I'm not getting any record of affiliate commissions. I've check and the version I have installed is the one with the amended files for seo plugins on this thread.

I'm using Nochex (payment processor) to test my transactions and the sales are being recorded, just not the affiliate commission. I've cleared the cookies and use a different account to make the purchase from the referral link, tried home page and deep links. Nothing seems to work.

Any suggestions?

Many thanks

Kerrie

23 May 2013, 8:56 AM
#60
picandnix avatar

picandnix

Totally Zenned

Join Date:
Dec 2010
Location:
UK
Posts:
1,780
Plugin Contributions:
2

Re: Snap Affiliates v2.0 for v1.5.0 and later

kezan98:

I wonder if anyone can help.

I'm using the latest version of this plugin on zencart 1.5 with ceons ultimate seo and while I get no 404 errors and the cookie seems to be set, I'm not getting any record of affiliate commissions. I've check and the version I have installed is the one with the amended files for seo plugins on this thread.

I'm using Nochex (payment processor) to test my transactions and the sales are being recorded, just not the affiliate commission. I've cleared the cookies and use a different account to make the purchase from the referral link, tried home page and deep links. Nothing seems to work.

Any suggestions?

Many thanks

Kerrie

Hi Kerrie
have you read all of this thread? I think it's been answered already.