我使用Multisite(子文件夹),并且如果客户已注册,希望自动填写结帐字段。
为此,我使用在该线程中找到的代码:“ Pre-populate Woocommerce checkout fields”:
add_filter('woocommerce_checkout_get_value', function($input, $key )
{
$current_user = get_current_user_id();
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;
case 'billing_phone':
$phone = get_user_meta($current_user,'phone_number',true);
return $phone;
break;
endswitch;
}, 10, 2);
我注册了用户并填写了个人资料字段-名,姓,电子邮件和电话。
但不幸的是,在结帐字段中仅显示电子邮件。名字,姓氏和电话不显示。
如何解决?