Created
May 29, 2017 11:33
-
-
Save aliciaiceland/c5029f3c7f155bbc69bb90d961cd3c8c to your computer and use it in GitHub Desktop.
Pre-populate Woocommerce checkout fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Pre-populate Woocommerce checkout fields | |
*/ | |
add_filter('woocommerce_checkout_get_value', function($input, $field ) { | |
global $current_user; | |
switch ($field) : | |
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment