Esempio n. 1
0
function verifyShopStatus($conn, $shop)
{
    if ($shop = getShopDetails($conn, $shop)) {
        if ($shop['token'] != '') {
            return $shop;
        }
    }
    return false;
}
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'));
            $res[] = $shopify('POST /admin/script_tags.json', $scriptTag);
            // add Order/Create Webhook
            $webhook = array('webhook' => array('topic' => 'orders/create', 'address' => 'https://retargeting.biz/shopify/webhooks/orders/create.php', 'format' => 'json'));
            $res[] = $shopify('POST /admin/webhooks.json', $webhook);
        } else {
            // disable Retargeting App
            $stBase = null;
Esempio n. 3
0
        echo 'App Successfully Installed! <br> go back to the admin!';
    } 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());
    }
    // [end]OAUTH
} else {
    shopify\is_valid_request($_GET, SHOPIFY_APP_SHARED_SECRET) or die('Invalid Request! Request or redirect did not come from Shopify');
    $shop = getShopDetails($conn, $_GET['shop']);
    $shopify = shopify\client($shop['shop'], SHOPIFY_APP_API_KEY, $shop['token']);
    $shopShopifyDetails = $shopify('GET /admin/shop.json');
    $_SESSION['oauth_token'] = $shop['token'];
    $_SESSION['shop'] = $shop['shop'];
    $shopify = shopify\client($shop['shop'], SHOPIFY_APP_API_KEY, $shop['token']);
    //require __DIR__.'/admin_preload.php';
    $view['status'] = $shop['status'];
    $view['init'] = $shop['init'];
    $view['domain'] = $shop['domain'] != '' ? $shop['domain'] : $shop['shop'];
    $view['domain_api_key'] = $shop['domain_api_key'];
    $view['api_token'] = $shop['api_token'];
    $view['help_pages'] = $shop['help_pages'];
    $view['qs_add_to_cart'] = $shop['qs_add_to_cart'];
    $view['qs_variation'] = $shop['qs_variation'];
    $view['qs_add_to_wishlist'] = $shop['qs_add_to_wishlist'];