Hi all!
I'm having difficulties merging the 2 orders.php files, i would appreciate if someone here could help :)
TIA
Printable View
Hi all!
I'm having difficulties merging the 2 orders.php files, i would appreciate if someone here could help :)
TIA
Which two orders.php files would those be? What other admin-level plugins do you have installed that have made modifications to the orders.php file?
Sorry, its basically just admin/orders.php
I have
SO
TY Package tracker
Add Orders
Custom Mod
It looks like everything is in order except one thing. It shows the commission on the affiliates admin but it fails to show on my admin as I review my affiliates. Did I put a file in a wrong place? I am using Zen Cart 1.5.1, windows 8 and the most recent I.E.
I'm using snap 2.1.2
I can think of one person who could answer that with the most accuracy...you :wink:Quote:
Did I put a file in a wrong place?
So, did you upload them correctly?
I kept that version since I'm not good at adding mods. If I can get something that works, I don't change it. Now that I need to upgrade I'm worried about messing up the original install of the mod and the store. Any advice?
The readme's pretty specific about what files were changed for what version. What other admin-level plugins are you using in your store? The current versions of SNAP make modifications to the /YOUR_ADMIN/orders.php processing and the amount of merging required depends heavily on the changes introduced by those other plugins!
I also have a rewards mod in there, that's about it.
If you compare your store's /YOUR_ADMIN/orders.php to the Zen Cart original version, have any changes been made?
I'm not sure. I used softaculous to install the zen cart, It's one of those instant install software kits. Is that where I should go? I can do that this afternoon and see where anything might have gone wrong
I'd rather have the snap affiliate than the rewards mod so I used the snap orders.php file and overwrote what I had there.
Looks like I made more of a mess than I had before. Now the snap isn't working and I can't see any orders made in my store's admin.
I fixed the orders issue. I wish this could be easier, lol.
Agreed on the easier comment; I believe that Zen Cart v1.6.0 is looking to include some interfaces to at least have the plugins' installations more standardized. For the SNAP install, just follow the instructions in the plugin's distribution zip-file. The only corefile overwrite is the admin's orders.php, so all the other files can be safely overwritten once you've verified that the orders.php file is OK!
I'll try to upgrade, thank you so much for sticking with me.
Cheers
Oh, can I use the same .sql file or do I need to add the new one?
If you do the SNAP file upgrade from 2.1.2 to 2.7.0, the PHP files on the admin side will handle the database updates required automatically.
I've just submitted v2.7.1 to the Plugins; it will be available for download (http://www.zen-cart.com/downloads.php?do=file&id=1635) once approved.
This version picks up a template-file change for Zen Cart v1.5.3 that was previously missed and displays each referrer's email address within the Customers->Referrers page.
Just a suggestion, if an account has an affiliate account active show "Affiliate Admin" next to account link
Customer Name | Affiliate Admin | logout
Yes for customer front end
Am I missing something, I don't see an images/referrers folder in the zip download? I've used the earlier version of snap in my 1.3.9 store and i'm installing this on a new 1.5 store. I use my own designed banners for my affiliates and this new version seems to be set up a bit different. The instructions, referenced a template in the images/referrers folder but it's not there.
Any help would be awesome.
Thanks for the module and effort, it's greatly appreciated.
You're not missing anything; when I transitioned to github, I'm apparently "ignoring" the /images directory.:censored:
The /images/referrers directory is being used by the plugin and I'll get the plugin's distribution updated -- thanks for the report!
No worries, figured it out and got it all working.
I do have a question. In the earlier mod version, there was a work around to have multiple banners of the same size.
For example, i'm using ref.120.600.jpg. If wanted to use another 120x600 jpg banner is there a method or work around for this?
Thanks
I don't have my SNAP test site available, but here's (as yet untested) what I propose using as a replacement for /includes/modules/pages/referrer_tools/header_php.php:
Code:<?php
// +---------------------------------------------------------------------------+
// |Snap Affiliates for Zen Cart |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2013-2014, 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. |
// +---------------------------------------------------------------------------+
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
define('DIR_WS_IMAGES_REFERRERS', DIR_WS_IMAGES . 'referrers/');
if (!$_SESSION['customer_id']) {
$_SESSION['navigation']->set_snapshot();
$messageStack->add_session('login', CAUTION_NEED_LOGIN, 'caution');
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
}
$is_logged_in = true;
$query = "SELECT * FROM " . TABLE_REFERRERS ." WHERE referrer_customers_id = " . (int)$_SESSION['customer_id'];
$referrer = $db->Execute($query);
if ($referrer->EOF) {
zen_redirect(zen_href_link(FILENAME_REFERRER_SIGNUP, '', 'SSL'));
}
if (((int)$referrer->fields['referrer_approved']) == 0) {
zen_redirect(zen_href_link(FILENAME_REFERRER_MAIN, '', 'SSL'));
}
$snap_banners = array();
if (SNAP_AFFILIATE_IMAGES != '') {
$snap_banner_files = explode('/', SNAP_AFFILIATE_IMAGES);
foreach ($snap_banner_files as $current_file ) {
if (zen_not_null($current_file)) {
$fileinfo = explode(',', $current_file);
$width = $fileinfo[0];
$height = $fileinfo[1];
$extension = $fileinfo[2];
$filenames = glob (DIR_WS_IMAGES_REFERRERS . "ref*.$width.$height.$extension");
if ($filenames !== false {
foreach ($filenames as $filename) {
$snap_banners[] = array ( 'name' => $filename, 'width' => $width, 'height' => $height );
}
}
}
}
}
// include template specific file name defines
$define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_REFERRAL_TOOLS, 'false');
$breadcrumb->add(NAVBAR_TITLE);
This isn't a dynamic method but for now it's going to have to work for me, since I need to get my store up and this is the only thing hold me back, since i've got a ton affiliates already from using older version of zen cart..
I just wanted to pass this along if someone else needed to add multiple banners of the same size. I updated the tpl_referrer_tools_default.php file. Instead of having the banners generated dynamically, i'm just adding them in manually with the below code repeating and adding in the image page, sizing and banner sizing info.
<div class="imagewrap"><div class="imagetitle">Banner Size Goes Here</div>
<img class="referrer_image" src="banner image path here" width="banner width here" height="banner height here" alt="Your image alt-text here" />
<br />
<textarea rows="3" cols="1"><a href="http://your store url&referrer=<?php echo $referrer->fields['referrer_key']; ?>"><img src="banner image path here" width="banner width here" height="banner height here" alt="Your image alt-text here" /></a>
</textarea>
<br />
</div>
for anyone interested, the above code is replacing
<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']);
}
}
?>
you also must delete lines 54-56:
<?php
if (is_array($snap_banners) && count($snap_banners) != 0) {
?>
Sorry for the hack up job but, time is important right now. When I have more time, i'm going to look into a dynamic fix if one hasn't been worked out by the time I get around to it :o)
Hi lat9,
What a truly fantastic mod, thank you so much for all your hard work.
I have installed this along with many other modifications including Ty Packager Tracker. With the files you provided for this integration, all seems to be working quite well with one small exception. When adding the tracking number to customer's order the comments generated to include a link to the shippers tracking info gives the following:
It seems to me this is generated in admin/includes/classes/observers/class.ty_package_tracker but not being a coder, I have no idea how to correct it. Everything I try 'breaks' the page.Quote:
Your USPS Tracking ID is ***************
https://tools.usps.com/go/TrackConfirmAction!input.action?tLabels=****************>Click here</a> to track your package.
If the above link does not work, copy the following URL address and paste it into your Web browser.
https://tools.usps.com/go/TrackConfi...**************
It may take up to 24 hours for the tracking information to appear on the website.
Thanks in advance for your response, and many,many thanks for this great contribution!
Duffy
Duffy, you're correct about which module inserts that tracking information. I'll need to review that integration code-merge to see what's up. Where does that "funky" display show up? On the display? In HTML emails? In text emails?
It shows up in all three plus. On the admin order screen in the comments section, in emails and in the customer's account history when reviewing orders.
Hmm, it looks like your language definition is missing an anchor start. Do lines 32-45 of the identified file look like this?
Code:case 'ZEN_UPDATE_ORDERS_HISTORY_PRE_EMAIL': {
$track_id = $this->get_track_ids();
if (is_array($track_id)) {
foreach ($track_id as $id => $track) {
if (zen_not_null($track) && constant('CARRIER_STATUS_' . $id) == 'True') {
if (zen_not_null($osh_additional_comments)) {
$osh_additional_comments .= "\n";
}
$osh_additional_comments .= "Your " . constant('CARRIER_NAME_' . $id) . " Tracking ID is " . $track . " \n\t\t<a href=" . constant('CARRIER_LINK_' . $id) . $track . ">Click here</a> to track your package. \n\t\tIf the above link does not work, copy the following URL address and paste it into your Web browser. \n\t\t" . constant('CARRIER_LINK_' . $id) . $track . "\n\nIt may take up to 24 hours for the tracking information to appear on the website.";
}
}
}
break;
}
Yes. It looks exactly like that.
Change that code fragment to
The additional information is extraneous.Code:case 'ZEN_UPDATE_ORDERS_HISTORY_PRE_EMAIL': {
$track_id = $this->get_track_ids();
if (is_array($track_id)) {
foreach ($track_id as $id => $track) {
if (zen_not_null($track) && constant('CARRIER_STATUS_' . $id) == 'True') {
if (zen_not_null($osh_additional_comments)) {
$osh_additional_comments .= "\n";
}
$osh_additional_comments .= "Your " . constant('CARRIER_NAME_' . $id) . " Tracking ID is " . $track . "\n\nIt may take up to 24 hours for the tracking information to appear on the website.\n\n";
}
}
}
break;
}
Perfect!! Works great. THANK YOU SO VERY MUCH!!:clap:
You're welcome. I'll include that update as an optional installation element in the next release of the SNAP Affiliates plugin. Thanks for the heads-up that the changes caused "funkiness" in the display
Hello all, quick question for anyone who knows: How are affiliate codes in Snap Affiliates generated? We are putting a site together with about 450 existing affiliates, and would like to maintain the original affiliate codes for legacy users. Our codes have a common prefix, so that should work. Can I just replace the affiliate code in the database for each legacy user, and allow the system to generate new codes for new users? Our old codes are fairly simple, and by their construction should not create any collisions.
Thanks in advance for any insight.
The referrer "key" (aka affiliate code) is calculated as:
So, the keys are calculated as the prefix you choose followed by a sequence of numerical digits.Code:$tag = SNAP_KEY_PREFIX . $_SESSION['customer_id'] . time();
Thank you for the very prompt answer. It looks like I will be able to use my old codes.
I have a new issue. If I check the box to include the "Our Affiliate Program" page in the sidebox, it puts the link both first and last in the box. Any idea why it may be duplicated?
Just installed the mod, and I'm having some issues with it.
quick question, I need to display the actual commission paid amount on the clients account area, is there a way to show it?
Thanks.
The "referrers_main" page will show any commissions paid to the affiliate-customer.
Thanks Lat9.
It currently shows only the commission based on the total amount of the order, not the actual commission paid amount.
In the admin area of the store, we can input the amount that will be paid to the affiliate on a particular order, say for example the order total is $80, the commission to be paid on a 10% is $8, but we had a return on that order, so the actual commission goes down to $5. On the referrers_main page the $5 isn't shown, only the $8.
I appreciate the detailed report, I'll look into the issue and report back.
Thanks so much!
I think I was able to make it work for what we need, and it might be helpful for someone else, so here it goes.
We wanted to show both the commission based on the order's amount, and the actual commission paid, which is stored on the database as commission_paid_amount. So we added an extra column that displays the commission_paid_amount.
All the changes made show as //EWD so they're easy to locate.
modules>pages>referrer_main>header_php.php
PHP 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. |
// +----------------------------------------------------------------------+
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
$breadcrumb->add(NAVBAR_TITLE);
$today = getdate();
$referrer = null;
$submitted = false;
$approved = false;
$banned = false;
$is_referrer = false;
$is_logged_in = isset ($_SESSION['customer_id']);
$total_total = 0;
$total_commission = 0;
$unpaid_total = 0;
$unpaid_commission = 0;
$yearly_total = 0;
$yearly_commission = 0;
$last_payout = 0;
$next_payout = 0;
$activity_begin = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
$activity_end = mktime(23, 59, 59, $activity_begin['mon'] + 1, 0, $today['year']);
$activity_total = 0;
$activity_commission = 0;
$activity_total_commission_paid_amount = 0; //EWD
$activity_commission_paid_amount = 0; // EWD
$activity = array();
if (isset($_GET['start'])) {
$activity_begin = intval ($_GET['start']);
}
if( $activity_begin > time() ) {
$activity_begin = time();
}
if (isset ($_GET['end'])) {
$activity_end = intval( $_GET['end'] );
}
if ($activity_begin > $activity_end) {
$tempDate = getdate ($activity_begin);
$activity_end = mktime (23, 59, 59, $tempDate['mon']+1, 0, $tempDate['year']);
}
if (!$is_logged_in) {
zen_redirect(zen_href_link(FILENAME_REFERRER_SIGNUP, '', "SSL"));
} else {
$query = "SELECT * FROM ". TABLE_REFERRERS ." WHERE referrer_customers_id = " . (int)$_SESSION['customer_id'];
$referrer = $db->Execute($query);
if (!is_object($referrer) || $referrer->EOF ) {
zen_redirect(zen_href_link(FILENAME_REFERRER_SIGNUP, '', "SSL"));
} else {
$submitted = true;
$approved = (bool)$referrer->fields['referrer_approved'];
$banned = (bool)$referrer->fields['referrer_banned'];
if ($approved) {
if (!defined('SNAP_ORDER_STATUS_EXCLUSIONS')) define('SNAP_ORDER_STATUS_EXCLUSIONS', ''); /*v2.1.0a*/
if (!defined('SNAP_ORDER_TOTALS_EXCLUSIONS')) define('SNAP_ORDER_TOTALS_EXCLUSIONS', 'ot_tax,ot_shipping');
//-bof-v2.1.0c (changed $exclude_array to $totals_exclude_array
$totals_exclude_array = explode(',', SNAP_ORDER_TOTALS_EXCLUSIONS);
for ($i = 0, $totals_exclude_clause = '', $n = count($totals_exclude_array); $i < $n; $i++) {
if ($i != 0) {
$totals_exclude_clause .= ' OR ';
}
$totals_exclude_clause .= ("t.class = '" . $totals_exclude_array[$i] . "'");
}
if ($totals_exclude_clause != '') {
$totals_exclude_clause = " AND ( $totals_exclude_clause ) ";
}
//-eof-v2.1.0c
$year_start = mktime(0,0,0, 1, 1, $today['year']);
//-bof-v2.1.0a: Don't show commission for orders status values in the "exclude list".
$status_exclude_array = explode(',', SNAP_ORDER_STATUS_EXCLUSIONS);
//-eof-v2.1.0a
$no_status_exclusions = (sizeof($status_exclude_array) == 1 && $status_exclude_array[0] == '') ? true : false; /*v2.5.1a*/
// EWD Added c.commission_paid_amount
$query = "SELECT o.orders_id, o.date_purchased, o.order_total, c.commission_paid, c.commission_paid_amount, c.commission_rate, o.orders_status
FROM ". TABLE_ORDERS ." o, " . TABLE_COMMISSION . " c
WHERE c.commission_referrer_key = '" . $referrer->fields['referrer_key'] . "'
AND o.orders_id = c.commission_orders_id"; /*v2.1.0c*/
$orders = $db->Execute($query);
while (!$orders->EOF) {
$commission = floatval($orders->fields['commission_rate']);
$purchase_date = strtotime($orders->fields['date_purchased']);
$current_date = $orders->fields['commission_paid'];
$current_commission_paid_amount = floatval($orders->fields['commission_paid_amount']); // EWD
$query = "SELECT t.value
FROM " . TABLE_ORDERS ." o, ". TABLE_ORDERS_TOTAL ." t
WHERE o.orders_id = " . $orders->fields['orders_id'] . "
AND o.orders_id = t.orders_id" . $totals_exclude_clause; /*v2.1.0c*/
$totals = $db->Execute($query);
$current_exclusion = 0;
while (!$totals->EOF) {
$current_exclusion += floatval($totals->fields['value']);
$totals->MoveNext();
}
$current_amount = floatval($orders->fields['order_total']) - $current_exclusion;
if ($current_amount < 0) {
$current_amount = 0;
}
if ($current_date != "0000-00-00 00:00:00") {
$current_date = strtotime($current_date);
} else {
$current_date = 0;
}
if ( $no_status_exclusions || !($current_date == 0 && in_array($orders->fields['orders_status'], $status_exclude_array)) ) { /*v2.5.0a,v2.5.1c*/
$total_total += $current_amount;
$total_commission += $commission * $current_amount;
if( $purchase_date > $year_start ) {
$yearly_total += $current_amount;
$yearly_commission += $commission * $current_amount;
}
if ($current_date === 0) {
$unpaid_total += $current_amount;
$unpaid_commission += $commission * $current_amount;
}
if ($current_date > $last_payout) {
$last_payout = $current_date;
}
if ($activity_begin < $current_date && $current_date < $activity_end) { /*v2.5.0c*/
$activity_total += $current_amount;
$activity_commission += $commission * $current_amount;
$activity_total_commission_paid_amount += $current_commission_paid_amount; // EWD
$activity_commission_paid_amount += $current_commission_paid_amount; // EWD
// EWD added 'commission_paid_amount' => $current_commission_paid_amount to the array
array_push( $activity, array('amount' => $current_amount, 'date' => $purchase_date, 'paid' => $current_date, 'commission' => $commission, 'commission_paid_amount' => $current_commission_paid_amount) );
}
} /*v2.5.0a*/
$orders->MoveNext();
}
}
}
}
templates>YOUR TEMPLATES>templates>tpl_referrer_main_default.php
All changes on this file show as <!-- EWD -->.
HTML 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. |
// +----------------------------------------------------------------------+
?>
<div class="centerColumn" id="referrerMainDefault">
<?php
if ($messageStack->size('referrer_main') > 0) echo $messageStack->output('referrer_main'); /*v2.4.0-a*/
if (!$is_logged_in) {
?>
<p id="refMainNeedLogin"><?php echo sprintf(TEXT_PLEASE_LOGIN, zen_href_link(FILENAME_LOGIN, '', 'SSL')); ?></p>
<?php
} else {
if (!$submitted) {
?>
<p id="refMainNotSubmitted"><?php echo sprintf(TEXT_REFERRER_SIGNUP, zen_href_link(FILENAME_REFERRER_SIGNUP, '', 'SSL')); ?></p>
<?php
} else {
if (!$approved) {
?>
<p><?php echo TEXT_REFERRAL_SUBMITTED; ?></p>
<?php
} else {
if ($banned) {
?>
<p><?php echo sprintf(TEXT_REFERRAL_BANNED, zen_href_link(FILENAME_CONTACT_US, '', 'NONSSL')); ?></p>
<?php
} else {
echo zen_draw_form('referral_main', zen_href_link(FILENAME_REFERRER_MAIN, '', 'SSL'), 'get', ''); /*v2.4.0-c*/
?>
<input type="hidden" name="main_page" value="<?php echo FILENAME_REFERRER_MAIN; ?>" />
<div id="refSignupLinks"><?php echo TEXT_ORDERS_PAYMENTS; ?> | <a href="<?php echo zen_href_link(FILENAME_REFERRER_TOOLS, '', 'SSL');?>"><?php echo TEXT_MARKETING_TOOLS; ?></a> | <a href="<?php echo zen_href_link(FILENAME_REFERRER_SIGNUP, 'terms', 'SSL');?>"><?php echo TEXT_REFERRER_TERMS; ?></a></div>
<hr />
<h3><?php echo HEADING_REFERRER_INFO; ?></h3>
<div id="referrerMainInfo" class="table">
<div class="item_outer">
<div class="item c1"><?php echo TEXT_REFERRER_ID; ?></div>
<div class="item c2"><?php echo $referrer->fields['referrer_key']; ?></div>
</div>
<?php //-bof-v2.2.0a ?>
<div class="item_outer">
<div class="item c1"><?php echo TEXT_MY_WEBSITE; ?></div>
<div class="item c2"><?php echo $referrer->fields['referrer_homepage'] . '<a href="' . /*-bof-c-v2.4.0*/ zen_href_link(FILENAME_REFERRER_EDIT, '', 'SSL') /*-eof-c-v2.4.0*/ . '"> ' . zen_image_button(BUTTON_IMAGE_EDIT_SMALL, BUTTON_EDIT_SMALL_ALT) . '</a>';; ?></div>
</div>
<?php //-eof-v2.2.0a ?>
<div class="item_outer">
<div class="item c1"><?php echo TEXT_LAST_PAYMENT_MADE; ?></div>
<div class="item c2"><?php echo ($last_payout == 0) ? TEXT_NO_PAYMENTS : date("F j, Y", $last_payout); /*v2.5.0c*/ ?></div>
</div>
<div class="item_outer">
<div class="item c1"><?php echo TEXT_COMMISSION_RATE; ?></div>
<div class="item c2"><?php printf("%u%%", 100 * $referrer->fields['referrer_commission']); ?></div>
</div>
</div>
<br />
<hr />
<h3><?php echo TEXT_SALES_SUMMARY; ?></h3>
<div id="referrerMainSummary" class="table">
<div class="item_outer">
<div class="item c1"><?php echo TEXT_CURRENT_SALES; ?></div>
<div class="item c2"><?php echo $currencies->format($unpaid_total); ?></div>
</div>
<div class="item_outer">
<div class="item c1"><?php echo TEXT_UNPAID_COMMISSION; ?></div>
<div class="item c2"><?php echo $currencies->format($unpaid_commission, 2); ?></div>
</div>
<div class="item_outer">
<div class="item c1"><?php echo TEXT_YTD_SALES; ?></div>
<div class="item c2"><?php echo $currencies->format($yearly_total, 2); ?></div>
</div>
<div class="item_outer">
<div class="item c1"><?php echo TEXT_YTD_COMMISSION; ?></div>
<div class="item c2"><?php echo $currencies->format($yearly_commission, 2); ?></div>
</div>
</div>
<br />
<hr />
<h3 class="back"><?php echo TEXT_ACTIVITY; ?></h3>
<div class="forward" style="margin-top: 12px;">
<?php echo TEXT_FROM; ?>
<input type="hidden" name="start" value="<?php echo $activity_begin; ?>" />
<select onchange="document.referral_main.start.value = this.options[this.selectedIndex].value; document.referral_main.submit();">
<?php
$begin = getdate($activity_begin);
$end = getdate($activity_end);
$today = getdate();
$bound = ( $begin['year'] == $today['year'] ) ? $today['mon'] : 12;
for( $i = 1; $i <= $bound; ++$i ) {
printf('<option value="%u"%s>%s</option>' . "\n", mktime(0, 0, 0, $i, 1, $begin['year']), ($i == $begin['mon']) ? ' selected="selected"' : '', date ('F', mktime(0,0,0, $i)));
}
?>
</select>
<select onchange="document.referral_main.start.value = this.options[this.selectedIndex].value; document.referral_main.submit();">
<?php
for ($i = $today['year'] - 9; $i <= $today['year']; $i++) {
printf('<option value="%u"%s>%s</option>' ."\n", mktime(0, 0, 0, $begin['mon'], 1, $i), (($i == $begin['year']) ? ' selected="selected"' : ''), date( "Y", mktime(0,0,0, $begin['mon'], 1, $i)));
}
?>
</select>
<?php echo TEXT_TO; ?>
<input type="hidden" name="end" value="<?php echo $activity_end; ?>" />
<select onchange="document.referral_main.end.value = this.options[this.selectedIndex].value; document.referral_main.submit();">
<?php
$bound = ( $end['year'] == $today['year'] ) ? $today['mon'] : 12;
for( $i = 1; $i <= $bound; ++$i ) {
printf('<option value="%u"%s>%s</option>' . "\n", mktime(0, 0, 0, $i + 1, 0, $end['year']), (($i == $end['mon']) ? ' selected="selected"' : ''), date('F', mktime(0,0,0, $i)));
}
?>
</select>
<select onchange="document.referral_main.end.value = this.options[this.selectedIndex].value; document.referral_main.submit();">
<?php
for( $i = $begin['year']; $i <= $today['year']; ++$i) {
printf('<option value="%u"%s>%s</option>' . "\n", mktime(0, 0, 0, $end['mon'] + 1, 0, $i), (($i == $end['year'] ) ? ' selected="selected"' : ''), date('Y', mktime(0,0,0, $end['mon'] + 1, 0, $i)));
}
?>
</select>
</div>
<br class="clearBoth" />
<div id="referrerMainHistory" class="table">
<div class="head_outer">
<div class="thead c1"><?php echo HEADING_PURCHASE_DATE; ?></div>
<div class="thead c2"><?php echo HEADING_AMOUNT; ?></div>
<div class="thead c1"><?php echo HEADING_COMMISSION_RATE; ?></div>
<div class="thead c2"><?php echo HEADING_AMOUNT; ?></div>
<!-- BOF EWD -->
<div class="thead c2"><?php echo HEADING_COMMISSION; ?></div>
<!-- EOF EWD -->
<div class="thead c1"><?php echo HEADING_COMMISSION_PAY_DATE; ?></div>
</div>
<?php
$toggle = false;
foreach ($activity as $entry) {
$nice_date = ($entry['paid'] == 0) ? TEXT_UNPAID : date('F j, Y', $entry['paid']); /*v2.5.0c*/
?>
<div class="item_outer <?php echo ($toggle) ? 'odd' : 'even'; ?>">
<div class="item c1a"><?php echo date('F j, Y', $entry['date']); ?></div>
<div class="item c2"><?php echo $currencies->format($entry['amount']); ?></div>
<div class="item c3"><?php echo number_format($entry['commission'] * 100, 0) . '%'; ?></div>
<div class="item c4"><?php echo $currencies->format($entry['commission'] * $entry['amount']); ?></div>
<!-- BOF EWD -->
<div class="item c4"><?php echo $currencies->format($entry['commission_paid_amount']); ?></div>
<!-- EOF EWD -->
<div class="item c5"><?php echo $nice_date; ?></div>
</div>
<?php
$toggle = !$toggle;
}
?>
<div class="item_outer totals">
<div class="item c1"><?php echo HEADING_TOTALS; ?></div>
<div class="item c2"><?php echo $currencies->format($activity_total); ?></div>
<div class="item c3"><?php echo ' '; ?></div>
<div class="item c4"><?php echo $currencies->format($activity_commission); ?></div>
<!-- BOF EWD -->
<div class="item c4"><?php echo $currencies->format($activity_commission_paid_amount); ?></div>
<!-- EOF EWD -->
<div class="item c5"><?php echo ' '; ?></div>
</div>
</div>
</form>
<?php
} // Signed in, submitted, approved and not banned
} // Signed in, submitted but not approved
if (!$approved || $banned) {
?>
<div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div>
<?php
}
} // Signed in but not submitted
} // Signed in
?>
</div>
There are no changes on the language file, just used HEADING_COMMISSION which was already on the file.
Hope this helps someone else.
And thanks Lat9 for the quick reply! =)
Ouch, that's not very pretty! My current plan for this display issue is, for any commissions that were manually-overridden, to display a (*) next to the commission amount and include a note below the commissions-paid table that reads:
Any suggestions/improvements would be greatly appreciated!Code:(*) This commission value was modified by the store owner based on a change to the order.
** Update **
Perhaps the right solution is a combination of mvstudio's posting (showing both calculated and paid) along with a notation when they're different to let the customer know that the store knows that they're different?
Ouch, that's not very pretty! LOL! oookkkk!!!! :huh:
What we did was add the coding that was needed to display the extra column using the original files provided, nothing more. My apologies for asking the how to, without taking a look at the files first. I thought it could solve the problem for somebody else, looking for the same thing, so that's why I shared. Any extras or styling is up to the store owner, I think. We didn't like the original layout of the page, so ours was customized to match our stores, and we took all those divisions out and replaced them for tables instead. We also added a note to the page that explains the reason for any discrepancy in commissions as established in our Terms, which is what you were referring to.
This is what ours tpl_referrer_main_default.php page looks like
https://www.byvalenti.com/images/snapaffiliate1.jpg
For anyone looking to style the page like ours here is the code for the tpl_referrer_main_default.php
HTML 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. |
// +----------------------------------------------------------------------+
?>
<div class="centerColumn" id="referrerMainDefault">
<h1 id="affiliateMain"><?php echo HEADING_TITLE; ?></h1>
<?php
if ($messageStack->size('referrer_main') > 0) echo $messageStack->output('referrer_main'); /*v2.4.0-a*/
if (!$is_logged_in) {
?>
<p id="refMainNeedLogin"><?php echo sprintf(TEXT_PLEASE_LOGIN, zen_href_link(FILENAME_LOGIN, '', 'SSL')); ?></p>
<?php
} else {
if (!$submitted) {
?>
<p id="refMainNotSubmitted"><?php echo sprintf(TEXT_REFERRER_SIGNUP, zen_href_link(FILENAME_REFERRER_SIGNUP, '', 'SSL')); ?></p>
<?php
} else {
if (!$approved) {
?>
<p><?php echo TEXT_REFERRAL_SUBMITTED; ?></p>
<?php
} else {
if ($banned) {
?>
<p><?php echo sprintf(TEXT_REFERRAL_BANNED, zen_href_link(FILENAME_CONTACT_US, '', 'NONSSL')); ?></p>
<?php
} else {
echo zen_draw_form('referral_main', zen_href_link(FILENAME_REFERRER_MAIN, '', 'SSL'), 'get', ''); /*v2.4.0-c*/
?>
<input type="hidden" name="main_page" value="<?php echo FILENAME_REFERRER_MAIN; ?>" />
<div id="refSignupLinks">
<h3><?php echo TEXT_ORDERS_PAYMENTS; ?> | <a href="<?php echo zen_href_link(FILENAME_REFERRER_TOOLS, '', 'SSL');?>"><?php echo TEXT_MARKETING_TOOLS; ?></a> | <a href="<?php echo zen_href_link(FILENAME_REFERRER_SIGNUP, 'terms', 'SSL');?>"><?php echo TEXT_REFERRER_TERMS; ?></a></h3>
</div>
<hr />
<h3><?php echo HEADING_REFERRER_INFO; ?></h3>
<div id="referrerMainInfo" class="table">
<div class="item_outer">
<div class="item c1"><?php echo TEXT_REFERRER_ID; ?></div>
<div class="item c2"><?php echo $referrer->fields['referrer_key']; ?></div>
</div>
<?php //-bof-v2.2.0a ?>
<div class="item_outer">
<div class="item c1"><?php echo TEXT_MY_WEBSITE; ?></div>
<div class="item c2"><?php echo $referrer->fields['referrer_homepage'] . '<br /><a href="' . /*-bof-c-v2.4.0*/ zen_href_link(FILENAME_REFERRER_EDIT, '', 'SSL') /*-eof-c-v2.4.0*/ . '">' . zen_image_button(BUTTON_IMAGE_EDIT_SMALL, BUTTON_EDIT_SMALL_ALT) . '</a> '; ?></div>
</div>
<?php //-eof-v2.2.0a ?>
<div class="item_outer">
<div class="item c1"><?php echo TEXT_LAST_PAYMENT_MADE; ?></div>
<div class="item c2"><?php echo ($last_payout == 0) ? TEXT_NO_PAYMENTS : date("F j, Y", $last_payout); /*v2.5.0c*/ ?></div>
</div>
<div class="item_outer">
<div class="item c1"><?php echo TEXT_COMMISSION_RATE; ?></div>
<div class="item c2"><?php printf("%u%%", 100 * $referrer->fields['referrer_commission']); ?></div>
</div>
</div>
<br />
<hr />
<h3><?php echo TEXT_SALES_SUMMARY; ?></h3>
<div id="referrerMainSummary" class="table">
<div class="item_outer">
<div class="item c1"><?php echo TEXT_CURRENT_SALES; ?></div>
<div class="item c2"><?php echo $currencies->format($unpaid_total); ?></div>
</div>
<div class="item_outer">
<div class="item c1"><?php echo TEXT_UNPAID_COMMISSION; ?></div>
<div class="item c2"><?php echo $currencies->format($unpaid_commission, 2); ?></div>
</div>
<div class="item_outer">
<div class="item c1"><?php echo TEXT_YTD_SALES; ?></div>
<div class="item c2"><?php echo $currencies->format($yearly_total, 2); ?></div>
</div>
<div class="item_outer">
<div class="item c1"><?php echo TEXT_YTD_COMMISSION; ?></div>
<div class="item c2"><?php echo $currencies->format($yearly_commission, 2); ?></div>
</div>
</div>
<br />
<hr />
<h3 class="back"><?php echo TEXT_ACTIVITY; ?></h3>
<div class="forward" style="margin-top: 12px;">
<?php echo TEXT_FROM; ?>
<input type="hidden" name="start" value="<?php echo $activity_begin; ?>" />
<select onchange="document.referral_main.start.value = this.options[this.selectedIndex].value; document.referral_main.submit();">
<?php
$begin = getdate($activity_begin);
$end = getdate($activity_end);
$today = getdate();
$bound = ( $begin['year'] == $today['year'] ) ? $today['mon'] : 12;
for( $i = 1; $i <= $bound; ++$i ) {
printf('<option value="%u"%s>%s</option>' . "\n", mktime(0, 0, 0, $i, 1, $begin['year']), ($i == $begin['mon']) ? ' selected="selected"' : '', date ('F', mktime(0,0,0, $i)));
}
?>
</select>
<select onchange="document.referral_main.start.value = this.options[this.selectedIndex].value; document.referral_main.submit();">
<?php
for ($i = $today['year'] - 9; $i <= $today['year']; $i++) {
printf('<option value="%u"%s>%s</option>' ."\n", mktime(0, 0, 0, $begin['mon'], 1, $i), (($i == $begin['year']) ? ' selected="selected"' : ''), date( "Y", mktime(0,0,0, $begin['mon'], 1, $i)));
}
?>
</select>
<?php echo TEXT_TO; ?>
<input type="hidden" name="end" value="<?php echo $activity_end; ?>" />
<select onchange="document.referral_main.end.value = this.options[this.selectedIndex].value; document.referral_main.submit();">
<?php
$bound = ( $end['year'] == $today['year'] ) ? $today['mon'] : 12;
for( $i = 1; $i <= $bound; ++$i ) {
printf('<option value="%u"%s>%s</option>' . "\n", mktime(0, 0, 0, $i + 1, 0, $end['year']), (($i == $end['mon']) ? ' selected="selected"' : ''), date('F', mktime(0,0,0, $i)));
}
?>
</select>
<select onchange="document.referral_main.end.value = this.options[this.selectedIndex].value; document.referral_main.submit();">
<?php
for( $i = $begin['year']; $i <= $today['year']; ++$i) {
printf('<option value="%u"%s>%s</option>' . "\n", mktime(0, 0, 0, $end['mon'] + 1, 0, $i), (($i == $end['year'] ) ? ' selected="selected"' : ''), date('Y', mktime(0,0,0, $end['mon'] + 1, 0, $i)));
}
?>
</select>
</div>
<br class="clearBoth" />
<br class="clearBoth" />
<table style="width: 100%">
<tr>
<td class="thead c1" style="width:16.6%;"><?php echo HEADING_PURCHASE_DATE; ?></td>
<td class="thead c1" style="width:16.6%;"><?php echo HEADING_AMOUNT; ?></td>
<td class="thead c1" style="width:16.6%;"><?php echo HEADING_COMMISSION_RATE; ?></td>
<td class="thead c1" style="width:16.6%;"><?php echo HEADING_AMOUNT_COMMISSION; ?></td>
<td class="thead c1" style="width:16.6%;"><?php echo HEADING_COMMISSION; ?></td>
<td class="thead c1" style="width:16.7%;"><?php echo HEADING_COMMISSION_PAY_DATE; ?></td>
</tr>
<?php
$toggle = false;
foreach ($activity as $entry) {
$nice_date = ($entry['paid'] == 0) ? TEXT_UNPAID : date('F j, Y', $entry['paid']); /*v2.5.0c*/
?>
<tr class="item_outer <?php echo ($toggle) ? 'odd' : 'even'; ?>">
<td class="item c1a"><?php echo date('F j, Y', $entry['date']); ?></td>
<td class="item c2"><?php echo $currencies->format($entry['amount']); ?></td>
<td class="item c3"><?php echo number_format($entry['commission'] * 100, 0) . '%'; ?></td>
<td class="item c4"><?php echo $currencies->format($entry['commission'] * $entry['amount']); ?></td>
<td class="item c4"><?php echo $currencies->format($entry['commission_paid_amount']); ?></td>
<td class="item c5"><?php echo $nice_date; ?></td>
</tr>
<?php
$toggle = !$toggle;
}
?>
<tr class="item_outer totals">
<td class="item c1"><?php echo HEADING_TOTALS; ?></td>
<td class="item c2"><?php echo $currencies->format($activity_total); ?></td>
<td class="item c3"><?php echo ' '; ?></td>
<td class="item c4"><?php echo $currencies->format($activity_commission); ?></td>
<td class="item c4"><?php echo $currencies->format($activity_commission_paid_amount); ?></td>
<td class="item c5"><?php echo ' '; ?></td>
</tr>
</table>
</form>
<br class="clearBoth" />
<p><?php echo TEXT_COMMISSION_PAID; ?></p>
<br class="clearBoth" />
<div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div>
<br class="clearBoth" />
<?php
} // Signed in, submitted, approved and not banned
} // Signed in, submitted but not approved
if (!$approved || $banned) {
?>
<div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div>
<?php
}
} // Signed in but not submitted
} // Signed in
?>
</div>
On the language>english>YOUR TEMPLATE>referrer_main.php:
Replace:
For:HTML Code:define('HEADING_COMMISSION', 'Commission');
And Add:HTML Code:define('HEADING_COMMISSION', '*Commission Total');
HTML Code:define('TEXT_COMMISSION_PAID', '<strong>*Commission Total</strong> amounts, include any refunds or returns that have being deducted from the final commission amount. For more information on how
commissions are calculated please visit our <a href="index.php?main_page=referrer_signup&terms">Affiliate Terms & Conditions".');
Hope this is a little bit better =)
My ouch! was on the plugin's current output, not your suggested changes!:shocking:
I'll incorporate your changes into the next version of SNAP ... thanks for the share.
I've submitted v2.7.2 to the Plugins; it will be available for download one reviewed:
BUGFIX: Previously missing /images/referrers directory now included
BUGFIX: Correct processing on referrers_main page (make a distinction between calculated and paid commissions).
Thanks (again) to mvstudio for the report and the suggested correction!
LOL!! got it! :D
Glad I was able to help! :smile:
v2.7.2 is now available for download in the Plugins ...
Great Plug-in. I'm trying to add multiple banners in the same size but different color variations. I'm not sure how I should name them. I have one of each size uploaded and working, however I want to add a blue version, magenta version, etc of the same size. I tried naming them "ref.160.600.blue.png" and entered 160,600,blue,png/ in Admin... but its not working.
Any help or suggestions appreciated.
Also, where can I enter the image alt text???
Thanks for a great plugin. My client wants the referrers to land on an other page then the homepage. Is it possible to change the URL of the page for all referrals? I've been through most of the php but can't find it. I know i can change it with the deeplink generator but my clients expects a vast amount of affiliates so preffers it automated.
Are you saying that you want a different landing page if the page access was made with the referrer parameter set? If so, you could make your modification to /includes/init_includes/init_snap.php to perform your custom redirect.
Code:<?php
/*-----
** Initialize the session's referrer key.
*/
//-bof-v2.1.2a
if (!defined('SNAP_COOKIE_LIFETIME')) {
define ('SNAP_COOKIE_LIFETIME', 60*60*24*365);
}
//-eof-v2.1.2a
if( isset($_GET['referrer']) ) {
if( strpos($_GET['referrer'], SNAP_KEY_PREFIX) === 0 ) {
if( strlen($_GET['referrer']) < 24 ) {
$_SESSION['referrer_key'] = $_GET['referrer'];
setcookie("referrer_key", $_GET['referrer'], time() + SNAP_COOKIE_LIFETIME, "/"); /*v2.1.2c*/
//- Insert your custom redirect here
}
}
} else if( $_COOKIE['referrer_key'] ) {
if( strpos($_COOKIE['referrer_key'], SNAP_KEY_PREFIX) === 0 ) {
if( strlen($_COOKIE['referrer_key']) < 24 ) {
$_SESSION['referrer_key'] = $_COOKIE['referrer_key'];
}
}
}
Thanks, but what should I put there? Just to be clear: all I want is a different landing URL for all referrers, thanks in advance
Are you planning on creating a brand-new page for the landing or are you going to use an EZ-Page?
preferably a brand-new page
So, what you'd insert at the spot I indicated is
where you've previously setCode:zen_redirect (zen_href_link (FILENAME_NEW_PAGE_NAME));
To create a new page is pretty easy, just follow the example provided by the "About Us" plugin.Code:define ('FILENAME_NEW_PAGE_NAME', 'new_page_name');
works ! Thanks a million
Excellent! I'm glad you got it working.
I've submitted v2.7.3 to the Plugins for review. This update adds the home-page link to the admin's Customers->Referrers page, making it possible for the admin to copy/paste the information.
Is there anyway to give people a choice of either X dollars in cash or Y dollars in credit for our site?
v2.7.3 is now available for download.
v2.8.0 is now available from the Plugins area. The update provides downwardly-compatible changes required for Zen Cart v1.5.4.
Hi was wondering if someone could help me (no idea how it is built might be impossible) limit certain coupon codes should not work if the order is an affiliate order?
TIA
There's a session variable set if the current customer has entered your store using an affiliate link, so you'd bracket your custom coupon-limiting code with:
Code:if (isset($_SESSION['referrer_key']) && zen_not_null($_SESSION['referrer_key'])) {
<your custom code here>
}
I have an odd issue. We installed v2.7.1 in a new store running Zen 1.5.3. We imported a number of affiliates from a different system, synced affiliate codes, and launched and all seemed well.
We just had our first new affiliate sign-up. We got their info, they were assigned a number, but when we go to approve them the screen refreshes and the first affiliate in our list is toggled to unapproved.
To trace the flow:
List affiliates, find an unapproved one. Click the row to bring up the record: ( I am wrapping urls in code to avoid munging, I hope...)
Correct referrer record displays. Click the Approve button. Code tags have post info from request:Code:https://www.naturalpetrx.com/XXXXXX/referrers.php?page=2&referrer=938&mode=details
Screen refreshes to details of first referrer in list, and they are now marked Not approved. They are not referrer 938, that was the original referrer.Code:commission 35
mode
mode Approve
referrer 938
securityToken a4812229a2be4e95f4d661686bdc1b36
Has anybody seen something similar, or can anyone point me in the right direction?
Hmm, two mode variables?
I'll need to investigate further.Code:commission 35
mode
mode Approve
referrer 938
securityToken a4812229a2be4e95f4d661686bdc1b36
I'm not seeing this behavior on SNAP v2.7.3 on Zen Cart v1.5.1.
What method did you use to import/sync those affiliate codes?
hi Cindy,
Maybe a stupid question but i'm struggling with the sign_up procedure. Am I correct in understanding that the only way to sign up as an affiliate is by entering the URL for wich the customer already has to be registered and signed in?
Unless I didn't set up the plugin correctly this means, the affiliate-to-be creates an account (regular ZC account) then has to click on "Our Partner Programm" in the informationbox again to get to the sign_up form (the URL that is). This seems a complicated way to sign up. And rather hard to explain to a wannabee Affiliate. Isn't there some kind of shortcut? In my case just simply filling out a form and getting a notice that a Affiliates needs approval would be sufficient.
many thanks in advance. Sander
As the code/process sits today, an affiliate to your store needs to have an account with your store -- that's how the admin side of the processing maps the affiliates's "code" to a person.
That said, you could look at also installing the "Encrypted Master Password" plugin. That would allow you (the Zen Cart admin) to create the account for the customer/affiliate and go through the "difficult" steps of requesting an affiliate link.
Actually, it occurred to me that you don't need to go the EMP route unless the affiliate already has a customer account. If the affiliate is a "fresh" customer, all you need from him/her is their contact information (so you can fill out your store's create-account form) and their desired initial password (ditto).
Then, you just create their account and request an affiliate code on their behalf.
I have a question. First off - thanks for this Haddon - it is great!
I have several images that are the same size - how can I add these short of changing the filetype?
Example, if I have 2 images that are 250px 250px and are both jpg, they would be added like this:
/250,250,jpg/250,250,jpg/ then I would have 2 images with the same name. Is there a way to do this that I am missing?
I've just discovered an issue with SNAP Affiliates, where performing any task (Accept, Ban, Pay, etc.) from a referrer's 'details' view -- where that referrer's information is not on the first page of the overall referrers listing -- will have "issues".
The work-around, while I'm determining the best solution, is to set your Configuration->Affiliate Program->Affiliate Display Count to a large number (like 1000, or something much larger than your current count of referrers) so that your referrers' listing will result in a single page of display.
I'll post back here once the solution has been uploaded to the plugins.
v2.8.2 is now available for download ...
v3.0.0 has just been submitted for review; this version includes the capability for your referrers to choose their form of commission payment! Built-in payment choices are "Check/Money-order" and (optionally) PayPal.
v3.0.0 is now available for download ...
I've been notified (thanks, bumba000) of a minor XSS flaw that has existed within the Snap Affiliates code from the get-go. v3.0.1 contains this correction and is now available for download from the plugins area (http://www.zen-cart.com/downloads.php?do=file&id=1635).
All changes associated with this update are marked with //-v3.0.1, making it easier for you to find and correct the issue. For those of you using a version prior to v3.0.0, you only need to focus on the changes in the header_php.php files on the referrer_edit and referrer_signup pages.
Can one do deep linking with Snap?
If it were me, I'd create yet-another observer to handle your specifics (disallowing certain coupon codes for orders that will be giving an affiliate commission).
Please start a new thread (outside of SNAP Affiliate's support thread) and I'll give you a couple of pointers.
Posted here TIA
I just submitted v3.0.2 to the plugins. This version corrects the handling of CR/LF sequences in the status-update messages; incorporates osh_updated_by v1.2.1.