Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#26 06-24-2004 11:59:53

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19876
Website

Re: Affiliate System Levels Bug?

I think the problem stems from the fact that you have 'S12' listed as a sub-affiliate for 'S13'.  Remove that and I think this will work properly.  'S13' doesn't have any sub-affiliates and shouldn't have an entry there.  The logic is circular for traversing the affiliate membership tree - so associating 'S13' with 'S13' on the 'S13' entry would have closed the loop of the circular logic and only returned those two.


Nick Hendler

Offline

 

#27 06-24-2004 15:50:43

TheThinker
Member
From: Salt Lake City, Utah
Registered: 06-16-2004
Posts: 535
Website

Re: Affiliate System Levels Bug?

webmaster,06/24/2004 11:59:53 AM wrote:

I think the problem stems from the fact that you have 'S12' listed as a sub-affiliate for 'S13'.  Remove that and I think this will work properly.  'S13' doesn't have any sub-affiliates and shouldn't have an entry there.  The logic is circular for traversing the affiliate membership tree - so associating 'S13' with 'S13' on the 'S13' entry would have closed the loop of the circular logic and only returned those two.

Thanks, I missed that.  I don't think this is the problem, though, as I've run this test now probably over 100 times, on two machines, with entirely different affiliate tables.  I see how it could be the problem in the above table, of course, provided I'm using affl=12 or affl=13. 

I'll check this out and let you know.  I finally figured out how to efficiently debug the CCP perl scripts and already have a debugger breakpoint set at this code, so I can find out in a few mins and post back the results.


Regards,
Eric

Offline

 

#28 06-26-2004 03:19:34

TheThinker
Member
From: Salt Lake City, Utah
Registered: 06-16-2004
Posts: 535
Website

Re: Affiliate System Levels Bug?

The problem still occurs.  I debugged the code, and I don't see where there is logic to handle more than 2 levels of affiliates, so I added it myself and now it seems to be working fine.   I put the affiliate commission calculation logic, for secondary affiliates, in a loop that iterates up to 10 times (as per my client's requirements) to pay commissions of 1% each for up to 10 levels.


Regards,
Eric

Offline

 

#29 06-28-2004 16:36:47

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19876
Website

Re: Affiliate System Levels Bug?

Routine: ste_order_conf_updateaff_proc
File: ./cgi-bin/library/modules/ste_order.pl

Code:


$tracking_affiliaterel =~ s/\, /\,/gs;

my @related = split (/\,/, $tracking_affiliaterel);

my $related = "";

foreach $related(@related) {

if ($related ne "") {

$dbins_affiliate_id = database_quote('affacct',$related);

$affiliaterel_sql .= "affacct_id=$dbins_affiliate_id OR ";

} ######### End of if statement.

} ######### End of foreach statement.

