PHP code example of zohaib-vaival / php-cartzy

1. Go to this page and download the library: Download zohaib-vaival/php-cartzy 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/ */

    

zohaib-vaival / php-cartzy example snippets


$config = array(
    'ShopUrl' => 'yourshop.cartzy.com',
    'ApiKey' => '***YOUR-PRIVATE-API-KEY***',
    'Password' => '***YOUR-PRIVATE-API-PASSWORD***',
);

PHPCartzy\CartzySDK::config($config);

$config = array(
    'ShopUrl' => 'yourshop.cartzy.com',
    'AccessToken' => '***ACCESS-TOKEN-FOR-THIRD-PARTY-APP***',
);

PHPCartzy\CartzySDK::config($config);

$config = array(
    'ShopUrl' => 'yourshop.cartzy.com',
    'ApiKey' => '***YOUR-PRIVATE-API-KEY***',
    'SharedSecret' => '***YOUR-SHARED-SECRET***',
);

PHPCartzy\CartzySDK::config($config);

//your_authorize_url.php
$scopes = 'read_products,write_products,read_script_tags,write_script_tags';
//This is also valid
//$scopes = array('read_products','write_products','read_script_tags', 'write_script_tags'); 
$redirectUrl = 'https://yourappurl.com/your_redirect_url.php';

\PHPCartzy\AuthHelper::createAuthRequest($scopes, $redirectUrl);

\PHPCartzy\AuthHelper::createAuthRequest($scopes, $redirectUrl, null, null, true);

//your_redirect_url.php
PHPCartzy\CartzySDK::config($config);
$accessToken = \PHPCartzy\AuthHelper::getAccessToken();
//Now store it in database or somewhere else

//your_authorize_and_redirect_url.php
PHPCartzy\CartzySDK::config($config);
$accessToken = \PHPCartzy\AuthHelper::createAuthRequest($scopes);
//Now store it in database or somewhere else

$Cartzy = new PHPCartzy\CartzySDK;

$Cartzy = new PHPCartzy\CartzySDK($config);

$config = array(
    'ClientID' => '***CLIENT-ID-FOR-THIRD-PARTY-APP***',
    'ShopUrl' => 'yourshop.cartzy.com',
    'AccessToken' => '***ACCESS-TOKEN-FOR-THIRD-PARTY-APP***',
);

PHPCartzy\CartzySDK::config($config);
$discountCode = new PHPCartzy\Discount\DiscountCode();
$resp = $discountCode->get();
shell
composer