我想在我的bigcommerce商店中添加订单,让我知道我想使用以下代码:
$billing_array = array(array("first_name"=> "MG",
"last_name"=> "Shah",
"company"=> "",
"street_1"=> "12345 W Anderson Ln",
"street_2"=> "",
"city"=> "Austin",
"state"=> "Texas",
"zip"=> "78757",
"country"=> "United States",
"country_iso2"=> "US",
"phone"=> "",
"email"=> "a@example.com"),);
$shipping_array = array(
array( "first_name"=> "MG",
"last_name"=> "Shah",
"company"=> "",
"street_1"=> "12345 W Anderson Ln",
"street_2"=> "",
"city"=> "Austin",
"state"=> "Texas",
"zip"=> "78757",
"country"=> "United States",
"country_iso2"=> "US",
"phone"=> "",
"email"=> "a@example.com"
)
,);
$products_array= array();
for($i=0;$i<sizeof($products);$i++)
{
$products_array[] = array(array('product_id' => $products[$i]['products_id'],
'quantity' => $products[$i]['products_qty']),);
}
$createFields= array(
"customer_id" => 0,
"status_id"=> 10,
"billing_address"=> $billing_array,
"shipping_addresses"=>$shipping_array,
"products"=>$products_array,
"external_source"=> "POS"
);
$data_array_jason = json_encode($createFields);
$products_passed = Bigcommerce::createOrder($data_array_jason);
我收到了错误bool(false),使用POST方法请求时看到此错误,您可以对此问题有任何答案吗,请对此进行指导.
最佳答案
请用下面的数组替换你的数组
$billing_array = array(
"first_name"=> "MG",
"last_name"=> "Shah",
"company"=> "",
"street_1"=> "12345 W Anderson Ln",
"street_2"=> "",
"city"=> "Austin",
"state"=> "Texas",
"zip"=> "78757",
"country"=> "United States",
"country_iso2"=> "US",
"phone"=> "",
"email"=> "a@example.com"
);
$shipping_array = array(
array( "first_name"=> "MG",
"last_name"=> "Shah",
"company"=> "",
"street_1"=> "12345 W Anderson Ln",
"street_2"=> "",
"city"=> "Austin",
"state"=> "Texas",
"zip"=> "78757",
"country"=> "United States",
"country_iso2"=> "US",
"phone"=> "",
"email"=> "a@example.com"
)
,);
$products_array= array();
for($i=0;$i<sizeof($products);$i++){
$products_array[] = array( 'product_id' => $products[$i]['products_id'],
'quantity' => $products[$i]['products_qty']
);
}
$createFields= array(
"customer_id" => 0,
"status_id"=> 10,
"billing_address"=> $billing_array,
"shipping_addresses"=>$shipping_array,
"products"=>$products_array,
"external_source"=> "POS"
);
$data_array_jason = json_encode($createFields);
$products_passed = Bigcommerce::createOrder($data_array_jason);
然后检查它是否可以正常工作.
Inm小程序商店
Inm小程序商店收录了最新,最热门的微信小程序和微信小游戏,是国内内容最丰富的集小程序游戏、小程序分发、小程序推广为一体的综合性小程序门户网站之一。
Vultr中文网
最低 $2.5/月 的VPS, 稳定, 可靠