function add_product_to_collection($product_id, $collection_id)
{
    $shopify = shopify\client(SHOPIFY_SHOP, SHOPIFY_APP_API_KEY, SHOPIFY_APP_PASSWORD, true);
    try {
        # Making an API request can throw an exception
        $collect = $shopify('POST /admin/collects.json', array(), array('collect' => array('product_id' => $product_id, 'collection_id' => $collection_id)));
        return array('collect' => $collect, 'success' => 'true');
    } catch (shopify\ApiException $e) {
        # HTTP status code was >= 400 or response contained the key 'errors'
        return array('request' => $e->getRequest(), 'response' => $e->getResponse(), 'error' => $e, 'success' => 'false');
    } catch (shopify\CurlException $e) {
        # cURL error
        return array('request' => $e->getRequest(), 'response' => $e->getResponse(), 'error' => $e, 'success' => 'false');
    }
}
Пример #2
0
<?php

session_start();
require __DIR__ . '/vendor/autoload.php';
use phpish\shopify;
require __DIR__ . '/conf.php';
$shopify = shopify\client(SHOPIFY_SHOP, SHOPIFY_APP_API_KEY, SHOPIFY_APP_PASSWORD, true);
echo "<pre>";
try {
    # Making an API request can throw an exception
    $products = $shopify('GET /admin/products.json', array('published_status' => 'published'));
} catch (shopify\ApiException $e) {
    # HTTP status code was >= 400 or response contained the key 'errors'
    echo $e;
    print_R($e->getRequest());
    print_R($e->getResponse());
} catch (shopify\CurlException $e) {
    # cURL error
    echo $e;
    print_R($e->getRequest());
    print_R($e->getResponse());
}
foreach ($products as $key => $product) {
    try {
        # Making an API request can throw an exception
        $response = $shopify('DELETE /admin/products/' . $product['id'] . '.json', array());
        echo $key . '\\r\\n';
    } catch (shopify\ApiException $e) {
        # HTTP status code was >= 400 or response contained the key 'errors'
        echo $e;
        print_R($e->getRequest());
<?php

session_start();
require __DIR__ . '/db.php';
require __DIR__ . '/vendor/autoload.php';
use phpish\shopify;
require __DIR__ . '/conf.php';
if (isset($_POST['domain_api_key']) && isset($_POST['api_token']) && isset($_SESSION['oauth_token'])) {
    $shopify = shopify\client($_SESSION['shop'], SHOPIFY_APP_API_KEY, $_SESSION['oauth_token']);
    $newDomain = $_POST['domain'];
    $newDomainApiKey = $_POST['domain_api_key'];
    $newApiToken = $_POST['api_token'];
    $changeStatus = isset($_POST['changeStatus']) ? true : false;
    $newHelpPages = $_POST['help_pages'];
    $newAddToCart = $_POST['qs_add_to_cart'];
    $newVariation = $_POST['qs_variation'];
    $newAddToWishlist = $_POST['qs_add_to_wishlist'];
    $newImage = $_POST['qs_image'];
    $newReview = $_POST['qs_review'];
    $newPrice = $_POST['qs_price'];
    $response = updateShopDetails($conn, $_SESSION['shop'], $_SESSION['oauth_token'], $newDomain, $newDomainApiKey, $newApiToken, $changeStatus, $newHelpPages, $newAddToCart, $newVariation, $newAddToWishlist, $newImage, $newReview, $newPrice);
    try {
        $shop = getShopDetails($conn, $_SESSION['shop']);
        $res = array();
        if ($shop['status']) {
            // enable Retargeting App
            // base embedding
            $scriptTag = array('script_tag' => array('event' => 'onload', 'src' => 'https://retargeting.biz/shopify/js/embedd.php'));
            $res[] = $shopify('POST /admin/script_tags.json', $scriptTag);
            // triggers
            $scriptTag = array('script_tag' => array('event' => 'onload', 'src' => 'https://retargeting.biz/shopify/js/triggers.php'));
Пример #4
0
<?php

session_start();
require __DIR__ . '/db.php';
require __DIR__ . '/vendor/autoload.php';
use phpish\shopify;
require __DIR__ . '/conf.php';
if (isset($_GET['shop']) && ($shop = verifyShopStatus($conn, $_GET['shop']))) {
    $shopify = shopify\client($shop['shop'], SHOPIFY_APP_API_KEY, $shop['token']);
    if (isset($_GET['t'])) {
        if ($_GET['t'] == 'sendProduct') {
            $productHandle = $_GET['h'];
            $categoryHandle = $_GET['hc'];
            if ($productHandle == '') {
                echo 'false';
                return false;
            }
            try {
                $product = $shopify('GET /admin/products.json?handle=' . $productHandle);
                if (count($product) > 0) {
                    $product = $product[0];
                    $productImage = '';
                    if (array_key_exists('image', $product)) {
                        $productImage = $product['image']['src'];
                    }
                    // $category = 'false';
                    $category = '{
							"id": 1,
							"name": "Root",
							"parent": false,
							"breadcrumb": []
Пример #5
0
        $upsell_products = $row['upsell_product'];
        $shop_id = $row['shop_id'];
        $upsell_show = $row['upsell_show'];
        $title_upsell = $row['title_upsell'];
        $body_upsell = $row['body_upsell'];
    }
}
$result = pg_query($db, "SELECT * from app_shop_data where shop_id='{$shop_id}'");
if (pg_num_rows($result) > 0) {
    while ($row = pg_fetch_array($result)) {
        $shop_url = $row['shop_url'];
    }
}
$upsell_product = explode(",", $upsell_products);
$count_upsell = count($upsell_product);
$shopify = shopify\client($shop_url, SHOPIFY_APP_API_KEY, $token);
?>
 document.write("<div id='cartrelatedproduct' style='display:none'><a class='fancybox-close1' href='/cart'></a><div class='popup'><div class='content'><div id='four-product' class='product-upsell'><div class='opt1' ><div class='upsell-description'><?php 
echo $title_upsell;
?>
</div><div class='upsell-description-small' style=''><?php 
echo $body_upsell;
?>
</div></div><div class='hidd mobilecontent' style='display:none'><div  id='relCarousel1' class='container jsCollection row-store-collection relCarousel_1'><?php 
for ($i = 0; $i < $count_upsell; $i++) {
    $up_p_id = $upsell_product[$i];
    $products = $shopify("GET /admin/products/{$upsell_product[$i]}.json", array('published_status' => 'published'));
    $upsell_product_id = $products['id'];
    ?>
 <div class='col-md-3 col-sm-3 col-xs-12'> <div class='product_image'>   <center>   		<img style='width:auto;' src='<?php 
    echo $products['image']['src'];