http://cnedelcu.blogspot.co.uk/2010/12/ ... spire.html
... I opted to update it to suit my needs and also bring it up to speed with version 6.1.x
Features over the original:
- Fixed to work with 6.1.1
- Bug fix: commission details record correct rates
- Bug fix: removed max EOL formatting that caused all sorts of problems with the original affiliate.php file!
- Added: Spread of commission rates based on order value instead of one rate fits all
- Added: Affiliate access/rewards only available to customer accounts who are members of a specified customer group
- Updated: Heavily edited the original affiliate pitch to suit my requirements (ie: no pressure sales) and include T&C items
- Added: Removes commission from affiliate, in full, if the order status is changed to refunded or cancelled
- Logs affiliate sales to log... There is no admin panel/indicators to show which are affiliate sales (TODO?)
Note: This is not for commercial redistribution or reuse including in ISC rip offs (yes, I'm referring to you cartaddons, Mr_isc, etc...)
It's also NOT supported... Use entirely at your own risk...
The modifications/changes to the original instructions are:
SQL:
Code: Select all
ALTER TABLE `isc_orders` ADD `ordaffiliate` INT( 11 ) NOT NULL DEFAULT '0' COMMENT 'ID of the affiliate who got the sale'
Open: init.php
At end of file, insert
Code: Select all
require_once(ISC_BASE_PATH . '/lib/affiliate.php'); //MOD Affiliate
Open: class.checkout.php
Find:
Code: Select all
$newOrder = array(
'orderpaymentmodule' => $providerId,
'ordcurrencyid' => $selectedCurrency['currencyid'],
'ordcurrencyexchangerate' => $selectedCurrency['currencyexchangerate'],
'ordipaddress' => getIp(),
'ordstatus' => $orderStatus,
Code: Select all
'ordaffiliate' => isset($_COOKIE["ref"]) ? intval($_COOKIE["ref"]) : "0", //MOD Affiliate
Open: /lib/orders.php
Find:
Code: Select all
if (OrderIsComplete($status)) {
$updatedOrder['orddateshipped'] = time();
}
Code: Select all
//MOD Affiliate
if (OrderIsComplete($status)) {
$updatedOrder['orddateshipped'] = time();
// Give affiliate credit!
if (!empty($order['ordaffiliate'])) {
require_once("affiliate.php");
GiveAffiliateCredit($order);
}
}
//MOD END Affiliate
Find:
Code: Select all
// Marked as refunded or cancelled, need to cancel the gift certificates in this order too if there are any
$updatedCertificates = array(
"giftcertstatus" => 3
);
$GLOBALS['ISC_CLASS_DB']->UpdateQuery("gift_certificates", $updatedCertificates, "giftcertorderid='" . $GLOBALS['ISC_CLASS_DB']->Quote($orderId) . "'");
Code: Select all
//MOD Affiliate
// Remove affiliate credit!
if (!empty($order['ordaffiliate'])) {
require_once("affiliate.php");
GiveAffiliateCredit($order, true); // Cancel the credit
}
//MOD END Affiliate
Open: class.account.php
Find:
Code: Select all
case "reorder": {
$this->DoReorder();
break;
}
Code: Select all
case "affiliate": {
DisplayAffiliateAccountPage();
$this->MyAccountPage();
break;
}
Code: Select all
$GLOBALS['ISC_LANG']['RecentlyViewedItemsDescription'] = sprintf(GetLang('RecentlyViewedItemsDescription'), $GLOBALS['StoreName']);
Code: Select all
//MOD Affiliate
$GLOBALS['AFFILIATE_LINK'] = "<li><a href='account.php?action=affiliate#affiliate' title='Manage my affiliate account'>Affiliate account</a> - Manage your affiliate account and view your sales</li>";
//MOD END Affiliate
Open: /templates/[theme]/account.html
Find:
Code: Select all
<li><a href="%%GLOBAL_ShopPath%%/account.php?action=recent_items">%%LNG_RecentlyViewedItems%%</a> - %%LNG_RecentlyViewedItemsDescription%%</li>
</ul>
Code: Select all
<li><a href="%%GLOBAL_ShopPath%%/account.php?action=recent_items">%%LNG_RecentlyViewedItems%%</a> - %%LNG_RecentlyViewedItemsDescription%%</li>
%%GLOBAL_AFFILIATE_LINK%%
</ul>
%%GLOBAL_AFFILIATE_LINK%%