Ïnitial Commit App
This commit is contained in:
parent
ebde8bc052
commit
f9dee33e2f
26 changed files with 6860 additions and 0 deletions
39
user/ajax_actions.php
Normal file
39
user/ajax_actions.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
/* include main config file file */
|
||||
include_once ('../include/config.php');
|
||||
/* include main client function file */
|
||||
include_once ('user_functions.php');
|
||||
|
||||
//ob_clean();
|
||||
|
||||
$is_bad_shop = 0;
|
||||
if (isset($_POST['shop']) && $_POST['shop'] != '') {
|
||||
|
||||
if(isset($_POST['is_analytics']) && $_POST['is_analytics']=='1'){
|
||||
include_once ('analytics.php');
|
||||
$uf_obj = new Analytics($_POST['shop']);
|
||||
}else{
|
||||
$uf_obj = new User_functions($_POST['shop']);
|
||||
}
|
||||
|
||||
$current_user = $uf_obj->get_store_detail_obj();
|
||||
|
||||
if (!empty($current_user)) {
|
||||
/* used for called function (comes from ajax call) */
|
||||
if (isset($_POST['method_name']) && $_POST['method_name'] != '') {
|
||||
$response = call_user_func(array($uf_obj, $_POST['method_name']));
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$is_bad_shop ++;
|
||||
}
|
||||
} else {
|
||||
$is_bad_shop ++;
|
||||
}
|
||||
|
||||
if ($is_bad_shop > 0) {
|
||||
$response = array('result' => 'fail', 'msg' => 'Opps! Bad request call!', 'code' => '403');
|
||||
echo json_encode($response);
|
||||
}
|
34
user/app_bridge.php
Normal file
34
user/app_bridge.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php if (MODE == 'live') { ?>
|
||||
<script src="https://cdn.shopify.com/s/assets/external/app.js"></script>
|
||||
<script type="text/javascript">
|
||||
var query_output = '';
|
||||
ShopifyApp.init({
|
||||
forceRedirect: true,
|
||||
apiKey: '<?php echo SHOPIFY_API_KEY; ?>',
|
||||
shopOrigin: 'https://<?php echo $shop; ?>'
|
||||
});
|
||||
ShopifyApp.ready(function () {
|
||||
ShopifyApp.Bar.initialize({
|
||||
buttons: {
|
||||
secondary: [{"label": "Dashboard", "href": "index.php?shop=<?php echo $shop; ?>"}]}
|
||||
});
|
||||
var shopifyQL = 'SHOW ua_browser_version, ua_os, ua_form_factor, ua_os_version, ua_browser, referrer_host, page_type, page_path, page_url, page_resource_id, referrer_host, referrer_name, referrer_path, referrer_url, referrer_source, utm_campaign_content, utm_campaign_term, utm_campaign_medium, utm_campaign_source, utm_campaign_name, location_country, location_region, location_city OVER day(timestamp) AS day FROM visits SINCE -7d UNTIL today ORDER BY day ASC';
|
||||
//var shopifyQL = 'SELECT * FROM shopify.online_store_sessions';
|
||||
var renderData = function (response) {
|
||||
query_output = response;
|
||||
console.log('renderData',JSON.stringify(response));
|
||||
// do amazing things here
|
||||
};
|
||||
var handleError = function (response) {
|
||||
console.log('handleError',response);
|
||||
// handle missing API errors here (missing scopes, back shopifyql, etc...)
|
||||
};
|
||||
ShopifyApp.Analytics.fetch({
|
||||
query: shopifyQL,
|
||||
success: renderData,
|
||||
error: handleError
|
||||
});
|
||||
});
|
||||
ShopifyApp.Bar.loadingOff();
|
||||
</script>
|
||||
<?php } ?>
|
18
user/error_log
Normal file
18
user/error_log
Normal file
|
@ -0,0 +1,18 @@
|
|||
[25-Aug-2020 18:44:43 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[25-Aug-2020 18:48:14 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[25-Aug-2020 18:49:17 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[31-Aug-2020 12:16:50 UTC] PHP Recoverable fatal error: Object of class common_function could not be converted to string in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/user_functions.php on line 45
|
||||
[31-Aug-2020 12:16:55 UTC] PHP Recoverable fatal error: Object of class common_function could not be converted to string in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/user_functions.php on line 45
|
||||
[31-Aug-2020 12:37:50 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[31-Aug-2020 12:38:14 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[31-Aug-2020 12:39:14 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[01-Sep-2020 04:30:07 UTC] PHP Parse error: syntax error, unexpected '}' in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/index.php on line 39
|
||||
[09-Sep-2020 06:50:13 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 06:50:34 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 06:50:58 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 06:51:14 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 06:53:05 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 06:59:39 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 07:02:12 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 07:03:51 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
||||
[09-Sep-2020 07:05:03 UTC] PHP Warning: Use of undefined constant PAGE_404 - assumed 'PAGE_404' (this will throw an Error in a future version of PHP) in /home/seerscoo/gdpr-cookie-consent-banner-cookie-notice-seers.seerscookieconsent.com/user/header.php on line 13
|
3
user/footer.php
Normal file
3
user/footer.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
</div>
|
||||
</body>
|
||||
</html>
|
39
user/header.php
Normal file
39
user/header.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/* include main config file file */
|
||||
include_once ('../include/config.php');
|
||||
|
||||
/* include main client function file */
|
||||
include_once ('user_functions.php');
|
||||
/* client function class variable */
|
||||
if (isset($_REQUEST['shop']) && $_REQUEST['shop'] != '') {
|
||||
$shop = $_REQUEST['shop'];
|
||||
$uf_obj = new User_functions($shop);
|
||||
$current_user = $uf_obj->get_store_detail_obj();
|
||||
if (empty($current_user)) {
|
||||
header('Location:' . PAGE_404 . '');
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
header('Location:' . PAGE_404 . '');
|
||||
exit;
|
||||
}
|
||||
$custom_client_mode_time = filemtime('../assets/css/custom.css');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo SITE_NAME; ?> | <?php echo $shop; ?></title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" media="screen" href="../assets/css/polaris.css" />
|
||||
<link rel="stylesheet" media="screen" href="../assets/css/custom.css?v=<?php echo $custom_client_mode_time; ?>" />
|
||||
|
||||
<!-- Js -->
|
||||
<script type="text/javascript">var shop = '<?php echo $shop; ?>'; var mode = '<?php echo MODE; ?>';</script>
|
||||
<script type="text/javascript" src="../assets/js/jquery-2.1.1.min.js"></script>
|
||||
<?php include_once('app_bridge.php'); ?>
|
||||
<script type="text/javascript" src="../assets/js/custom.js?v=<?php echo filemtime('../assets/js/custom.js'); ?>"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="Polaris-Page Polaris-Page--fullWidth">
|
74
user/index.php
Normal file
74
user/index.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
include_once('header.php');
|
||||
?>
|
||||
<div class="Polaris-Page__Content">
|
||||
<div class="Polaris-Banner">
|
||||
<p class="Polaris-Heading">Need any other help?</p>
|
||||
<p>We are always here to help you. Please <a class="Polaris-Link" href="mailto:<?php echo SITE_EMAIL; ?>" target="_blank">email us</a></p>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="Polaris-Banner-hol">
|
||||
<div class="Polaris-Banner-head"><span>Banner Settings</span>
|
||||
<p class="grey-text">Enable/disable banner in just one click.</p>
|
||||
</div>
|
||||
<div class="Polaris-Banner">
|
||||
<label>Domain URL:</label>
|
||||
<input class="input-text" type = "text" name="user_doamin" id="user_doamin" readonly value="<?php if(!empty($current_user['user_domain'])){ echo $current_user['user_domain']; }else{ echo $current_user['domain']; } ?>">
|
||||
<label>Email: *</label>
|
||||
<input class="input-text" type = "email" name="user_email" id="user_email" value="<?php if(!empty($current_user['user_email'])){ echo $current_user['user_email']; }else{ echo $current_user['email']; } ?>">
|
||||
<label>Domain Group ID:</label>
|
||||
<input class="input-text" type = "text" name="data_key" id="user_key" value="<?php echo @$current_user['data_key']; ?>" readonly>
|
||||
<p class="cooloes-text">CONSENT </p>
|
||||
<p class="cooloes-text">
|
||||
By using this plugin, you agree to the <a href='https://seersco.com/terms-and-conditions.html' target='_blank'>terms and condition</a> and <br> <a href='https://seersco.com/privacy-policy.html' target='_blank'>privacy policy</a>, and also agree Seers to use my email and url to <br> create an account and power the cookie banner.
|
||||
</p>
|
||||
<hr style="margin:0 auto 10px; border-bottom:.5px dotted #c1c1c1; width:95%">
|
||||
<p class="cooloes-text">You must enter Domain Url and Email to get a Consent Banner.</p>
|
||||
<?php if($current_user['toggle_status']==1){ ?>
|
||||
<p class="enable-banner"><span class ="banner-tick"></span> Banner is enabled on your store.<br><span style="margin-left:18px;"></span>Please refresh your store home page to see the effect. </p>
|
||||
<?php }else{?>
|
||||
<p class="enable-banner">Banner is disabled on your store.</p>
|
||||
<?php } ?>
|
||||
<div class="onoffswitch">
|
||||
<?php if($current_user['toggle_status']==1){ ?>
|
||||
|
||||
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked tabindex="0">
|
||||
<?php }else{ ?>
|
||||
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" tabindex="0">
|
||||
<?php } ?>
|
||||
<label class="onoffswitch-label" for="myonoffswitch">
|
||||
<span class="onoffswitch-inner"></span>
|
||||
<span class="onoffswitch-switch"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
</div>
|
||||
|
||||
<?php include_once('footer.php'); ?>
|
||||
<script>
|
||||
var switchStatus = false;
|
||||
|
||||
$("#myonoffswitch").on('change', function() {
|
||||
if ($(this).is(':checked')) {
|
||||
switchStatus = $(this).is(':checked');
|
||||
var user_doamin = $('#user_doamin').val();
|
||||
var user_email = $('#user_email').val();
|
||||
var data_key = $('#user_key').val();
|
||||
toggleCheckedVal(switchStatus,user_doamin,user_email,data_key);
|
||||
}
|
||||
else {
|
||||
switchStatus = $(this).is(':checked');
|
||||
var user_doamin = $('#user_doamin').val();
|
||||
var user_email = $('#user_email').val();
|
||||
var data_key = $('#user_key').val();
|
||||
toggleCheckedVal(switchStatus,user_doamin,user_email,data_key);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
224
user/user_functions.php
Normal file
224
user/user_functions.php
Normal file
|
@ -0,0 +1,224 @@
|
|||
<?php
|
||||
|
||||
/* include common function */
|
||||
include_once (ABS_PATH . '/include/common_function.php');
|
||||
|
||||
class User_functions extends common_function {
|
||||
|
||||
/**
|
||||
* the function "__construct()" automatically starts whenever an object of this class is created,
|
||||
*/
|
||||
public function __construct($shop = '') {
|
||||
/* call parent's (common_function) constructor */
|
||||
parent::__construct($shop);
|
||||
}
|
||||
|
||||
/* When undefined method call that time this function will run */
|
||||
|
||||
public function __call($method, $args) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function remove_code($storeuserid = 0, $curshop = '') {
|
||||
|
||||
$store_user_id = $this->store_user_id;
|
||||
|
||||
if($storeuserid) {
|
||||
$store_user_id = $storeuserid;
|
||||
}
|
||||
|
||||
$response = array('result' => 'fail', 'msg' => 'Something went wrong');
|
||||
if (isset($store_user_id) && is_numeric($store_user_id) && $store_user_id > 0) {
|
||||
//by Shoaib actually in Post data_key is not coming then I will get the data_key from database of this current user
|
||||
$datakey = ((!empty($_POST['data_key'])) ? $_POST['data_key'] : "" );
|
||||
$token = '';
|
||||
$shop = '';
|
||||
|
||||
|
||||
if (empty($datakey)) {
|
||||
$selected_field = 'data_key, token, shop';
|
||||
$where = array('store_user_id' => $store_user_id);
|
||||
$user_store = $this->select_row(TABLE_USER_STORES, $selected_field, $where);
|
||||
if (!empty($user_store)) {
|
||||
$datakey = $user_store['data_key'];
|
||||
$token = $user_store['token'];
|
||||
$shop = $user_store['shop'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$script = '<script data-key="' . $datakey . '" data-name="CookieXray" src="https://cmp.seersco.com/script/cb.js" type="text/javascript"></script>';
|
||||
//fix by Shoaib for scripts added in old way start
|
||||
$script = '<script(.*?)src="https://cmp.seersco.com/script/cb.js"(.*?)>(.*?)</script>';
|
||||
$script2 = '<script(.*?)src="https://seersco.com/script/cb.js"(.*?)>(.*?)</script>';
|
||||
|
||||
$themes = $this->prepare_api_condition(array('themes'), array('role' => 'main'), 'GET', '0', '', $curshop);
|
||||
if (!empty($themes['body']['themes'])) {
|
||||
|
||||
$theme_id = $themes['body']['themes'][0]['id'];
|
||||
|
||||
$url_param_arr = array('asset' => array('key' => 'layout/theme.liquid'));
|
||||
$theme_responce = $this->prepare_api_condition(array('themes', $theme_id, 'assets'), $url_param_arr, 'GET', '0', '', $curshop);
|
||||
$theme_value = $theme_responce['body']['asset']['value'];
|
||||
|
||||
//$html = str_replace($script, "", $theme_value);
|
||||
$html = preg_replace('#'. $script . '#is', '', $theme_value);
|
||||
$html = preg_replace('#'. $script2 . '#is', '', $html);
|
||||
$url_param_arr = array('asset' => array('key' => 'layout/theme.liquid', 'value' => $html));
|
||||
$theme_update = $this->prepare_api_condition(array('themes', $theme_id, 'assets'), $url_param_arr, 'PUT', '0', '', $curshop);
|
||||
|
||||
}
|
||||
// old way fix end.
|
||||
|
||||
// ----- new way remove tags start ---------
|
||||
$arrsrc = ['https://cmp.seersco.com/script/cb.js', 'https://seers-application-assets.s3.amazonaws.com/scripts/cbattributes.js?key=' . $datakey . '&name=CookieXray'];
|
||||
$cbattrjspath = 'https://seers-application-assets.s3.amazonaws.com/scripts/cbattributes.js';
|
||||
|
||||
|
||||
//get all avialable tags
|
||||
$allscriptags = $this->prepare_api_condition(array('script_tags'), array(), 'GET', '0', $token, $shop);
|
||||
|
||||
//print_r($allscriptags);
|
||||
|
||||
if(!empty($allscriptags['body']) && !empty($allscriptags['body']['script_tags'])) {
|
||||
|
||||
foreach ($allscriptags['body']['script_tags'] as $thescript) {
|
||||
|
||||
if (strcasecmp($thescript['src'], $arrsrc[0]) === 0) {
|
||||
//remove the script
|
||||
$scriptdel = $this->prepare_api_condition(array('script_tags', $thescript['id']), array(), 'DELETE', '0', $token, $shop);
|
||||
} else if (stripos($thescript['src'], $cbattrjspath) !== false && strcasecmp($thescript['src'], $arrsrc[1]) !== 0) {
|
||||
//remove the script
|
||||
$scriptdel = $this->prepare_api_condition(array('script_tags', $thescript['id']), array(), 'DELETE', '0', $token, $shop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// ----- new way remove tags end ---------
|
||||
|
||||
|
||||
$response = array('result' => 'success', 'msg' => 'Code Remove successfully.');
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function change_appStatus(){
|
||||
|
||||
$cf_obj = new common_function();
|
||||
$shop = isset($_POST['shop']) ? $_POST['shop'] : $_GET['shop'];
|
||||
$store_user_id = $this->store_user_id;
|
||||
$data_status = $_POST['data_status'];
|
||||
$user_domain = $_POST['user_name'];
|
||||
$user_email = $_POST['user_email'];
|
||||
|
||||
$user_key = $_POST['data_key'];
|
||||
|
||||
if($data_status=='true')
|
||||
{
|
||||
$data_status = '1';
|
||||
}else{
|
||||
$data_status = '0';
|
||||
}
|
||||
|
||||
|
||||
$selected_field = '*';
|
||||
$where = array('shop' => $shop,'store_user_id' => $store_user_id);
|
||||
$is_store_exist = $cf_obj->select_row(TABLE_USER_STORES, $selected_field, $where);
|
||||
|
||||
$already_toggle_status = $is_store_exist['toggle_status'];
|
||||
$domain = $is_store_exist['domain'];
|
||||
$email = $is_store_exist['email'];
|
||||
$token = $is_store_exist['token'];
|
||||
$shop = $is_store_exist['shop'];
|
||||
if(!empty($is_store_exist)){
|
||||
// SEND API CALL
|
||||
$data = array(
|
||||
'domain' => $domain,
|
||||
'user_domain' => $domain,
|
||||
'email' => $email,
|
||||
'user_email' => $email,
|
||||
'secret' => '$2y$10$9ygTfodVBVM0XVCdyzEUK.0FIuLnJT0D42sIE6dIu9r/KY3XaXXyS',
|
||||
'platform' => 'shopify',
|
||||
'status'=>$data_status,
|
||||
);
|
||||
|
||||
// /******* Curl call start *****/
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => "https://seersco.com/api/banner-settings",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => $data
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$error_number = curl_errno($curl);
|
||||
$error_message = curl_error($curl);
|
||||
curl_close($curl);
|
||||
|
||||
$result = json_decode($response, TRUE);
|
||||
|
||||
//var_dump($result);
|
||||
//exit;
|
||||
//by Shoaib in reponse there is no element of banner_enable
|
||||
// {"key":"$2y$10$ZtDil0sCM95w..QVVdqOielWh7YRbySFOPDgzR.K4iukb5I7ewF4G","status":0,"message":"success"}
|
||||
|
||||
//$banner_status = $result['banner_enable'];
|
||||
$banner_status = ((!empty($result['banner_enable'])) ? $result['banner_enable'] : ((isset($result['status'])) ? $result['status'] : $already_toggle_status ) );
|
||||
|
||||
if(!empty($result['key'])){
|
||||
$user_key = $result['key'];
|
||||
}else{
|
||||
$user_key = $_POST['data_key'];
|
||||
}
|
||||
|
||||
//$banner_status = '1';
|
||||
$jsonresponse = array('result' => 'fail', 'msg' => 'Something went wrong');
|
||||
|
||||
if($banner_status=='1'){
|
||||
$jsonresponse = array('result' => 'success', 'key'=>$user_key, 'msg' => "<p><span class ='banner-tick'></span>Banner is enabled on your store. <br> <span style='margin-left:18px;'></span>Please refresh your store home page to see the effect.</p>");
|
||||
$this->snippest_insert($shop, $token, $domain, $email);
|
||||
}else{
|
||||
$jsonresponse = array('result' => 'success', 'key'=>$user_key, 'msg' => 'Banner is disabled on your store');
|
||||
$this->remove_code();
|
||||
}
|
||||
/** Update Banner Status */
|
||||
$this->updateToogelStatus($cf_obj, $shop, $banner_status,$user_domain,$user_email,$user_key);
|
||||
|
||||
if (!empty($result['message']) && strcasecmp($result['message'], 'success') === 0)
|
||||
{
|
||||
return $jsonresponse;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function updateToogelStatus($cf_obj, $shop, $banner_status,$user_domain,$user_email,$user_key){
|
||||
|
||||
|
||||
$shop_details = array(
|
||||
'status'=>'1',
|
||||
'updated_on'=>DATE,
|
||||
'toggle_status'=>$banner_status,
|
||||
'domain'=>$user_domain,
|
||||
'email'=>$user_email,
|
||||
'data_key'=>$user_key
|
||||
);
|
||||
|
||||
$where = array('shop' => $shop,'store_user_id' => $this->store_user_id);
|
||||
$last_id = $cf_obj->update(TABLE_USER_STORES, $shop_details, $where);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue