You can stop WooCommerce checkout fields from auto filling by using a Woo filter woocommerce_checkout_get_value, this could be useful in a situation when a logged in user is ordering on behalf of multiple customers.
add_filter( 'woocommerce_checkout_get_value','prefix_return_empty_checkout', 1, 1 );
function prefix_return_empty_checkout(){
$user = wp_get_current_user();
//The user has the "shop_manager" role
if ( in_array( 'shop_manager', (array) $user->roles ) ) {
return '';
}
}
So in the code snippet I am returning blank checkout fields just to the ‘Shop Manager’ role which is provided by WooCommerce, conditionally doing this allows regular Customers the user experience of having the checkout fields auto-fill. To apply for all users just remove the if condition.










6 comments
Maaz khan
where to put this?
Neil Gowran
Theme’s functions file
R Darby
Where does this code go? function.php, theme.css??
Martin Bäckman
Is it possible to do this to specific fields like e-mail, name?
Martin Bäckman
Hey this is great! Is there a way to limit it to specific fields? For example, just street, city and postcode?
Scott
Hey this is great! Is there a way to limit it to specific fields? For example, just street, city and postcode?