Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[contribution] Store Locator


ssnb

Recommended Posts

This is the support forum for the following contribution:

 

Store Locator V1

 

 

**** INTRODUCTION *********

 

This contribution will enable you to include drop down boxes that let your users select their nearest retail stores / stockists - without displaying all of them at once (useful if you don't want a large page full of contact details etc).

 

This package contains all the files, but it does not explain how to create a new page - you will have to do that yourself (there are plenty of forum pages dedicated to explaining how to do that). Alternatively, you might want to install this package on an existing page (such as contact us)

 

This script uses a database table to store the list of cities and contact details etc and at the moment - a separate admin page that allows you to populate the table. V2 could move the admin side into OSC admin - but I don't have the time for that right now and it works great as it is.

 

Demo: http://www.sk8factoryshop.com/mydealer.php

 

This script was originally created by Jennifer - http://www.scriptygoddess.com and modified a lot by me.

 

10 minute install and no OSC files modified.

AS ALWAYS, BACK UP YOUR DB FIRST !!

 

 

I will help where I can....

Link to comment
Share on other sites

Looks good, do you have a link to the contribution?

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Thanks, can't wait to try it out, sorry if I was too eager!!

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Hi, great thing you did, exactly what I was looking for, thank you very much.

 

Some first feedback:

1) Installation is an 5 minute issue, there are no osc files affected really, just some addings

2) There must be an issue with adminadd.php and adminedit.php

 

When trying to add a store, I'm getting always the message "there was an error etc", and also nothing new appears in my database

When adding directly a store into the database table, then everything is fine, I can find the store again when watching the retailers.php

When deleting this store again (via admin), then it works also, no store anymore in the database, so the admindelete.php works fine

 

But we need this to add stores, not just to delete them, right? :)

Edited by multimixer
Link to comment
Share on other sites

Hi, great thing you did, exactly what I was looking for, thank you very much.

 

Some first feedback:

1) Installation is an 5 minute issue, there are no osc files affected really, just some addings

2) There must be an issue with adminadd.php and adminedit.php

 

When trying to add a store, I'm getting always the message "there was an error etc", and also nothing new appears in my database

When adding directly a store into the database table, then everything is fine, I can find the store again when watching the retailers.php

When deleting this store again (via admin), then it works also, no store anymore in the database, so the admindelete.php works fine

 

But we need this to add stores, not just to delete them, right? :)

 

 

Hello, thanks for your feedback.

 

Did you download the second package? The first had an error in it.

 

Just in case, here is the code for those two files - just replace what you have.

 

adminadd.php

<?php
session_start();
include('config.php');
include('logindetect.php');


