Bigcommerce is revolutionary ready eCommerce platform. Its allow to create e-store instantly with latest features. Bigcommerce has own web service, which provide to access store data outside or to integrate with any third party service.
Adding New Product in Bigcommerce via API
For Add new product in Bigcommerce account. You need to pass required product parameter in json encoded form.
First create an array of product required parameters.
1 2 3 4 5 6 7 8 9 10 |
$data_array = array( 'name'=>'product name', 'description' =>'description of product', 'retail_price' =>'list price of product', 'weight' =>'weight', 'depth' =>'length of product', 'height' =>'height', 'width' =>'width', 'inventory_level' =>'number of items in stock' ); |
Than you have to encode the $data_array in json form.
$body=json_encode($data_array);
Using php curl code you can post the API request in bigcommerce. Check below curl code to add new product in bigcommerce via its api.
$headers = array(
“Content-type: application/json”
);
Use json content application in curl header request.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
$chbig = curl_init('https://store-l3wxicl1.mybigcommerce.com/api/v2/products'); //open connection curl_setopt($chbig, CURLOPT_TIMEOUT, 60); //set to 60 seconds from BC API Guide v1 PDF example curl_setopt($chbig, CURLOPT_HTTPHEADER, $headers); //load all header data curl_setopt($chbig, CURLOPT_CUSTOMREQUEST, "PUT"); //comment out this PUT line to change to a POST statement curl_setopt( $chbig, CURLOPT_SSL_VERIFYPEER, 0 ); curl_setopt( $chbig, CURLOPT_USERPWD, ***username***:***api key***); curl_setopt($chbig, CURLOPT_POSTFIELDS, $body); curl_setopt( $chbig, CURLOPT_SSL_VERIFYHOST, 0 ); curl_setopt( $chbig, CURLOPT_RETURNTRANSFER, 1 ); $result = curl_exec($chbig); //execute post curl_close($chbig); $result1 = json_decode($result); echo "<pre>"; print_r($result1); if ($result == true) { echo 'Product updated successfully'; } else { echo 'An error occured while updating the product.'; } |
In this curl code, use your bigcommerce admin username and api key to access the api request. After post this request new product is added in account.
You can also add new product with SKU, for that use this api request url : https://store-l3wxicl7.mybigcommerce.com/api/v2/products/{product_id}/sku.
Help me i add images to product use php
Hi Zacaca
To add image for product just need to pass “image_file” parameter as image path value. Its use Basic POST curl code to this request URL : /api/v2/products/{product_id}/images.
Place your product id in request URL.
Thanks
Hi Harish
you demo for me ?
$data_array = array(
‘name’=>’product name’,
“type”=> “physical”,
‘description’ =>’description of product’,
‘price’ =>’21.98′,
‘retail_price’ =>’21.98′,
‘weight’ =>’0.5′,
‘depth’ =>’12’,
“categories” => [23],
“availability”=> “available”,
‘inventory_level’ =>’0′,
“videos” => “https://www.youtube.com/watch?v=VNxnvMbmvN0”,
“image_file” => “https://www.codefixup.com/wp-content/uploads/2016/09/add-products-in-jet-com-via-api.png”
);
thanks
You fix me code
I am tried to use above code.. but in print i am getting Null..
Means Not able to Create Project at my store. Can you please help me for that?
Hi Ricky,
Might be an parameter error. Please check post parameter data again.
If facing issue after that, please email me your script code at [email protected]
Thanks
I have send you code which i have implemented.
Okay, will check and update you.
Okay, thanks a lot..
Hello, I have Resolved the issue.. Yes you are right there is parameter issue..
I also have send you new mail.
Kindly Please check
Thank You
Hello HARISH,
As per per last discussion for webhooks. Can you send me the example of webhooks when new products created.. because as i checked i am not able to get solution for that . please help me for that.
thanks
Hello Harish,
How to do the same approach when adding NEW ORDERS?
Thank you!
Hi,
Same POST API call will work for create new Order. Follow the Official API Documentation and send correct create order parameter in API call.
Thanks
Hell Sir,
How can i add product image..??
please share code for adding product with product image.
Hi Saurabh,
Same code works to add product image. Just check product object properties in BigCommerce Official API documentation.
Their is parameter explained in Product Reference.
Thanks
Hello Can you please help me how to crate an order using api
Hi Siddhesh,
Creating an order is something similar as Adding Products. You can use POST API request with order parameters to create an order.
Product must exist in Bigcommerce, than only you can create an order. Please check official documentation for exact API Request Parameter. https://developer.bigcommerce.com/api/v2/#create-an-order
If you need my paid service, please let me know. Will create an API call for you.
Thanks
i want to add order in my store like user give order can you help me on this topic..?
Have you tried with POST API call ? what issue you getting ?
issue is “400The field ‘products’ is invalid.” so how i pass products in api call
If you are adding products first than follow above mentioned post. After adding you will get product ID, which you can pass along with create new order API request parameters.
And if products already exist in store, than also get that product ID and pass in order API request.
Thanks
No no i want to add order using api
If I try two calls like this, It gives me easy handle already used in multi handle error
If I remove one of them , it works fine.
Bigcommerce::getCustomer($customer_id);
Bigcommerce::getProduct($product_id);
Thank You