Bigcommerce creates an order error API in PHP… here is a solution to the problem.
Bigcommerce creates an order error API in PHP
I want
to add an order in my bigcommerce store, you know what, I want to use the following code:
$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"=> "[email protected]"),);
$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"=> "[email protected]"
)
,);
$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);
I get the error
bool(false),
I see this error when using the POST method request, can you answer this question, please guide me.
Solution
Please replace your array with the one below
$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"=> "[email protected]"
);
$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"=> "[email protected]"
)
,);
$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);
Then check if it is working now.