I'm using the Bigcommerce php library to create customers through the API, which works fine, but I get {"status":400,"message":"The field 'name' is invalid."}
back when I try adding the form_fields
array of objects to the call. Is it possible to include these in a createCustomer call?
Here's basically what I'm trying to do:
$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));
Also, here's what a Bigcommerce customer record looks like:
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@example.com
[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 are currently GET only and they are only available in stores with a specific "store experiment" turned on. This has been omitted from our documentation, so we will work on updating that to provide better clarity.