Limiting Affiliate Orders

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Limiting Affiliate Orders

Post by michael.p.larsen » Fri Feb 19, 2010 9:37 am

Hello,
I want to only associate an order with an affiliate once. What I mean is this... person X comes to mysite.com/SomeProduct.aspx?afid=1 and they order that product. That order should be associated with that affiliate. But now, if person X orders product Y in a totally NEW order, I do NOT want the affiliate to be associated with that order.
Does that make sense? How do I do this.
I know you can limit the time in DAYS, but it would be handy to set a limit like I mentioned above, or set a limit in MINUTES.

How can I go about doing this?

Thanks!

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Limiting Affiliate Orders

Post by mazhar » Fri Feb 19, 2010 12:11 pm

I guess you are looking for the ability of specifying the affiliate association for only one order for a customer. I believe this could be done with some code in OnePageCheckout. In my opinon CheckingOut event handler of OnePageCheckout would be a nice place to do this stuff. Edit Your ConLIb/OnePageCheckout.ascx.cs file and place this code just above the closing brace of its CheckingOut event handler.

Code: Select all

if (Token.Instance.User.AffiliateId > 0)
            {
                OrderCollection ordersWithAffiliate = OrderDataSource.LoadForCriteria(string.Format("UserId={0} AND AffiliateId={1}", Token.Instance.UserId, Token.Instance.User.AffiliateId));
                if (ordersWithAffiliate.Count > 0)
                { 
                    //NOT A VALID AFFILIATE SO REMOVE IT
                    Token.Instance.User.AffiliateId = 0;
                    Token.Instance.User.Save();
                }
            }

michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Re: Limiting Affiliate Orders

Post by michael.p.larsen » Fri Feb 19, 2010 4:23 pm

NICE! Thanks Mazhar.

michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Re: Limiting Affiliate Orders

Post by michael.p.larsen » Fri Feb 19, 2010 5:47 pm

In the criteria, can I specify a time? If more than a day has passed, it's okay if the affiliate is associated with an order.

How do I do this?

Thanks for all your help Mazhar.

michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Re: Limiting Affiliate Orders

Post by michael.p.larsen » Fri Feb 19, 2010 5:54 pm

Actually even better -- on the ReceiptPage.ascx.cs, how can I remove all references to an affiliate?

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Limiting Affiliate Orders

Post by jmestep » Sat Feb 20, 2010 8:36 am

This might work- in Able 5 there was a setting where you could make an affiliate's orders persistent or not.
In the Able 7 admin, there is a field "Referral Days". If you set that to one, it might accomplish what you want, but I'm not sure.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

michael.p.larsen
Lieutenant (LT)
Lieutenant (LT)
Posts: 70
Joined: Fri Jan 15, 2010 8:17 am

Re: Limiting Affiliate Orders

Post by michael.p.larsen » Wed Feb 24, 2010 2:24 pm

Thanks for all the insight.

On the ReceiptPage control, in the Page_Init I added the following code:

Code: Select all

Token.Instance.User.AffiliateId = 0;
Token.Instance.User.Save();

Post Reply