PHP code example of arslaniftikhar / shopify-client

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

    

arslaniftikhar / shopify-client example snippets


$shopify = new Shopify($shop, $APP_API_KEY, $APP_SECRET);

$client->installURL($permissions, $redirect_uri, $auto_redirect = true);

session_start();
$shopify = new Shopify($_GET['shop'], $APP_API_KEY, $APP_SECRET);

if ($token = $client->getAccessToken()) {
    // You can save the access token to database to make the api call in future.
  $_SESSION['shopify_access_token'] = $token;
  $_SESSION['shopify_shop_domain'] = $_GET['shop'];
  // Redirect to app's dashboard URL
  header("Location: dashboard.php");
}
else {
  die('Couldn't find the access token');
}


session_start();
$shopify = new Shopify(, $APP_API_KEY, $APP_SECRET);
$shopify->setAccessToken($_SESSION['shopify_access_token']);

// you can get the resource by just passing the resource name.
$products = $shopify->get('products');

$shopify = new Shopify($SHOPIFY_SHOP_DOMAIN, $SHOPIFY_API_KEY, $SHOPIFY_SHARED_SECRET);
$result = $shopify->get('shop');

$result = $shopify->get('products', ['query' => ['fields' => 'id']]);
foreach($result->products as $product) {
  print $product->id;
}

$data = ['product' => ['title' => 'my new product']];
$result = $shopify->post('products', $data);

$data = ['product' => ['title' => 'updated product name']];
$result = $shopify->put('products/' . $product_id, $data);

$shopify->delete('products/' . $product_id);