在Stackoverflow上查看了类似的问题,但作为BC的新手,仍然遇到了这个问题。尝试使用Bigcommerce API(PHP)创建新客户。
我已经能够使用API(PHP)连接到我的Bigcommerce商店并获取数据,例如客户列表。我使用的代码(只是当下的测试)如下:
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/>";
}
我的问题是,如何编写PHP代码以在我的Bigcommerce商店中创建新客户?
谢谢,
湄公河
答案 0 :(得分:1)
好的伙计们,我已经把它整理好了。只是我的粗糙,测试代码,但它的工作原理(万岁!):
$first_name = "Willy";
$last_name = "Wonka";
$email = "willy@wonkaville.com";
$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);