我正在使用 Bigcommerce php 库通过 API 创建客户,这工作正常,但当我尝试将
{"status":400,"message":"The field 'name' is invalid."}
对象数组添加到调用中时,我得到 form_fields
回来。是否可以将这些包含在 createCustomer 调用中?
这基本上就是我想做的事情:
$customer_object = array(
"email" => $email,
"first_name" => $first_name,
"last_name" => $last_name,
"_authentication" => array(
"password" => $password
)
);
$form_fields = array();
if(!empty($occupation)) {
$obj = (object) array("name" => "Occupation", "value" => $occupation);
array_push($form_fields, $obj);
}
$customer_object["form_fields"] = $form_fields;
$response = Bigcommerce::createCustomer(json_encode($customer_object));
此外,这是 Bigcommerce 客户记录的样子:
Bigcommerce\Api\Resources\Customer Object
(
[ignoreOnCreate:protected] => Array
(
[0] => id
)
[ignoreOnUpdate:protected] => Array
(
[0] => id
)
[fields:protected] => stdClass Object
(
[id] => 34
[company] => Company Name
[first_name] => John
[last_name] => doe
[email] => [email protected]
[phone] => 123-456-7890
[date_created] => Tue, 19 Jul 2016 23:40:14 +0000
[date_modified] => Wed, 10 Aug 2016 17:39:28 +0000
[store_credit] => 0.0000
[registration_ip_address] =>
[customer_group_id] => 6
[notes] =>
[tax_exempt_category] =>
[reset_pass_on_login] =>
[accepts_marketing] =>
[addresses] => stdClass Object
(
[url] => https://example.com/api/v2/customers/34/addresses.json
[resource] => /customers/34/addresses
)
[form_fields] => Array
(
[0] => stdClass Object
(
[name] => Occupation
[value] => Developer
)
)
)
[id:protected] => 34
[ignoreIfZero:protected] => Array
(
)
[fieldMap:protected] => Array
(
)
)
Form_fields 目前只能获取,并且仅在打开了特定“商店实验”的商店中可用。我们的文档中已省略这一点,因此我们将努力更新它以提供更好的清晰度。