Active
Project:
Ubercart Affiliate v2
Version:
6.x-2.6
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Sep 2011 at 08:42 UTC
Updated:
27 Sep 2011 at 06:18 UTC
Hello,
I just realized that there is quite big problem with using of $_SESSION['affiliate'] for user tracking. As you know in ubercart you can set option to create accounts for all anonymous users when they complete checkout. But currently those accounts are not connected with affiliate ID because Drupal create it under different php session when receiving paypal confirmation.
For this case I propose to use affiliate ID from uc_affiliate2_orders table. Just extract it based on order ID.
I talking about this code now:
function uc_affiliate2_user($op, &$edit, &$account, $category = NULL) {
global $user;
switch ($op) {
case 'insert':
// update user count for affiliate and associate user with affiliate
$aff = $_SESSION['affiliate'];
if ($aff) {
db_query('INSERT INTO {uc_affiliate2_users} (aid, uid) VALUES (%d, %d)', $aff, $account->uid);
$message = t('User !name referred by user id !affiliate', array('!name' => theme('username', $account),
'!affiliate' => theme('placeholder', $aff)
)
);
watchdog('user', $message);
}
break;
What do you think about that?
Thanks,
Vadim
Comments
Comment #1
vadim.eremeev commentedI can suggest to change it into something like:
Comment #2
vadim.eremeev commentedEven we can optimize query a bit and also need to make primary_email as index in uc_orders table