Auto Address is only available with CoCart Plus.
Provider selection is handled automatically server-side based on configuration and country. Developers configure the provider(s) during setup, and the API automatically selects the appropriate provider. The
provider
field in responses is informational only - customers use it to pass back to the details endpoint.Providers
These are the currently supported address providers:Google Places API
Provides global address autocomplete using Google’s Places API. Configuration: Add to yourwp-config.php
file:
- Google Cloud Platform account
- Places API enabled
- Valid API key
SmartyStreets
Provides US address validation and autocomplete using SmartyStreets API. Configuration: Add to yourwp-config.php
file:
- SmartyStreets account
- Auth ID and Auth Token
You can create your own custom address provider if these are not the ones you want to use. See the Custom Address Provider guide for details.
Best Practices
- Debounce input - Wait 300-500ms after user stops typing before searching
- Handle errors gracefully - Provide fallback to manual entry
- Cache results - Consider caching suggestions client-side
- Validate addresses - Always validate the final address before checkout
- Store provider ID - Save the provider ID from search results to use in the details request
Performance Considerations
- Minimum query length enforced (3 characters) to reduce unnecessary API calls
- Provider is automatically selected server-side based on country and configuration
- Results are not cached server-side to ensure fresh data
- Consider implementing client-side caching and debouncing