PHP code example of shopifyextras / shopify-php-api-wrapper

1. Go to this page and download the library: Download shopifyextras/shopify-php-api-wrapper 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/ */

    

shopifyextras / shopify-php-api-wrapper example snippets




$client = new \Shopify\Client([
   "shopUrl" => $shopUrl,
   "X-Shopify-Access-Token" => $accessToken
]);

// Get a list of all orders.
$client->getOrders();

// Get a specific order.
$client->getOrder(['id' => $order_id]);

// Get Order ID and Total Price for a specific order. 
$client->getOrder(['id' => $order_id, 
                   'fields' => 'id,total_price']);

// Get a list of all products.
$client->getProducts();

// Get a specific product.
$client->getProduct(["id" => $product_id]);

// Get a list of all variants for a specific product.
$client->getProductVariants(["id" => $product_id]);

// Get a specific product variant.
$client->getProductVariant(["id" => $variant_id]);

// Get metafields for a specific variant. 
$client->getProductVariantMetafields(["id" => $variant_id]);
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php