2015-09-24 18 views
9

WordPressユーザーと同様にプログラムで顧客を作成することができますか?明らかに、WooCommerceユーザーは同じWordPressユーザーフィールドのいくつかを共有しています。そこには、請求/郵便アドレスのように設定する必要のある追加のコンテンツがあります。WooCommerceプログラムによって/機能を介してアカウントを作成

誰でもこれまでに達成したことはありますか?彼らのウェブサイトのWooCommerce API /関数リストに何も見つかりません。

編集:ただ、これを見つけた:(アドレスなど)http://docs.woothemes.com/wc-apidocs/function-wc_create_new_customer.html

しかし、どのように私は、提供することができ、他のフィールドの詳細。

答えて

20

WooCommerceのお客様は基本的に余分なメタデータを持つWordPressユーザーです。したがって、ユーザーが作成されると、update_user_meta機能を使用してメタデータを追加できます。ユーザー - >すべてのユーザーに移動し、ユーザーの1人を編集してから、下にスクロールしてフィールドを表示します。

以下のコードを作成して、どのように動作するかを説明します。ここで

$user_id = wc_create_new_customer($email, $username, $password); 

update_user_meta($user_id, "billing_first_name", 'God'); 
update_user_meta($user_id, "billing_last_name", 'Almighty'); 
.... more fields 

は、請求先住所と配送フィールドの完全なリストである

課金

  • billing_first_name
  • billing_last_name
  • billing_company
  • billing_address_1
  • billing_address_2
  • billing_city
  • billing_postcode
  • billing_country
  • billing_state
  • billing_phone

送料

billing_email 10
  • shipping_first_name
  • shipping_last_name
  • shipping_company
  • shipping_address_1
  • shipping_address_2
  • shipping_city
  • shipping_postcode
  • shipping_country
  • shipping_state
+0

ありがとうございます。私は昼食時に同じ結論に達しましたが、私はそれを見ている将来のユーザーのためにあなたの答えを記します。 –

+0

ありがとう、幸せなコーディング:) –

+0

@AnandShahは、このフィールドのリストを入手した場所からのリンクで返信していただけますか?できるだけ早くそれをしてください。 –

関連する問題