2017-08-16 62 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/

此頁面上,你可以得到正確的字段名