Reputation: 449
Checked out similar questions on Stackoverflow but, being a newbie to BC, still having real trouble with this one. Trying to create a new customer using Bigcommerce API (PHP).
I've been able to connect to my Bigcommerce store using API (PHP) and get data, for example, a list of customers. The code (just a test for the moment) I used is as follows:
require_once "bigcommerce-api/bigcommerce.php";
use Bigcommerce\Api\Client as Bigcommerce;
Bigcommerce::configure(array(
'store_url' => 'https://store-xxxxxxxx.mybigcommerce.com/',
'username' => 'admin',
'api_key' => 'xxxxxxxxxxxxxxxxxxxx'
));
Bigcommerce::setCipher('RC4-SHA');
Bigcommerce::verifyPeer(false);
$customers = Bigcommerce::getCustomers();
foreach($customers as $customer) {
echo $customer->first_name;
echo $customer->last_name;
echo "<br/>";
}
My question is, how do I write the PHP code to create a new customer in my Bigcommerce store?
Thanks,
Mekong
Upvotes: 0
Views: 395
Reputation: 449
It's OK guys, I've got it sorted. Just my rough, test code but it works (hooray!):
$first_name = "Willy";
$last_name = "Wonka";
$email = "[email protected]";
$company = "Wonka Pty Ltd";
$phone = "03 9699 1234";
$store_credit = "0";
$customer_group_id = "2";
$authentication = "harry1";
$createFields = array('first_name'=>$first_name,'last_name'=>$last_name,
'email'=>$email, 'company'=>$company,'phone'=>$phone,
'store_credit'=>$store_credit,'customer_group_id'=>$customer_group_id,
'_authentication'=>$authentication);
$customers = Bigcommerce::createCustomer($createFields);
Upvotes: 1