First of all, I'm not a coder my self, therefore the code I'm sharing with you I created myself by copying here and there to try and make it work... but it does not. So would you please help me out?
What I'm trying: make the billing_phone autocomplete="tel"
value, become automplete="nope"
so it will stop autocompleting that filed and only that one.
I tried many things during the last 10 hours, with no luck, so this is what I got right now on my functions.php file, although it can be completely wrong, I just hope you can help me, and of course, explain your code would be most welcome:
/* Disable autofill phone */
add_action('woocommerce_billing_fields', 'autocomplete_nope');
function autocomplete_nope( $content ) {
$str_pos = strpos( $content, 'name="billing_phone"' );
$content = substr_replace( $content, 'value autocomplete="nope"', $str_pos, 0 );
return $content;
}
UPDATE
Based on your anwswers bellow i tried this 2 options, but still no luck, they still send back this in the HTML:
<input type="tel" class="input-text wfacp-form-control" name="billing_phone" id="billing_phone" placeholder="999-999-9999" value="" autocomplete="tel">
First attempt (not working):
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields )
{
$fields['billing']['billing_phone']['custom_attributes'] = array( "autocomplete" => "nope" );
return $fields;
}
Updated - Second attempt (not working):
add_action('woocommerce_billing_fields', 'autocomplete_nope');
function autocomplete_nope( $fields ) {
$fields['billing']['billing_phone']['autocomplete'] = false;
return $fields;
}
Thanks so much for your time.
question from:
https://stackoverflow.com/questions/66065484/disable-autocomplete-phone-billing-woocommerce 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…