The Digital Developer Blog - Blogs by Computan

Building Custom Location Plugin in WordPress

Written by Simranjeet Singh | December 19, 2021 at 5:27 PM

It is maybe because I post Computan custom integration blogs regularly, the readers wonder that why does Computan does custom integration? Why don’t these guys give solutions through native integration or integration through connectors?

As a consistent integration service provider, we do get requests for integration of HubSpot or WordPress with any third-party tool or software. While we are in the discussion with our clients, we explore all the options to achieve the desired goals for the clients. We do check whether the integration is possible through native integration or with a middleware connector that is already available in the market. Anyone just by reading the features of the standard integration can figure out whether the integration tasks will be possible or not.
When all the options fail, custom integration seems to be the right choice to achieve the desired results from integration.

In not so recent integration project, Computan built a custom ‘Find a Clinic’ custom plugin for a client in Canada. And, yes, paid location plugins were available that are known for achieving similar goals, but they have limitations due to which we could not use that in our project. Haseeb, technical project manager at Computan handled the project gracefully and made sure it gets delivered as expected and on time. Kudos to Haseeb and his team.

Why build a custom WP plugin for this when there are many paid options available?

The paid WP plugins out there do not have the ability to get the last order details from WooCommerce. We needed customer addresses collected from the order Meta printed on a Google map page where website visitors can browse the clinics. This workflow wasn’t available in the paid plugins.

What sort of customizations to WordPress is needed to build a Location Plugin?

Not much customization in WordPress was needed but the environment variables like PHP max_execution_time were modified because we had to process thousands of orders at the same time before the map pins get printed.

How do the Google Map licenses work?

The Google Maps API key was generated by the client and we queue our custom script with that key tied to it. Since it is a paid one, the domain names were associated with the API settings to restrict unauthorized API calls.

Here’s how to generate Google Maps API if you are curious to know

  • Login to your Google Developer console
  • Create a Project, go to Library, search for Google maps and enable it
  • Follow the above step similarly to generate Google Places API
  • Create credentials for the API key
  • Restrict access to API
  • You now have your API key ready

You can queue any of your custom scripts with it that would help you achieve the desired integration.

Computan’s Plan of Action for Integration

  • We began with designing the frontend section. Like almost every project, we design first and then develop. The placement and position of Google Maps and the list were important to know. Also, any questions that arise during the designing stage become easy to address during the development stage.
  • Fetch all the companies and list them on the map using custom post type.
  • Each company fetched should have one user and must have entered the fields such as user role, company owner, company user role, company among others.
  • Crosschecking of the WooCommerce orders associated with the respective users
  • Pull up the product categories users are purchasing. Even if they purchased in multiple categories, we needed all the purchases to be listed.
  • Quality checks at the completion of each stage and at the end to make sure the system is working the way our client requested.

What is the general estimated time?

It takes around 140 to 160 hours to accomplish the task of this scale.

How to Create a WordPress Plugin?

Since we are on the topic of custom WordPress plugin development, let's see the basic steps that we need to follow to design a custom WordPress plugin because the need for a custom plugin can arise at any time. Plugins are an integral part of your business process expansion if you are a WordPress user.

From website security to marketing, from content creation to community building, you will find several plugins to achieve goals on your website.

  • Start by creating a folder on your computer
  • Create a new text file in your text editor and name it with .php extension
  • Add a header to your plugin file. Write Plugin name, URL, description, version, author, author URL,
  • License, License URL, Text domain, and domain path.
  • Now plugin header is added, it’s time to add your plugin code below. Code according to the feature/function you want to achieve on your website.
  • Save the file in the folder and create a zip folder.
  • Go to your WordPress dashboard and click on Add New under Plugins
  • Upload the zip format file of the plugin and click on activate.
  • View how the plugin performs on the website.
  • I suggest you first test it on the demo website.