PHP code example of sairum123 / laravel-bigcommerce
1. Go to this page and download the library: Download sairum123/laravel-bigcommerce library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sairum123 / laravel-bigcommerce example snippets 5
'providers' => [
...
Oseintow\Bigcommerce\BigcommerceServiceProvider::class,
],
5
'aliases' => [
...
'Bigcommerce' => Oseintow\Bigcommerce\Facades\Bigcommerce::class,
],
5
Route::get("process_oauth_result",function(\Illuminate\Http\Request $request)
{
$response = Bigcommerce::getAccessToken($request->code, $request->scope, $request->context));
dd($response);
});
5
Bigcommerce::setApiVersion('v2');
5
Bigcommerce::setApiVersion('v3');
5
Bigcommerce::get("resource uri",["query string params"]);
Bigcommerce::post("resource uri",["post body"]);
Bigcommerce::put("resource uri",["put body"]);
Bigcommerce::delete("resource uri");
5
$storeHash = "ecswer";
$accessToken = "xxxxxxxxxxxxxxxxxxxxx";
$products = Bigcommerce::setStoreHash($storeHash)->setAccessToken($accessToken)->get("products");
5
// returns Collection
$bigcommerce = Bigcommerce::setStoreHash($storeHash)->setAccessToken($accessToken);
$products = $bigcommerce->get("admin/products.json", ["limit"=>20, "page" => 1]);
5
use Illuminate\Http\Request;
use Oseintow\Bigcommerce\Bigcommerce;
class Foo
{
protected $bigcommerce;
public function __construct(Bigcommerce $bigcommerce)
{
$this->bigcommerce = $bigcommerce;
}
/*
* returns Collection
*/
public function getProducts(Request $request)
{
$products = $this->bigcommerce->setStoreHash($storeHash)
->setAccessToken($accessToken)
->get('products');
$products->each(function($product){
\Log::info($product->title);
});
}
}
5
Bigcommerce::getHeaders();
5
Bigcommerce::getHeader("Content-Type");
5
Bigcommerce::getStatus(); // 200
5
$time = Bigcommerce::getTime();
5
// oauth
$storeHash = "afw2w";
$accessToken = "xxxxxxxxxxxxxxxxxxxxx";
$products = Bigcommerce::setStoreHash($storeHash)->setAccessToken($accessToken)->getProducts();
//Basic Auth
$products = Bigcommerce::getProducts();
5
$filter = array("page" => 3, "limit" => 30);
$products = Bigcommerce::getProducts($filter);
5
$filter = array("is_featured" => true);
$featured = Bigcommerce::getProducts($filter);
5
$product = Bigcommerce::getProduct(11);
$product->name = "MacBook Air";
$product->price = 99.95;
$product->update();