Snap Affiliates v2.0 for v1.5.0 and later
I'll be submitting this plugin to the Plugins area shortly, based on the similar-named plugin for the v1.3.x series (http://www.zen-cart.com/showthread.p...nap-affiliates). This version (v2.0.0) will run only on Zen Cart v1.5.0 and later and includes the following additional changes:
- No core-file overwrites!
- Moved all language-specific text to the language file, both catalog and admin.
- Moved $_SESSION['referrer'] initialization to /includes/init_includes/init_snap.php and /includes/auto_loaders/config.snap.php; /includes/application_top.php is no longer changed by this plugin.
- Moved changes to /includes/database_tables.php and /includes/filenames.php to /includes/extra_datafiles/snap_file_database_names.php; those core files are no longer changed by this plugin.
- Moved order-related commission updates to observer-class code; /includes/classes/order.php is no longer changed by this plugin.
- Moved hard-coded referral terms to a separate language define file (/includes/languages/english/html_includes/define_referrer_terms.php and /includes/languages/english/html_includes/YOUR_TEMPLATE/define_referrer_terms.php).
- Moved /snapconfigure.php file initializations to your admin's Configuration->Affiliate Program.
- Database initialization is now performed automatically via your Zen Cart admin.
- Added "Information" sidebox link, controlled via admin configuration switch.
- Affiliate banner images are now specified via your admin.
- Commissions are given only to affiliate accounts that are previously authorized and not banned. An affiliate customer can no longer get a discount by using their own affiliate code.
- Using Zen Cart default email template for all emails sent; no longer require additional templates.
Once I have the download location, I'll post it back here; it's kind of a chicken/egg thing between the plugin's download link and it's support-thread!
Re: Snap Affiliates v2.0 for Zen Cart v1.5.0 and later
Oh Cindy you absolute star! Thank you very much. I didn't expect you to do it so soon, were you bored? :wink:
Re: Snap Affiliates v2.0 for Zen Cart v1.5.0 and later
Quote:
Originally Posted by
picandnix
Oh Cindy you absolute star! Thank you very much. I didn't expect you to do it so soon, were you bored? :wink:
Only a bit:smile:
1 Attachment(s)
Re: Snap Affiliates v2.0 for Zen Cart v1.5.0 and later
Ok...
installed on LOCAL copy of store
loaded just fine thank you, but, when going to admin>customers>referrers I don't have an option to enroll customer into affiliate program
Attachment 12058
and I'm getting error log as follows
[05-Mar-2013 21:38:58] PHP Warning: Invalid argument supplied for foreach() in C:\wamp\www\MYSTORE\MYADMIN\referrers.php on line 687
[05-Mar-2013 21:38:58] PHP Stack trace:
[05-Mar-2013 21:38:58] PHP 1. {main}() C:\wamp\www\MYSTORE\MYADMIN\referrers.php:0
Re: Snap Affiliates v2.0 for Zen Cart v1.5.0 and later
Sorry timed out to edit post.
error log is line 514 not 687...
[05-Mar-2013 21:56:30] PHP Warning: Invalid argument supplied for foreach() in C:\wamp\www\MYSITE\MYADMIN\referrers.php on line 514
[05-Mar-2013 21:56:30] PHP Stack trace:
[05-Mar-2013 21:56:30] PHP 1. {main}() C:\wamp\www\MYSITE\MYADMIN\referrers.php:0
Thank you again Lat9 :hug:
Re: Snap Affiliates v2.0 for Zen Cart v1.5.0 and later
Quote:
Originally Posted by
picandnix
Ok...
installed on LOCAL copy of store
loaded just fine thank you, but, when going to admin>customers>referrers I don't have an option to enroll customer into affiliate program
Attachment 12058
Doh! It's the referrers job to APPLY for an affiliate account rather than the admin to award an account isn't it, sorry my mistake.
Re: Snap Affiliates v2.0 for Zen Cart v1.5.0 and later
Quote:
Originally Posted by
picandnix
Sorry timed out to edit post.
error log is line 514 not 687...
[05-Mar-2013 21:56:30] PHP Warning: Invalid argument supplied for foreach() in C:\wamp\www\MYSITE\MYADMIN\referrers.php on line 514
[05-Mar-2013 21:56:30] PHP Stack trace:
[05-Mar-2013 21:56:30] PHP 1. {main}() C:\wamp\www\MYSITE\MYADMIN\referrers.php:0
Thank you again Lat9 :hug:
This one makes more sense (there's no line 687 in the file). There is no provision in the plugin for an administrator to add a referrer; a referrer creates a customer account and signs up themselves. The administrator's job is to approve, ban or pay the referrer.
That said, the "Details" button shouldn't be shown if there are no referrers, so if you make the following change to line 358 of /YOUR_ADMIN/referrers.php that problem (and the subsequent error logs) will be corrected:
Code:
<tr><td class="infoBoxContent"><br /><?php echo ($referrercount > 0) ? ('<a href="' . zen_href_link(FILENAME_REFERRERS, 'referrer=' . $referrers[$selected]['customers_id'] . '&mode=details', 'NONSSL') . '">' . zen_image_button('button_details.gif', IMAGE_DETAILS) . '</a>') : ' '; /*v2.0.1c*/ ?></td></tr>
Re: Snap Affiliates v2.0 for v1.5.0 and later
A possible bug?
once the commission is marked as 'paid' by store admin the affiliate receives an email stating the commission earnings. However in my live test site the email received states my affiliate has received $0.00 even though admin shows that they have been paid $1.00.
Re: Snap Affiliates v2.0 for v1.5.0 and later
Quote:
Originally Posted by
lat9
... Once I have the download location, I'll post it back here ...
It should be in the Plugins area shortly (http://www.zen-cart.com/downloads.php?do=file&id=1635) and you can always download it from my website.
Re: Snap Affiliates v2.0 for v1.5.0 and later
Quote:
Originally Posted by
picandnix
A possible bug?
once the commission is marked as 'paid' by store admin the affiliate receives an email stating the commission earnings. However in my live test site the email received states my affiliate has received $0.00 even though admin shows that they have been paid $1.00.
An absolute bug, darn it! Make this change, starting at line 208 of /YOUR_ADMIN/referrers.php:
Code:
case 'pay':
$query = "UPDATE " . TABLE_COMMISSION . " SET commission_paid = NOW() WHERE commission_paid = '0000-00-00 00:00:00' AND commission_referrer_key = '" . $referrers[$selected]['referrer_key'] . "'";
$result = $db->Execute($query);
$now = date("Y-m-d H:i:s", time());
$commission_paid = $referrers[$selected]['orders_unpaid']; /*v2.0.1a*/
$referrers[$selected]['orders_unpaid'] = 0;
for ($i = 0, $n = count($referrers[$selected]['orders']); $i < $n; $i++) {
if ($referrers[$selected]['orders'][$i]['commission_paid'] == '0000-00-00 00:00:00') {
$referrers[$selected]['orders'][$i]['commission_paid'] = $now;
}
}
send_notification_email (
$referrers[$selected],
EMAIL_SUBJECT_PAID,
sprintf(EMAIL_MESSAGE_PAID_TEXT, $currencies->format(floatval($commission_paid)), zen_catalog_href_link(FILENAME_LOGIN, '', 'SSL'), zen_catalog_href_link(FILENAME_REFERRER_MAIN, '', 'SSL'), zen_catalog_href_link(FILENAME_CONTACT_US, '', 'NONSSL')),
sprintf(EMAIL_MESSAGE_PAID_HTML, $currencies->format(floatval($commission_paid)), zen_catalog_href_link(FILENAME_LOGIN, '', 'SSL'), zen_catalog_href_link(FILENAME_REFERRER_MAIN, '', 'SSL'), zen_catalog_href_link(FILENAME_CONTACT_US, '', 'NONSSL'))); /*v2.0.1c*/
break;
But wait ... there's more! :( Update /YOUR_ADMIN/extra_datafiles/referrers_filenames.php:
Code:
<?php
/*
** Database tables and filenames associated with the Snap Affiliates v2.0 plugin.
**
** NOTE: Admin-side definitions!
*/
define('TABLE_REFERRERS', DB_PREFIX . 'referrers');
define('TABLE_COMMISSION', DB_PREFIX . 'commission');
define('FILENAME_REFERRERS', 'referrers');
define('FILENAME_REFERRER_MAIN', 'referrer_main'); /*v2.0.1a*/
and make the following change starting at line 82 of /YOUR_ADMIN/languages/english/referrers.php:
Code:
define('EMAIL_MESSAGE_PAID_HTML', 'A commission payment was recently made for your ' . STORE_NAME . ' referral account. Your total earnings this period were <strong>%1$s</strong>.<br /><br />To view your complete order history, you can login (<a href="%2$s">%2$s</a>) and view your referrer statistics (<a href="%3$s">%3$s</a>). If you have any questions, don\'t hesitate to contact us: <a href="%4$s">%4$s</a>.<br /><br />Sincerely,<br /><br />' . STORE_OWNER); /*v2.0.1c*/
define('EMAIL_MESSAGE_PAID_TEXT', 'A commission payment was recently made for your ' . STORE_NAME . ' referral account. Your total earnings this period were %1$s.' . "\n\n" . 'To view your complete order history, you can login (%2$s) and view your referrer statistics (%3$s). If you have any questions, don\'t hesitate to contact us using this link: %4$s.' . "\n\nSincerely,\n\n" . STORE_OWNER); /*v2.0.1c*/