Remove WooCommerce checkout fields values

enter image description here

I’m trying to apply autocomplete="off" on my WooCommerce checkout fields but it just doesn’t work.

Is there a way to do that for the checkout form?

I checked the docs and there’s nothing available there. I also tried setting the default value to empty but it doesn’t work either. This is when the user is not logged in of course.

UPDATE:

I tried unset as suggested by @smvax but it did not work as well.

add_filter('woocommerce_checkout_fields', 'default_values_checkout_fields');
function default_values_checkout_fields($fields) {
  if (!is_user_logged_in()) {
      unset($fields['billing_city']);
      unset($fields['billing_first_name']);
      unset($fields['billing_last_name']);
      unset($fields['billing_company']);
      unset($fields['billing_address_1']);
      unset($fields['billing_address_2']);
      unset($fields['billing_city']);
      unset($fields['billing_postcode']);
      unset($fields['billing_country']);
      unset($fields['billing_state']);
      unset($fields['billing_email']);
      unset($fields['billing_phone']);
      unset($fields['shipping_city']);
      unset($fields['shipping_first_name']);
      unset($fields['shipping_last_name']);
      unset($fields['shipping_company']);
      unset($fields['shipping_address_1']);
      unset($fields['shipping_address_2']);
      unset($fields['shipping_postcode']);
      unset($fields['shipping_country']);
      unset($fields['shipping_state']);
      return $fields;
  }
}

I also tried the answer here but it’s not working as well.

Thanks

Read more here: Remove WooCommerce checkout fields values

Leave a Reply

Your email address will not be published. Required fields are marked *