2017-08-16 82 views
0

发生了什么事是当已注册用户来结帐页面并填写结算表单。
数据更新当前用户数据。
woocommerce wordpress结算表格更新数据

例如,名字必须转到billing_first_name,但它的更新first_name也具有相同的值。

我想它来更新billing_first_name只

我想扭转这个过程:

add_action('woocommerce_checkout_order_processed', 'custom_process_order1', 10, 1); 
function custom_process_order1($order_id) { 
    $current_user = wp_get_current_user(); 
    $current_user_id = get_current_user_id(); 

    update_user_meta($current_user_id, "first_name", $current_user->billing_first_name); 
    update_user_meta($current_user_id, "last_name", $current_user->billing_last_name); 
} 

在这里它的更新名字与billing_first_name的价值,这是我想阻止什么。
我该怎么做?

回答

0

使用正确元字段名,

add_action('woocommerce_checkout_order_processed', 'custom_process_order1', 10, 1); 
function custom_process_order1($order_id) { 
    $current_user = wp_get_current_user(); 
    $current_user_id = get_current_user_id(); 

    update_user_meta($current_user_id, "billing_first_name", $current_user->billing_first_name); 
    update_user_meta($current_user_id, "billing_last_name", $current_user->billing_last_name); 
} 

https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/

此页面上,你可以得到正确的字段名