Sometimes you might want to disable auto population of WooCommerce fields for logged in users. To do this we make use of the woocommerce_checkout_get_value
filter and the if in WC_Checkout
get_value()
.
The if inside get_value()
returns the value before checking for logged in users if the value is not null. The function calls the woocommerce_checkout_get_value
filter before this. Therefore we force the value to be an empty string then it will return that instead of the user’s saved data.
Add the following function to your functions file or a separate library file if you prefer to organise your code.
// Disable autopopulate add_filter('woocommerce_checkout_get_value', 'checkoutGetValue', 1, 2);
/** * Disable autopopulate * * @param $value * @param $input * @return string */ public function checkoutGetValue($value, $input) { // Custom code or extra logic can go here return ''; }
Comments are closed.