From d0526c9c5b504bd1a2665a6a0dbb1202c615c913 Mon Sep 17 00:00:00 2001 From: Seersco Date: Wed, 20 Apr 2022 13:21:04 +0500 Subject: [PATCH] Shopify app_bridge backwork compatibility --- include/common_function.php | 20 +++++----- index.php | 2 + user/app_bridge.php | 80 +++++++++++++++++++++++++++++++------ 3 files changed, 79 insertions(+), 23 deletions(-) diff --git a/include/common_function.php b/include/common_function.php index 6895b06..a0ca1a3 100644 --- a/include/common_function.php +++ b/include/common_function.php @@ -485,7 +485,7 @@ class common_function { $cbattrjspath = 'https://seers-application-assets.s3.amazonaws.com/scripts/cbattributes.js'; $arrscriptexist = [false, false]; - + //get all avialable tags $allscriptags = $this->prepare_api_condition(array('script_tags'), array(), 'GET', '0', $token, $shop); @@ -503,12 +503,12 @@ class common_function { $arrscriptexist[1] = false; //remove the script $scriptdel = $this->prepare_api_condition(array('script_tags', $thescript['id']), array(), 'DELETE', '0', $token, $shop); - } + } } - - } - + + } + foreach ($arrsrc as $sitind => $sitesrc) { if (!$arrscriptexist[$sitind]) { @@ -516,12 +516,12 @@ class common_function { //add this src in scripts $scriptinsert = $this->prepare_api_condition(array('script_tags'), array('script_tag' => array( "event"=>"onload", "src"=>$sitesrc)), 'POST', '0', $token, $shop); -} - -} + } + + } } - + public function plugin_active_inactive($shopdetail, $isative = 0){ $postData = array( 'domain' => $shopdetail['shop'], @@ -559,7 +559,7 @@ class common_function { $response =json_decode($response, TRUE); return $response; -} + } } diff --git a/index.php b/index.php index a5b13b9..329cc31 100644 --- a/index.php +++ b/index.php @@ -32,6 +32,7 @@ if (isset($_REQUEST['shop']) && $_REQUEST['shop'] != "") { $store_row = $cf_obj->select_row(TABLE_USER_STORES, $selected_field, $where); if (isset($_GET['code'])) { + $thehost = (!empty($_REQUEST['host']) ? $_REQUEST['host'] : ""); $url_param_arr = array('client_id' => SHOPIFY_API_KEY, 'client_secret' => SHOPIFY_SECRET, 'code' => $_GET['code']); $responce = $cf_obj->prepare_api_condition(array('oauth', 'access_token'), $url_param_arr, 'POST', 0, '', $shop); @@ -63,6 +64,7 @@ if (isset($_REQUEST['shop']) && $_REQUEST['shop'] != "") { 'email' => $email, 'name' => mysqli_real_escape_string($cf_obj->db_connection, $shopinfo['name']), /* e.g example */ 'shop' => $shop, /* e.g example.myshopify.com */ + 'host' => $thehost, 'domain' => $shopinfo['domain'], 'token' => $token, 'owner' => $shopinfo['shop_owner'], diff --git a/user/app_bridge.php b/user/app_bridge.php index 21964e8..b7fcb45 100644 --- a/user/app_bridge.php +++ b/user/app_bridge.php @@ -1,17 +1,66 @@ - + + ' : "" ); ?> + - +