if ($affiliaterel_sql ne "") {

chop($affiliaterel_sql);
chop($affiliaterel_sql);
chop($affiliaterel_sql);
chop($affiliaterel_sql);

$sql_statement = "

SELECT affacct_id,affacct_active,affacct_salestd,affacct_commearntd,affacct_typesub,affacct_valuesub
FROM affacct
WHERE $affiliaterel_sql

";

my @affacct = database_call('affacct','SELECT',$sql_statement);

(As written in CCP 5.1)

Pulls all sub-affiliates into an array and does the right thing with each further down in a array loop.  Where did you make your change and are you sure there wasn't a data problem?


Nick Hendler

Offline

 

#30 06-28-2004 17:40:50

TheThinker
Member
From: Salt Lake City, Utah
Registered: 06-16-2004
Posts: 535
Website

Re: Affiliate System Levels Bug?

Nick,

Referencing your above code, yes, I saw that.  I've been debugging thru this exact code, and related code, for days.  This does indeed create a associative array of all affiliates related to the primary affiliate,   Therein lies the problem: My client expects to have 1,000s or even 10,000s of affiliates.  So the (apparently) fallacy in this code is that the affiliates would ALL be entered into the related affiliate field manually. 

For example, let's say my first affiliate is A1.  S/he signs up a single subaffiliate A2, who signs up A3, etc. 

A1 is the parent of A2
A2 is the parent of A3
A3 is the parent of A4
A4 is the parent of A5
A5 is the parent of A6
A6 is the parent of A7
A7 is the parent of A8
etc
A14 is the parent of A15

Now, let's say that customer1 orders, and indicates that his/her order should be credited to A13.  The way this needs to work for my client, and I would think for _all_ multilevel affiliate companies, is that CCP will look up A13, and find that A12 is A13's sponsor.  It would then add A12 to the hash, and repeat the process, finding that A12 was sponsored by A11, etc.  If this loop is not implemented, then I don't see how the affiliate commissions can support more than one or two levels without manual process, which won't work.

With the existing code, the CCP site admin would have to manually enter this entire lineage for  single sub affiliate.  Or am I missing something...

What my client needs is the ability to have CCP automatically determine the parent affiliates for any given affiliate.  So, I fixed this by reversing the related affiliates field to only specify a singe parent affiliate (rather than the child), and then to loop thru the db records until it found all required parent affiliates. 

Can you confirm that my above research is accurate?  And that my approach is valid?

Thanks in advance.


Regards,
Eric

Offline

 

#31 06-28-2004 17:49:59

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19876
Website

Re: Affiliate System Levels Bug?

When an affiliate signs up, if another affiliate referred them (they have the parent's code in their cookie) the sub-affiliate info is written out to the db.  If you are uploading a set of data, you would need to include those strings in the file.


Nick Hendler

Offline

 

#32 06-28-2004 17:57:44

TheThinker
Member
From: Salt Lake City, Utah
Registered: 06-16-2004
Posts: 535
Website

Re: Affiliate System Levels Bug?

Right.  I understand this. 

On your test machine, can you actually try to create 5 levels of affiliates, place an order that should be credited to the lowest level affiliate, and can you confirm that all 5 affiliates get credit?  On my production server, and on a clean install of CCP on an R&D server, this test fails to credit 5 levels; it only results in 2 levels getting credit for the sale.


Regards,
Eric

Offline

 

#33 07-02-2004 12:26:52

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19876
Website

Re: Affiliate System Levels Bug?

Yes, and it worked.  I did notice (forgot as I coded this a long time ago) that the column 'affacct_xaff' has to include all related affiliates as the code does not follow a chain through the table.  In this instance I created five affiliates, numbered 111 ... 555.

Code:


affacct_id,affacct_pass,affacct_active,affacct_salestd,affacct_commearntd,affacct_commpaidtd,affacct_typemain,affacct_valuemain,affacct_typesub,affacct_valuesub,affacct_xaff,affacct_firstname,affacct_lastname,affacct_company,affacct_addressone,affacct_addresstwo,affacct_city,affacct_stateprov,affacct_country,affacct_zip,affacct_rescom,affacct_phone,affacct_fax,affacct_email,affacct_emailsent
111,YlOl,Y,1307.79,26.16,0.00,PCT,10.000,PCT,10.000,"222, 333, 444, 555",Test,1,,Address 1,,City 1,North Carolina,United States,27949,R,5552221111,,webmaster@kryptronic.com,Y
222,YVCm,Y,1307.79,26.16,0.00,PCT,10.000,PCT,10.000,"333, 444, 555",Test,2,,Address 2,,City 2,North Carolina,United States,27949,R,5552221111,,webmaster@kryptronic.com,N
333,YFGn,Y,1307.79,26.16,0.00,PCT,10.000,PCT,10.000,"444, 555",Test,3,,Address 3,,City 3,North Carolina,United States,27949,R,Phone 3,,webmaster@kryptronic.com,N
444,YFGn,Y,1307.79,26.16,0.00,PCT,10.000,PCT,10.000,555,Test,4,,Address 4,,City 4,North Carolina,United States,27949,R,Phone 4,,webmaster@kryptronic.com,N
555,YFGn,Y,1307.79,26.16,0.00,PCT,10.000,PCT,10.000,,Test,5,,Address 5,,City 5,North Carolina,United States,27949,R,Phone 5,,webmaster@kryptronic.com,N

Notice:

111 has sub affiliates "222, 333, 444, 555"
222 has sub affiliates "333, 444, 555"
333 has sub affiliates "444, 555"
444 has sub affiliate "555"
555 has no sub affiliates

This was all done by setting up the affiliate accounts using the front-end and clicking the sub-affiliate sign up links in each account.

I verified all five affiliates got paid the right amount for several orders.


Nick Hendler

Offline

 

#34 07-02-2004 12:52:07

TheThinker
Member
From: Salt Lake City, Utah
Registered: 06-16-2004
Posts: 535
Website

Re: Affiliate System Levels Bug?

webmaster,07/02/2004 12:26:52 PM wrote:

Yes, and it worked.  I did notice (forgot as I coded this a long time ago) that the column 'affacct_xaff' has to include all related affiliates as the code does not follow a chain through the table.  In this instance I created five affiliates, numbered 111 ... 555.

<snip>

This was all done by setting up the affiliate accounts using the front-end and clicking the sub-affiliate sign up links in each account.

I verified all five affiliates got paid the right amount for several orders.

Thank you Nick.  This is the info I was looking for.  From stepping thru the source code, the behavior you describe is consistent with what I was able to derrive from looking at the logic.

I've already modified CCP so that it automatically follows the chains of affiliates upwards, like a SLL (singly linked list), with out requiring that each affiliate be mentioned in the affacct_xaff field.


Regards,
Eric

Offline

 

#35 07-02-2004 13:16:40

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19876
Website

Re: Affiliate System Levels Bug?

Excellent.  Just be careful that the right thing happens if an affiliate account is deleted via admin.  With the way it's set up now (by default I mean), admin routines check a reference table and verify that any references to a deleted affacct_id remaining in that table in the affacct_xaff column are deleted as well.  I'm not sure how the program will react if they're left in there.


Nick Hendler

Offline

 

#36 07-02-2004 13:43:19

TheThinker
Member
From: Salt Lake City, Utah
Registered: 06-16-2004
Posts: 535
Website

Re: Affiliate System Levels Bug?

webmaster,07/02/2004 01:16:40 PM wrote:

Excellent.  Just be careful that the right thing happens if an affiliate account is deleted via admin.  With the way it's set up now (by default I mean), admin routines check a reference table and verify that any references to a deleted affacct_id remaining in that table in the affacct_xaff column are deleted as well.  I'm not sure how the program will react if they're left in there.

Thanks for the tip.  To address this referential integrity issue, I've set up CCP so that an affiliate account can only be made inactive, it can't be deleted.  Same for customers.


Regards,
Eric

Offline

 

#37 10-24-2004 17:16:48

Steven
Member
Registered: 04-21-2004
Posts: 84

Re: Affiliate System Levels Bug?

I don't know if this is related, but I can't get affiliates working correctly on my site.  I never touched any of the affiliate files, and tested this with another clean install of ccp51.

The affiliation account can be created by the user, and it can be activated by myself, but when a sale comes through (which does include the aff code) - NOTHING is credited to the affiliate.  No options are available in the backend to generate anything at all.  I'm puzzled.  Is everyone having this problem??

This is a single top level affiliate.  I thought everything worked out automatically??

Offline

 

#38 10-24-2004 17:25:30

TheThinker
Member
From: Salt Lake City, Utah
Registered: 06-16-2004
Posts: 535
Website

Re: Affiliate System Levels Bug?

Do you have your site set up to credit affiliates as soon as the order is placed?


Regards,
Eric

Offline

 

#39 10-24-2004 17:45:04

Steven
Member
Registered: 04-21-2004
Posts: 84

Re: Affiliate System Levels Bug?

I believe so,
I have Track Affiliates Across sessions selected yes (I have seo mod installed)
Commission calculation method is Realtime when order placed.

one thing I have noticed under 'Manage Online Orders & View Invoices' for any order, is that the 'sale amount' is nill, while the 'Total Amount' has a value.  Why is sale amount nill??

Offline

 

#40 11-10-2004 16:47:14

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19876
Website

Re: Affiliate System Levels Bug?

Check to make sure the Perform Order Updates field is set to Yes for the active payment method you're testing with.  By default (usually with payment methods that aren't realtime) things like inventory and affiliate payments aren't automatically done (because you don't have the cash yet).


Nick Hendler

Offline

 

#41 12-01-2004 10:32:51

thedot
Member
Registered: 05-24-2004
Posts: 162
Website

Re: Affiliate System Levels Bug?

I've been following this discussion,
I just want to finalize a couple of questions I have, if you wouldn't mind?

What exactly is the default for this script, with regard to affiliate levels?

In order to have multiple levels, beyond 2, is there something that has to be done to make that happen?

Offline

 

#42 12-07-2004 11:41:44

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19876
Website

Re: Affiliate System Levels Bug?



What exactly is the default for this script, with regard to affiliate levels?

In order to have multiple levels, beyond 2, is there something that has to be done to make that happen?

(1) There is no default setting.

(2) Affiliates simply have to refer each other using each other's links for signup creating a chain of signups each with their referrer's id.


Nick Hendler

Offline

 

Board footer