if (isset($_POST['submit'])) {
//connect to database
include('db.php');

//add entry
if (mysql_query("INSERT INTO storelocator(`store`, `url`, `address`, `address2`, `city`, `state`, `zip`, `phone`, `email`) VALUES ('".trim($_POST['store'])."', '".trim($_POST['url'])."', '".trim($_POST['address'])."', '".trim($_POST['address2'])."', '".trim(ucwords(strtolower($_POST['city'])))."', '".$_POST['state']."', '".trim($_POST['zip'])."', '".trim($_POST['phone'])."', '".trim($_POST['email'])."')")) {
$msg = "Entry added successfully";
} else {
$msg = "There was an error adding the entry. Please try again.";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Dealer Directory - Admin - Add a Store</title>

<script type="text/JavaScript">
<!--

function validRequired(formField,fieldLabel,alertmsg)
{
var result = true;
if (formField.value == "")
{
if (alertmsg == "") {
alert('Please enter the ' + fieldLabel +'.');
} else {
alert(alertmsg);
}
formField.focus();
result = false;
}
return result;
}

function validate() {
if (!validRequired(document.addstore.store,"store name","")) {
return false;
}
if (!validRequired(document.addstore.address,"store's address","")) {
return false;
}
if (!validRequired(document.addstore.city,"store's city","")) {
return false;
}
if (!validRequired(document.addstore.state,"store's state","")) {
return false;
}
if (!validRequired(document.addstore.zip,"store's zipcode","")) {
return false;
}
}

//-->
</script>
</head>

<body>
<?php include("adminnavigation.php"); ?>

<h1>Dealer Directory - Admin - Add a Store</h1>
<?php
if (isset($msg)) {
echo "<p style='color: red;'>".$msg."</p>";
}
?>
<p>Fill out the fields below to add a store location:<br />
(* indicates a required field)
</p>
<form name="addstore" action="adminadd.php" method="post" onSubmit="return validate();">
<table width="500" border="0" cellspacing="0" cellpadding="0" class="formtable">
 <tr>
<td class="label">Store Name *</td>
<td class="field"><input name="store" type="text" id="store" style="width:400px;" /></td>
 </tr>
 <tr>
<td class="label">URL</td>
<td class="field"><input name="url" type="text" id="url" style="width:400px;"/><br />
*please include http://</td>
 </tr>
 <tr>
<td class="label">Address Line 1 *</td>
<td class="field"><input name="address" type="text" id="address" style="width:400px;"/></td>
 </tr>
  <tr>
<td class="label">Address Line 2</td>
<td class="field"><input name="address2" type="text" id="address2" style="width:400px;"/></td>
 </tr>
  <tr>
<td class="label">City *</td>
<td class="field"><input name="city" type="text" id="city" style="width:250px;"/></td>
 </tr>
  <tr>
<td class="label">Country:</td>
<td><select name="state">
<option value="">Please select...</option>
<option value="New Zealand">New Zealand</option>
<option value="Australia">Australia</option>
<option value="Europe">Europe</option>
<option value="North America">North America</option>
<option value="Asia">Asia</option>
<option value="Elsewhere">Elsewhere</option>
</select></td>
 </tr>
  <tr>
<td class="label">Post Code  *</td>
<td class="field"><input name="zip" type="text" id="zip" /></td>
 </tr>
  <tr>
<td class="label">Phone</td>
<td class="field"><input name="phone" type="text" id="phone" /></td>
 </tr>
<tr>
<td class="label">Email</td>
<td class="field"><input name="email" type="text" id="email" /></td>
 </tr>
 <tr>
<td class="label"></td>
<td class="field"><input name="submit" type="submit" value="Add Store" /></td>
 </tr>
</table>
</form>
</body>
</html>

 

 

adminedit.php

<?php
session_start();
include('config.php');
include('logindetect.php');

if (!isset($_GET['id'])) {
header("Location: listallstores.php");
}

include('db.php');


if (isset($_POST['submit'])) {
//add entry
if (mysql_query("UPDATE storelocator set `store`='".trim($_POST['store'])."', `url`='".trim($_POST['url'])."', `address`='".trim($_POST['address'])."', `address2`='".trim($_POST['address2'])."', `city`='".trim(ucwords(strtolower($_POST['city'])))."', `state`='".$_POST['state']."', `zip`='".trim($_POST['zip'])."', `phone`='".trim($_POST['phone'])."', `email`='".trim($_POST['email'])."' where `id`='".$_POST['id']."';")) {
$msg = "Entry updated successfully";
} else {
$msg = "There was an error updating the entry. Please try again.";
}
}

$result = mysql_query("SELECT * from storelocator where `id` = '".$_GET['id']."';");
$row = mysql_fetch_array($result);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Dealer Directory - Admin - Edit a Store</title>
<script type="text/JavaScript">
<!--

function validRequired(formField,fieldLabel,alertmsg)
{
var result = true;
if (formField.value == "")
{
if (alertmsg == "") {
alert('Please enter the ' + fieldLabel +'.');
} else {
alert(alertmsg);
}
formField.focus();
result = false;
}
return result;
}

function validate() {
if (!validRequired(document.addstore.store,"store name","")) {
return false;
}
if (!validRequired(document.addstore.address,"store's address","")) {
return false;
}
if (!validRequired(document.addstore.city,"store's city","")) {
return false;
}
if (!validRequired(document.addstore.state,"store's state","")) {
return false;
}
if (!validRequired(document.addstore.zip,"store's zipcode","")) {
return false;
}
}

//-->
</script>
</head>

<body>
<?php include("adminnavigation.php"); ?>

<h1>Dealer Directory - Admin - Edit a Store</h1>
<?php
if (isset($msg)) {
echo "<p style='color: red;'>".$msg."</p>";
}
?>
<p>Edit the store entry below:<br />
(* indicates a required field)</p>
<form name="addstore" action="adminedit.php?id=<?=$_GET['id']; ?>" method="post" onSubmit="return validate();">
<table width="500" border="0" cellspacing="0" cellpadding="0" class="formtable">
 <tr>
<td class="label">Store Name *</td>
<td class="field"><input name="store" type="text" id="store" value="<?=$row['store']; ?>" style="width:400px;" /></td>
 </tr>
 <tr>
<td class="label">URL<br />
include http://</td>
<td class="field"><input name="url" type="text" id="url" value="<?=$row['url']; ?>" style="width:400px;" /></td>
 </tr>
 <tr>
<td class="label">Address Line 1 *</td>
<td class="field"><input name="address" type="text" id="address" value="<?=$row['address']; ?>" style="width:400px;" /></td>
 </tr>
  <tr>
<td class="label">Address Line 2</td>
<td class="field"><input name="address2" type="text" id="address2" value="<?=$row['address2']; ?>" style="width:400px;" /></td>
 </tr>
  <tr>
<td class="label">City *</td>
<td class="field"><input name="city" type="text" id="city" value="<?=$row['city']; ?>" style="width:400px;" /></td>
 </tr>
  <tr>
 <td class="label">Country</td>
<td><select name="state">
<option value="">Please select...</option>
<option value="New Zealand">New Zealand</option>
<option value="Australia">Australia</option>
<option value="Europe">Europe</option>
<option value="North America">North America</option>
<option value="Asia">Asia</option>
<option value="Elsewhere">Elsewhere</option>
</select>
<script type="text/javascript">
  for (var i=0; i < document.addstore.state.length; i++) {
if (document.addstore.state[i].value == "<?=$row['state']; ?>") {
document.addstore.state[i].selected = true;
}
}
  </script></td>
 </tr>
  <tr>
<td class="label">Post Code *</td>
<td class="field"><input name="zip" type="text" id="zip" value="<?=$row['zip']; ?>" /></td>
 </tr>
  <tr>
<td class="label">Phone</td>
<td class="field"><input name="phone" type="text" id="phone" value="<?=$row['phone']; ?>" /></td>
<tr>
<td class="label">email</td>
<td class="field"><input name="email" type="text" id="email" value="<?=$row['email']; ?>" /></td>
 </tr>
  <tr>
<td class="label"><input type="hidden" name="id" value="<?=$_GET['id']; ?>" /></td>
<td class="field"><input name="submit" type="submit" value="Update Store" /></td>
 </tr>
</table>
</form>
</body>
</html>

Link to comment
Share on other sites

Hi, thank you for the reply

 

I installed the second package and also compared what I have with your postings. The files are identical

 

So, the problem remain

- I can not add a store via the admin (error message and no database update)

- I can see stores that I added directly in the database pressing "list stores". I can see them also on the customers side at retailers.php

- I can not edit the stores (error message and no database update)

- I can delete a store when pressing "delete"

 

Where could the problem be? I'm breaking my head. Well, I'm not a programmer, but still. Did other people installed this here? How does it work?

 

Ahhh, such a great thing and I can not bring it to work

Link to comment
Share on other sites

Hi, thank you for the reply

 

I installed the second package and also compared what I have with your postings. The files are identical

 

So, the problem remain

- I can not add a store via the admin (error message and no database update)

- I can see stores that I added directly in the database pressing "list stores". I can see them also on the customers side at retailers.php

- I can not edit the stores (error message and no database update)

- I can delete a store when pressing "delete"

 

Where could the problem be? I'm breaking my head. Well, I'm not a programmer, but still. Did other people installed this here? How does it work?

 

Ahhh, such a great thing and I can not bring it to work

 

 

Sounds like a problem with adminadd and adminedit.php

 

Works fine for me, can't see why it doesn't for you.

You could try using the original code here:

http://www.scriptygoddess.com/downloads/storelocator.zip

 

Cheers

Link to comment
Share on other sites

  • 3 weeks later...
Did you have any success? Keen to know if you found a bug?

 

Hi

 

Yes, I took the original code and everything remains as is. I tried this and that and no result. There must be a connection problem to the database n adminadd and adminedit.

 

I have to confess hat I didn't invest much time in this after my last trials, because of other things to do, but I'll give it one more try next week.

 

My final plan is to display this on checkout-shipping.php (additional to the original retailers.php) and combine it with the "store pick up" option that I have, so that if somebody choose this option, he can choose also in what store to pick up the stuff.

 

I dn't know if somebody else took this contribution and how it works, would be great to know

Link to comment
Share on other sites

Hi

 

Yes, I took the original code and everything remains as is. I tried this and that and no result. There must be a connection problem to the database n adminadd and adminedit.

 

I have to confess hat I didn't invest much time in this after my last trials, because of other things to do, but I'll give it one more try next week.

 

My final plan is to display this on checkout-shipping.php (additional to the original retailers.php) and combine it with the "store pick up" option that I have, so that if somebody choose this option, he can choose also in what store to pick up the stuff.

 

I dn't know if somebody else took this contribution and how it works, would be great to know

 

 

Can you provide me with a link so I can take a look?

 

Thanks

Sol

Link to comment
Share on other sites

Good news: The problem is SOLVED !! I'll explain what happened:

 

You (ssnb) send me via email a previous version of adminadd.php. The only difference to the recent was the "email" in the sql query. Uploading this file everything worked fine: I could add stores, but I could not edit them.

 

why? Because in adminedit.php there was still the "email" in sql query.

 

Going to the database to see whats going on, things got clear: There was no "email" field. Adding manually an email field solved the problem totally. Now the recent version(including "email") of adminadd.php and adminedit.php work perfectly.

 

What caused the problem? The .sql file in the package do not create an email field in the Database, probably it belongs to the old set of files.

 

Now everything works perfect, you did a great thing sol. And thank you very much for your support and time.

 

I'll keep the forum here posted on modifications and integrations I'll do with this great tool.

Link to comment
Share on other sites

Good news: The problem is SOLVED !! I'll explain what happened:

 

You (ssnb) send me via email a previous version of adminadd.php. The only difference to the recent was the "email" in the sql query. Uploading this file everything worked fine: I could add stores, but I could not edit them.

 

why? Because in adminedit.php there was still the "email" in sql query.

 

Going to the database to see whats going on, things got clear: There was no "email" field. Adding manually an email field solved the problem totally. Now the recent version(including "email") of adminadd.php and adminedit.php work perfectly.

 

What caused the problem? The .sql file in the package do not create an email field in the Database, probably it belongs to the old set of files.

 

Now everything works perfect, you did a great thing sol. And thank you very much for your support and time.

 

I'll keep the forum here posted on modifications and integrations I'll do with this great tool.

 

 

Excellent!

Thanks for the good news.

 

AHHHH the SQL file must have been incorrect. I will update the package now.

 

Thanks -

Sol

Link to comment
Share on other sites

  • 1 month later...

Hello Sol,

 

I have taken a cut at adding a storelocator maintenance box in the Admin area. I would be happy to send a zip of the work to you for your consideration. I also have a screenshot that I can email if you wish.

 

Regards,

Rollout

Link to comment
Share on other sites

  • 7 years later...

Hi Alan,

 

Your script is great. I like to extend 2 more selection. Start from manufacturer, product, state, city. If I imitate getcities.php and change into manufacturer and product. Then modify getstores.php and index.php. Add 2 column in the database table. Will it be possible? Can you give some suggestion?

 

Thanks a lot,

Robert

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...