Home / Disable / Clear Auto Fill in WooCommerce Checkout
Duplicate Snippet

Embed Snippet on Your Site

Clear Auto Fill in WooCommerce Checkout

Clears the auto fill on the WooCommerce Checkout page.

Code Preview
php
<?php
/**
 * Start Remove Autofill Checkout
 **/
add_filter('woocommerce_checkout_get_value', 'prefix_return_empty_checkout', 10, 2);
function prefix_return_empty_checkout($value, $key) {
    // List of fields to clear
    $fields_to_clear = array(
        'billing_first_name',
        'billing_last_name',
        'billing_company',
        'billing_country',
        'billing_address_1',
        'billing_address_2',
        'billing_city',
        'billing_state',
        'billing_postcode',
        'billing_phone',
        'billing_email',
        'shipping_first_name',
        'shipping_last_name',
        'shipping_company',
        'shipping_country',
        'shipping_address_1',
        'shipping_address_2',
        'shipping_city',
        'shipping_state',
        'shipping_postcode'
    );
    if (in_array($key, $fields_to_clear)) {
        return ''; // Return empty string to clear the field
    }
    return $value; // Return the original value for fields not meant to be cleared
}
/**
 * End Autofill Checkout Page
 **/

Comments

Add a Comment