![]() |
Assign idAffiliate session variable after login |
Post Reply ![]() |
Author | |||
owendf ![]() Newbie ![]() Joined: 04-February-2011 Status: Offline Points: 0 |
![]() ![]() ![]() ![]() ![]() Posted: 05-February-2011 at 5:07pm |
||
Hello,
Short description: I want to set the session("idAffiliate") variable to a Special Customer Field value just after a user logs on, but I don't know how to extract the Special Customer Field Value from the database, and I cannot figure where in login.asp to put the code. Long description: I created a Special Customer Field that the user never sees using the product cart control panel (Show on registration page, Show on checkout page check boxes are blank). I use this field to manually enter an Affiliate id for certain customers. I want to be able to assign those customers to my affiliates manually for offline affiliation. So, all I need to do is assign the session("idAffilate") variable to the Special Customer Field value for the customer just after login. If I knew what I was doing, this would be easy, I think. I have made many attempts but I think they are so far off that posting them would be counter-productive. Thanks for any help! Edited by owendf - 05-February-2011 at 5:08pm |
|||
![]() |
|||
Brett ![]() Groupie ![]() ![]() Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
![]() ![]() ![]() ![]() ![]() |
||
I'm a bit confused about your request.
You added a Special Customer Field and hid it from the customer by un-checking those boxes, but the field is still visible to you via the admin panel, right? So you want to be able to go into the admin panel and edit the customers and enter something into that special field (an affiliate ID). But, where does the process of assigning a value for the customer "just after login" come in? Can't you already go to your admin panel and enter the affiliate ID for each customer now that you've created the special field? *edit* I just added a special customer field on my store and viewed my customer record, and now I see the special field under "Other Settings". Is this what your are looking for? You've said you want to manually set the affiliate ID, but from your request it sounds like you want to automatically set the affiliate ID when the customer logs in? Edited by Brett - 05-February-2011 at 6:04pm |
|||
![]() |
|||
owendf ![]() Newbie ![]() Joined: 04-February-2011 Status: Offline Points: 0 |
![]() ![]() ![]() ![]() ![]() |
||
Hello Brett- you're right- it is confusing.
Yes, I want my store's code to automatically assign 'session("idAffiliate")'(which controls what affiliate, if any, is assigned to any purchases made during that session) to whatever is in the special customer field that I set manually through the admin on a per customer basis. For example- I create the Special Customer Field 'Affiliate ID' through the admin. A customer Named John registers and I edit his customer information through the admin and assign '12' to the 'Affiliate ID' Special Customer Field. I know that 12 is the affiliate ID of a business that I want to earn commissions on all of John's purchases. Then I add code so that just after John logs in, 'session("idAffiliate")' is assigned the value in the 'Affiliate ID' customer field, which is 12. Then when John buys, affiliate 12 is assigned the sale and I can pay the commission. I have actually figured out the code by looking at the query that the product cart admin uses to pull up the field when you edit it for a customer, in modCusta.asp. So, I can now assign 'session("idAffiliate")' the value in 'Affiliate ID' (happy to share code if requested). Right now I have the code at the beginning of onpepagecheckout.asp, but I really want it ran just after login, and just once. But I cannot figure where in the code that it would be guaranteed to be run after login. I'm not a developer, just a guy that can hack is way around half-blind. Edited by owendf - 05-February-2011 at 6:27pm |
|||
![]() |
|||
Brett ![]() Groupie ![]() ![]() Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
![]() ![]() ![]() ![]() ![]() |
||
Now it makes perfect sense ;) You want it to auto set that session variable so the customer doesn't have to enter it later during checkout. Is this correct? Is the customer usually able to enter something into an affiliate field during checkout, and you want that field auto populated by the hidden special customer field?
|
|||
![]() |
|||
owendf ![]() Newbie ![]() Joined: 04-February-2011 Status: Offline Points: 0 |
![]() ![]() ![]() ![]() ![]() |
||
Update- I just reread your reply and maybe you did get it. But no, there is not normally an option to choose an affiliate during checkout- the affiliate is defined by a query string in the url. OK, here is my full reply..
When you click on a link from an affiliate site, it contains a query string at the end of the url that identifies the affiliate ID. This is stored in a session variable called idAffiliate. When you check out, the order is associated with that idAffiliate value, which is in turn associated with an affiliate, who then receives a commission for the sale. This is called affiliate marketing, and is common on the web. You probably already know all that, but I wanted to establish a context. But I want to manually associate customers with particular affiliates, without them having to link with a url that has the affiliate ID in a query string. Thus, I create a DB field for each customer using the Special Customer Fields, assign the affiliate ID I want associated with that customer to that field, and then, when that customer logs on, I set the session variable idAffiliate to the value in that field. The customer sees none of this; no fields, no pre-populated text boxes, nothing- they are just automatically associated with an affiliate as if they had clicked on that affiliate's link from his site that contained a query string (example: www.mystore.com/store/pc/home.asp?idaffiliate=12) So, in the above example, say affiliate 12 is Bob, and I want him to get a commission check when John buys something. John's account-->special customer field called Affilate ID set to 12 manually by me in admin-->John logs in-->run code that sets idAffiliate session variable to Affiliate ID special customer field=12-->John buys widget-->I see in admin that affiliate 12, Bob, is owed a commission. The most sensible place to code this is someplace after login that would affect all users, regardless of how they logged in. But I cannot figure out where in the code that spot is. So, I have put the code at the beginning of checkout, because that will ensure that the idAffiliate session variable is set prior to completing the sale. Edited by owendf - 06-February-2011 at 12:25am |
|||
![]() |
|||
Brett ![]() Groupie ![]() ![]() Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
![]() ![]() ![]() ![]() ![]() |
||
Hey owendf, this should do what you want. It exists in pcStartSession.asp between:
...and
This is the newly added code:
Go to Customers > Manage Special Fields and hover your mouse over the Special Field you want to use to store your affiliate ID's and note the idcustfield= number from the url. Then, go to the pcStartSession.asp file included here and edit "pcCField_ID=2" in the database query, changing the number 2 to whatever the number from your URL was. This is how the script knows which database field to look for. Here's the attached file: pcStartSession.zip Edited by Brett - 08-February-2011 at 1:47pm |
|||
![]() |
|||
owendf ![]() Newbie ![]() Joined: 04-February-2011 Status: Offline Points: 0 |
![]() ![]() ![]() ![]() ![]() |
||
Hello Brett- Thanks!!! I appreciate your help.
|
|||
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |