Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
Forum Search
Google Site Search
 All Forums
 Technical
 PHP (Unix / Linux / Apache) versions
 Limiting Country on affiliate page
Author « Topic »  

midvalleydrifter001
Ecommerce Template Expert

USA
936 Posts

Posted - 02/13/2018 :  21:02:20  
Hi,

Is there a way to limit the "Country" on the affiliate.php page when a person is signing up to be an affiliate?

I'm getting people signing up from countries outside the USA. I can only have USA affiliates.

I do have reCaptcha setup.

Thanks,

Patrick

dbdave
ECT Moderator

USA
10468 Posts

Posted - 02/13/2018 :  22:14:51  
Hey, I liked your tip in this thread.... https://www.ecommercetemplates.com/support/topic.asp?TOPIC_ID=109339

As for your question, there is no built in way to do that, but lately I am on a javascript kick, so I did some quick research and I can see how you can easily do that with javascript.

If it were me, and I wanted to do this, I would use Javascript to check the location and then use css to hide the submit button and add a note that the affiliate program is only open to US folks.
It's not going to be foolproof, but it will work for most cases.

two pages I found some great resources
you would need this -
http://www.geoplugin.com/webservices/javascript
<script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>

then on this page https://www.sitepoint.com/geo-location-2-lines-javascript/
I tested the example code and it worked perfect at detecting my location.

If you need help compiling the code, let me know.

midvalleydrifter001
Ecommerce Template Expert

USA
936 Posts

Posted - 02/14/2018 :  12:58:26  
Your help would be much appreciated. I need to do something.

Thanks much

Patrick

dbdave
ECT Moderator

USA
10468 Posts

Posted - 02/14/2018 :  13:01:40  
I think I can work this out pretty easily this evening and I post up.
It should be a piece of cake.

I did away with our affiliate program a few years ago.
Customer were only using it for discounts on their own orders and we found that one, was actually running google search ads, and that sounds good, but they targeted our company name and what was happening is not all repeat customers type your address in the bar, or use a bookmark, some will just type your company name in a google search.
So this so called affiliate was earning commission on our repeat customers. Of course we shut him down fast.

Edited by - dbdave on 02/14/2018 13:05:10

dbdave
ECT Moderator

USA
10468 Posts

Posted - 02/14/2018 :  18:37:05  
Hi Patrick, this should do it.
I took a look at the affiliate page at the site listed in your profile.
If that's not the right site, let me know.
You will open your affiliate.php page in your html editor and make two simple additions.

This is updater proof, so no worries when making future updates.

In the head of the page somewhere, add the following single line
<script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>


Next, in the content area of the page, just after the include line for the affiliate code add the following

<script>
var country = geoplugin_countryCode();
var mesg = ('Sorry, our Affiliate program is available in the US only');
if (country != 'US'){
document.getElementsByClassName("ectdivcontainer")[0].style.display='none';
document.getElementsByClassName("ectdivcontainer")[1].style.display='none';
document.getElementsByClassName("ectdiv2column")[0].style.display='none';
document.getElementsByClassName("ectdivhead")[0].innerHTML = mesg;
}
</script>


Ok, a few things to note.
You can change the message in green there to anything you like. - However if your text contains a single quote ' then there will be an error unless we escape that. So let me know if that happens.
Next, we want to test this to be sure it works, right?
Being that you are in the US, you should not see anything happen at all when you upload the new page and visit your affiliate page.
So what you are going to do it change the part in red there and check the page.
What we have there currently is the "!=" and in Javascript, that is saying "not equal to".
Basically my "if" statement there just says if the country of the visitor is not US then do some stuff.

That "stuff" is going to hide the affiliate form and we are going to replace the text at the top of the page with a message.

So I want you to change the != to == and then upload the page. and visit the affiliate page. You may need to refresh the browser.
Now we are saying if the country IS US, then do that stuff, and you should see what a NON US visitor will see.
Once you confirm it's working, then change the code back to != and upload.

Keep in mind that it's possible to spoof an IP address so you may see the occasional signup from a foreigner but you can just ignore them and delete, because you can be sure they are spoofing their IP or defeated our little trick here, and they can probably not be trusted anyway.

Let me know how you get along and if you have issues or questions.
I can't really test this myself, but it should work perfectly.

David

dbdave
ECT Moderator

USA
10468 Posts

Posted - 02/15/2018 :  21:37:40  
Hi Patrick, I took a look at your page and I see you did not add this to the head of the page - be sure to do that.

In the head of the page somewhere, add the following single line

<script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
  « Topic »  
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.02 seconds. Snitz Forums 2000