In this integration guide, we will walk you through the installation and configuration of our Address Validation plugin. Service Objects’ Address Validation plugin will extend your existing checkout functionality by providing correction, standardization, and validation as well as providing extra metadata information about the client’s address. This information will help you to make better business decisions and reduce the amount of wasted time, energy, and money you spend pursuing invalid addresses.
The WooCommerce platform is built upon one of the most popular content management systems, WordPress. Thanks to this pairing, with a rudimentary knowledge of PHP, the extension of both systems is a breeze. For a detailed breakdown of the fields and methods available in the WooCommerce API please reference: https://docs.woocommerce.com/documentation/plugins/woocommerce/woocommerce-codex/extending/
First, we will examine a standard workflow that a client would go through during checkout.
Workflow
- Items are added to the cart and then the user navigates to their cart overview
- From the cart overview, the user will proceed to checkout, where they are directed to enter their contact information along with their billing details.
- The user then enters their shipping/billing information, and then the order is placed.
- After the order is placed, the user is directed to a confirmation page and the address data is collected and validated on the back end.
Data Validation Process
The address validation is performed after a user submits their order. This process is designed to be non-intrusive to the user’s experience while still providing the benefits of data validation. Workflows can be built around the service output, and is explained in more detail in part 4 of the Code Modification section.
- Address information is gathered on “Place Order”
- The address is run through the Service Objects web service
- The response is saved and displayed on the Order Admin page
This step can be modified to fit your business workflow
Here is an example Order Admin Section:
Address Validation Information Address1: 136 W Canon Perdido St Ste D Address2: City: Santa Barbara State: CA Zip: 93101-8207 IsResidential: false DPV: 1 DPVDesc: Yes, the input record is a valid mailing address DPVNotes: 26,28,39 DPVNotesDesc: The input address matched the ZIP+4 record,The input address matched the DPV record,Highrise apartment/office building address Corrections: 10,22 CorrectionsDesc: City change,ZIP code change BarcodeDigits: 931018207766 CarrierRoute: C008 CongressCode: 24 CountyCode: 083 CountyName: Santa Barbara FragmentHouse: 136 FragmentPreDir: W FragmentStreet: 93101-8207 FragmentSuffix: St FragmentPostDir: FragmentUnit: Ste Fragment: D FragmentPMBPrefix: FragmentPMBNumber:
Code Modification
Two main updates need to be made to the provided PHP code in order to use your license key and website fields. The LicenseKey variable should be updated to the key provided in your welcome email. For trial keys, the endpoint URL will remain as “trial.serviceobjects.com”. When it is time to swap to a production key it is as simple as switching over to the new key and changing the URL to point to our production environment. The last step in the code modification is to ensure the mappings are correct for your specific Billing and Shipping fields. The plugin code provides commented-out names for the standard WooCommerce shipping and billing fields.
- Replace the LicenseKey variable with the provided Service Objects license key
- Ensure $URL is pointing to the proper environment
- The endpoint URL will be provided upon license key signup
- Map your desired input parameters
e.g.$_POST[‘address_component’] This will generally be your shipping or billing address components
- Leverage the output fields in the function:order_checkout_display_address_validation
-
- To better understand the information provided by Service Objects’ Address Validation – US web service, please see the following developer guide: https://www.serviceobjects.com/docs/dots-address-validation-us-3/av3-operations/av3-getbestmatches-recommended/#AV3-GetBestMatches-Recommended-GetBestMatchesOutputs
The validated information can be displayed to your order fulfillment team so they can make any necessary updates before shipping your product. Data updates, workflows, and displaying information can all be done programmatically as well.
-
Installation
After the code modifications are complete, zip up the plugin and use the WordPress plugin manager to upload the file.
- Compress the extension into a .zip file
- Select “Add New” from the admin dashboard
- Select “Upload Plugin”
- Select “Choose File” and select the .zip file
- Select “Install Now”
- Select “Activate Plugin”
For more details about Service Objects’ Address Validation capability and its parameters, consult the Address Validation – US Developer Guide mentioned above on our website. And if you have questions or need assistance with your integration, our friendly technical support team is always happy to help.