1 回答

TA貢獻2065條經(jīng)驗 獲得超14個贊
如果下訂單時數(shù)據(jù)已經(jīng)存在,以下將禁止更新用戶配置文件(參見WC_Checkout process_customer()方法源代碼):
add_filter( 'woocommerce_checkout_update_customer_data', 'checkout_update_customer_data_callback', 10, 2 );
function checkout_update_customer_data_callback( $boolean, $checkout ) {
if ( get_current_user_id() > 0 ) {
$customer = new WC_Customer( get_current_user_id() );
$first_name = $customer->get_first_name();
// When customer data already exist, don't update it when an order is processed
if ( ! empty( $first_name ) ) {
return false;
}
}
return $boolean;
}
代碼位于活動子主題(或活動主題)的 functions.php 文件中。測試和工作。
相關(guān):禁用 woocommerce_checkout_update_customer_data
- 1 回答
- 0 關(guān)注
- 177 瀏覽
添加回答
舉報