Skip to content

Instantly share code, notes, and snippets.

@aliciaiceland
Created May 29, 2017 11:33
Show Gist options
  • Save aliciaiceland/c5029f3c7f155bbc69bb90d961cd3c8c to your computer and use it in GitHub Desktop.
Save aliciaiceland/c5029f3c7f155bbc69bb90d961cd3c8c to your computer and use it in GitHub Desktop.
Pre-populate Woocommerce checkout fields
<?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