【发布时间】:2019-08-24 23:14:14
【问题描述】:
我正在尝试在 woocommerce 结帐页面中预填充其他字段,但我正在为此苦苦挣扎。
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;
case 'billing_phone':
return $current_user->phone;
break;
case 'billing_company':
case 'shipping_company':
return $current_user->company;
break;
case 'billing_vat':
return $current_user->vat;
break;
endswitch;
}, 10, 2);
它适用于 $current_user->phone、$current_user->company、$current_user->vat
有什么帮助吗?
【问题讨论】:
标签: php wordpress woocommerce checkout hook-woocommerce