Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force condition on add to cart button

Status
Not open for further replies.

keepingbusy

Programmer
Apr 9, 2000
1,470
GB
Hi all

I want to add a condition to an add to cart button.

What I'm trying to do is give a warning when someone purchases a Region 1 DVD on our website as we are in the UK (Region 2) but also sell Region 1 DVD's.

Here is an example of what I mean: (Click on the Add to Cart button)

Here is our working website:
Most of what we have picked up has been self taught so we are prepared to have a go if you can give us some direction or guidance.

Thank you
 
the easiest way of doing this is to sniff the IP and geolocate it. there is a great pear class that interfaces to the maxmind free database that can do this for you.

then i would set the region (from sniffing) as a js variable on the page and use js to compare the dvd's region to the stored region for the user and flash a dialog if you need to. the js forum can help you with this.
 

Hi jpadie

Having looked at your suggestion, I think this may be above my head at the moment. Is there not a way I can use one of the tables (perhaps the one we use for the items we sell) and add a digit so in other words, if a field was set at "1" for region 1, then everytime someone clicked on the add to cart button it would show this pop up I'm looking for.

I do have some fields within the table but not sure what the command would be. I know in Visual Foxpro it's as simple as:
Code:
IF mcondtion="1"
*  Do something
ENDI
Any thoughts? (or from anyone else please)

Thank you
KB
 
i had assumed that you already knew the region of each dvd that you sell. of course you would need to store that in the database.

but if you do not "guess" at the user's region how do you know whether to warn the user? and if you are going to guess, how do you do so?

if you are going to flash a warning independent of the user's geo_region then it is as simple as recasting your links something like this

Code:
<input type="image" src="includes/languages/english/images/buttons/button_in_cart.gif" border="0" alt="Add to Cart" title=" Add to Cart " onclick="showRegion('<?=$row['regionID']?>);">

and you showRegion script would be in the <head> tags and could be as simple as this

Code:
function showRegion(region){
  return (confirm("This DVD is for region " + region + ". Please confirm that you have compatible equipment"));
}
or something more elegant from the js forum
 

Hi
i had assumed that you already knew the region of each dvd that you sell. of course you would need to store that in the database.
We do know the Region of the DVD's we sell, problem is, some customers read a specific notice we have that tells them about Region 1 DVD's are not compatible with Region 2 players so a multi-region or other suitable player is required.
but if you do not "guess" at the user's region how do you know whether to warn the user? and if you are going to guess, how do you do so?
Most of our customer are from the UK so it's not a problem to have a pop up window each time a Region 1 DVD is selected for purchse. There is no requirement to "guess".

Your coding looks like what we are looking for. We need to keep it simple and I will try this out over the next few days.

Excellent and thanks jpadie.

KB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top