PHP code example of bold-commerce / bold-shopify-toolkit

1. Go to this page and download the library: Download bold-commerce/bold-shopify-toolkit 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/ */

    

bold-commerce / bold-shopify-toolkit example snippets


    $this->app->bind(\BoldApps\ShopifyToolkit\Contracts\ApiSleeper::class,
            \BoldApps\ShopifyToolkit\Support\ShopifyApiHandler::class);


    $this->app->bind(\BoldApps\ShopifyToolkit\Contracts\ApiSleeper::class,
            \BoldApps\ShopifyToolkit\Support\ShopifyApiHandler::class);

    ...

        $shopifyApiHandler = new ShopifyApiHandler();
        $this->getContainer()->addShared(RequestHookInterface::class, $shopifyApiHandler);
        $this->getContainer()->addShared(ApiSleeper::class, $shopifyApiHandler);

// $shop - Eloquent model containing at least the myshopify_domain ("example.myshopify.com")
app()->instance(BoldApps\ShopifyToolkit\Contracts\ShopBaseInfo::class, $shop);
 
// $accessToken - Contains the access token string created when the shop installed the app
app()->instance(BoldApps\ShopifyToolkit\Contracts\ShopAccessInfo::class, $accessToken);

$variantService = new BoldApps\ShopifyToolkit\Services\Variant();
//OR
$variantService = app()->make(BoldApps\ShopifyToolkit\Services\Variant::class);

/** @var BoldApps\ShopifyToolkit\Models\Variant $variant */
$variant = $variantService->getById(2641814487051);
 
$variant->getPrice(); //99.0

/** @var Illuminate\Support\Collection $variants */
$variants = $variantService->getAllByProductId(327661486091, ["fields" => "title"]);
 
/** @var BoldApps\ShopifyToolkit\Models\Variant $variant */
foreach ($variants as $variant) {
    $title = $variant->getTitle(); //"Default title"
}

$variant->setOption1("Not pink");
 
$updatedVariant = $variantService->update($variant);
 
$updatedVariant->getOption1(); //"Not pink"