|
/ Documentation /Code Snippets/ How to Turn Off the Auto-fill of Address Fields on Entering Zip-Code?

How to Turn Off the Auto-fill of Address Fields on Entering Zip-Code?

CartFlows includes a convenient feature that automatically fills in the Country, State, and City fields on your checkout page based on the zip code entered by the customer. This functionality is powered by the Zippopotam API, which looks up location details for recognized zip codes and auto-fills the corresponding fields to streamline the checkout process.

However, in some scenarios, you may want to disable this behavior, for example, when using custom fields or serving regions where this data is unreliable.

Disable Auto-Fill Using a Filter

To turn off this auto-fill functionality, you can use the following WordPress filter:

/**
* Filter to enable/disable the address auto-fill using the zip code.
*
* @param string $allow having yes/no
* @return string $allow yes or no
*/

add_filter( 'cartflows_autocomplete_zip_data', 'wa_disable_autocomplete_zipcode', 10, 1 );

function wa_disable_autocomplete_zipcode( $allow ) {
$allow = 'no';
return $allow;
}

How to Add This Code

To apply this filter, add the snippet to your child theme’s functions.php file or use Code Snippets plugin. If you’re unsure how to safely add custom code to your site, we recommend reviewing this guide on adding custom code.

Once added, CartFlows will no longer auto-fill the address fields when a zip code is entered, allowing full manual input from the customer.

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page
Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Free Cartflows Form - Popup

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.