Re: 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.
Re: Snap Affiliates v2.0 for v1.5.0 and later
Quote:
Originally Posted by
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-...44491364328461
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?
Re: Snap Affiliates v2.0 for v1.5.0 and later
Quote:
Originally Posted by
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:
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/&referre...44491364328461 <-----THIS WORKS. COOKIE IS CREATED
DEEP LINK FORMAT:
http://www.domain.com/store/space-tr...44491364328461 <---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?
Re: Snap Affiliates v2.0 for v1.5.0 and later
Quote:
Originally Posted by
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/&referre...44491364328461 <-----THIS WORKS. COOKIE IS CREATED
DEEP LINK FORMAT:
http://www.domain.com/store/space-tr...44491364328461 <---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?
Re: Snap Affiliates v2.0 for v1.5.0 and later
Quote:
Originally Posted by
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
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
Code:
<?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:
Code:
<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.
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!
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.
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.
Code:
<?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.