Price displayed based on proximity

Is there a way to modify the "Proximity search with results sorted by distance"  Example Code to display a different price based on proximity using default values and not using a search form?

The idea would  be to set the fromAddress default value of zip code (for example:63841) as Point A and use a User Account zip code as Point B. If distance between Point A to Point B is greater than 50 miles away it displays Price 1, if greater than 25miles it displays Price 2, If less than 25 miles it displays Price 3.

Dan Perez

By Dave - December 12, 2013

Hi Dan, 

Yes, using the "sample_search.php" example code referred to as "Proximity search with results sorted by distance" you could just do this:

<?php 
  if     (!$record['_distance'])     { print "Unknown, can't calculate distance!"; } 
  elseif ($record['_distance'] > 50) { print $record['price1']; }
  elseif ($record['_distance'] > 25) { print $record['price2']; }
  else                               { print $record['price3']; }
?>

Let me know if that will work for you.

Dave Edis - Senior Developer
interactivetools.com

Thanks Dave.  Where would I enter the default zip as point A and the user zip as point B. I submitted this also through the hire us portion incase it requires development costs.  Haven't heard back yet.

Dan Perez

By Dave - December 12, 2013

Hi Dan, 

Basically it would be exactly the same as a proximity search but instead of having the user enter a zipcode you'd use their lng/lat coordinates from their user profile, and you'd need those for all the products too.  There's probably a few steps involved.  If you've got a proximity form setup already, and are automatically geocoding users addresses, and users are logged in, and products are all geocoded already, it shouldn't take too much more.

If you've already sent a ticket in (with FTP/CMS details?) I'll ask Ross to take a look and follow up either directly or through this post.

Talk soon, cheers!

Dave Edis - Senior Developer
interactivetools.com