Pages

June 5, 2016

WordPress Radius Calculation For Store Locator using Google Map



H
ave you ever had a chance work on the store locator project? Where you have to display the store using Google Map in given radius from the user's position (or say latitude longitude of user)? 
I recently had work on store locator project, Where in I have to customize the store locator functionality made using WordPress. 

The situation get worse when I found that the latitude and longitude of the store is stored in the `wp_meta`! This makes it more complex to calculate the distance of the stores.
After so much time spend in searching and thinking how to best fit the Google Map Distance calculation query with meta key and value format, I figure out the solutions. 

The solution was to not to use the lat, long meta data in the Google Map Distance calculation query for two reason.
  1. Its overwhelmingly complex to use meta value in Google Map Distance calculation query, (I know you know it, right?)
  2. The query will be incredibly slow while fetching the data, that will ultimately make your website look slow.

But, At the same time I cannot change the way lat and long are stored. 

The Solution I adopted was to use separate table for the lat long processing. 

This is comparatively very easy than earlier solution (with no change in current flow, off course). 

All I have done is to just use "save_post" hook and written code to save the post value in custom table. 

Like the example given below.
Write this code at the end of  `function.php` or you can make your own plugin (recommended).


Then you can apply the following query to get the store id for the given distance from the users latitude and longitude.

To search by kilometers instead of miles, replace 3959 with 6371 in the query.

That's it, thats all you need. Your store search should be working by now.

Do you find this article helpful? Don't forget to give your comment below.
Cheers.
GautamArya

October 5, 2014

UPS Shipping Rate Calculation API – Part 1


R
 ecently, I was working on the ups shipping rate calculation API. It was an e-commerce site using UPS Shipping service delivering its order.

First of all working with UPS shipping rate calculation API is simple. You first need to register yourself on ups site. You will get username, password and API key and UPS account number.

Now create a file with ‘ups_shipping_process.php’ name, and put following code in it.
Then create another file with `calculate_shipping_cost_ups.php` and put following code in it.
Set your credentials you got from UPS registration by calling ‘setCredentials()’ method, Replacing UPS_ACCOUNT_KEY, UPS_USERNAME, UPS_PASSWORD, UPS_ACCOUNT_NO with your real information.
You can set your Country, ZIP code, and measurement UNIT (i.e.  LBS or KG for weight and IN for dimension)
Below are the option for the shipping method, you might wants to use in your for user selection.
For Advance Configuration of the UPS Shipping Rate Calculation visit:

May 16, 2014

WordPress interview questions and answers

What is the Difference Between Posts vs. Pages

Posts vs. Pages
* Posts are timely vs. Pages are timeless.
* Posts are social vs. Pages are NOT.
* Posts can be categorized vs. Pages are hierarchical.
* Posts are included in RSS feed vs. Pages are not.
* Pages have custom template feature vs. Posts do not.

April 17, 2014

Create an Access token for twitter.



Have you ever caught up in a situation like you need to show the tweets on your website, for that you’ve created an application in dev.twitter.com but you don’t know where the hell is access token and access secret?

April 14, 2014

Extract images and text from post content WordPress

Hey There, Ever had a post with lots of images in it and you wanted text and images displayed separately from the post content?
Well, before a week ago I got exactly same situation where I need to display images from post content on the top and the text under it. It was a blog page of the site and showing excerpt there.
Showing the text only without image wasn’t difficult. I applied this php code and it’s done.

 echo substr(preg_replace('/<img />]+./','',$post->post_content),0,350); 
But extracting the images especially multiple from post content and showing them on the top of the blog entry was a little bit tricky part of this job.
So, what I did to extract images from post content is put this code where I need images to be displayed
  

March 29, 2014

Pagination with special recent post Plugin


Today, I'm going to show you how to add pagination with Special recent post Plugin.
If you are using special recent post plugin to show recent posts in your blog website.
You might have stuck with pagination problem i.e. what If you have 100 post and you want to show 10 posts per page?

I've made some custom changes in the special recent post plugin to made it work with pagination.
Follow these instructions to add pagination.
First we need to set the plugin is fetching the posts from the database so we need to set the offset option into the queries option so we can say what page number is requested and fetching from number of post up to 10 or whatever post you need to show in one page.
Go to the "special recent posts"  plugin now go to class directory of it. You'll find a file

class-main.php

Open it.

February 20, 2014

WordPress Plugin - Sidebar Pages Menu



Follow these very simple steps to Show menu in the sidebar of your WordPress.


  1. Log into WordPress admin area of your site.
  2. First install this Siebar Menu Widget  Plugin.
  3. Now Go to menu and create a new menu and then add the page you want to display in sidebar.
  4. Now go to widget area drag and drop the menu in the sidebar and select the menu from drop down.
That’s all. It’s that simple.

If you like this post you can like, share or comment. Subscribe the blog to get regular update on many web development articles and latest technology news.

Kindle Apps