Skip to main content

Posts

Showing posts from April, 2019

Pre-populate Woocommerce checkout fields for logged in user

Hi Friends In this Tip We Learn How to add Pre-populate Woocommerce checkout fields for logged in user. This will populate ‘value’ attribute of checkout input field. Add below code to Function.php file /** * Pre-populate Woocommerce checkout fields */ add_filter('woocommerce_checkout_get_value', function($input, $key ) { global $current_user; switch ($key) : case 'billing_first_name': case 'shipping_first_name': return $current_user->first_name; break; case 'billing_last_name': case 'shipping_last_name': return $current_user->last_name; break; case 'billing_email': return $current_user->user_email; break; case 'billing_phone': return $current_user->phone; break; endswitch; }, 10, 2);