2014-07-08 19 views
1

我试图找到woocommerce方法,这将允许我设置结算和/或运送名字。woocommerce设置结算名第

客户类将允许我设置一些字段,但不是first_name。任何人都知道是否存在方法,或者是否需要直接使用billing_first_name更新wp_usermeta表。

这里是什么行不通的例子:

global $woocommerce; 

$user_first_name = get_user_meta($user_id, 'first_name', true); 

if(!empty($woocommerce->customer->get_billing_first_name())) { 

    $woocommerce->customer->set_billing_first_name($user_first_name); // a set_billing_first_name method doesn't exist 

} 
+0

欢迎使用stackoverflow!如果您发布了一些代码,显示您现在正在做什么,以及/或者您未来希望如何​​做,这将会有很大帮助。究竟是什么问题? – davidkonrad

+1

谢谢你让我知道 – user8582

回答

0

客户在woocommerce不过是WordPress用户。如果您查看WC_Checkout->process_checkout(),则会创建一个新用户,然后将billing_first_name设置为first_name。 因此更新billing_first_name更新first_name使用update_user_meta

希望这会有所帮助!

+0

这就是我最终做的,它工作正常,谢谢! – user8582