Enhanced Ecommerce Google Analytics Plugin for WooCommerce - Version 4.5.8

Version Description

  • 10/01/2022 =

  • In this release, we have optimise the code and upgrade the plugin security.

Download this release

Release Info

Developer Tatvic
Plugin Icon 128x128 Enhanced Ecommerce Google Analytics Plugin for WooCommerce
Version 4.5.8
Comparing to
See all releases

Code changes from version 4.5.7 to 4.5.8

admin/class-conversios-admin.php CHANGED
@@ -27,9 +27,8 @@ if ( ! class_exists( 'Conversios_Admin' ) ) {
27
  protected $version;
28
  public function __construct() {
29
  $this->version = PLUGIN_TVC_VERSION;
30
- $this->includes();
31
- $this->url = $this->get_onboarding_page_url();
32
- /* $this->pro_plan_site = $this->get_pro_plan_site();*/
33
  $this->google_detail = $this->get_ee_options_data();
34
  add_action( 'admin_menu', array( $this, 'add_admin_pages' ) );
35
  add_action('admin_init',array($this, 'init'));
@@ -66,8 +65,8 @@ if ( ! class_exists( 'Conversios_Admin' ) ) {
66
  wp_enqueue_style('conversios-daterangepicker-css');
67
  }
68
  //all conversios page css
69
- wp_enqueue_style('conversios-style-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/style.css'), array(), $this->version, 'all' );
70
- wp_enqueue_style('conversios-responsive-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/responsive.css'), array(), $this->version, 'all');
71
  }
72
  }
73
 
@@ -87,7 +86,7 @@ if ( ! class_exists( 'Conversios_Admin' ) ) {
87
  wp_enqueue_script( 'conversios-moment-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/moment.min.js') );
88
  wp_enqueue_script( 'conversios-daterangepicker-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/daterangepicker.js') );
89
 
90
- wp_enqueue_script( 'tvc-ee-custom-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/tvc-ee-custom.js'), array( 'jquery' ), $this->version, false );
91
  }
92
  }
93
  }
27
  protected $version;
28
  public function __construct() {
29
  $this->version = PLUGIN_TVC_VERSION;
30
+ $this->includes();
31
+ $this->url = $this->get_onboarding_page_url(); // use in setting page
 
32
  $this->google_detail = $this->get_ee_options_data();
33
  add_action( 'admin_menu', array( $this, 'add_admin_pages' ) );
34
  add_action('admin_init',array($this, 'init'));
65
  wp_enqueue_style('conversios-daterangepicker-css');
66
  }
67
  //all conversios page css
68
+ wp_enqueue_style('conversios-style-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/style.css'), array(), esc_attr($this->version), 'all' );
69
+ wp_enqueue_style('conversios-responsive-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/responsive.css'), array(), esc_attr($this->version), 'all');
70
  }
71
  }
72
 
86
  wp_enqueue_script( 'conversios-moment-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/moment.min.js') );
87
  wp_enqueue_script( 'conversios-daterangepicker-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/daterangepicker.js') );
88
 
89
+ wp_enqueue_script( 'tvc-ee-custom-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/tvc-ee-custom.js'), array( 'jquery' ), esc_attr($this->version), false );
90
  }
91
  }
92
  }
admin/class-conversios-onboarding.php CHANGED
@@ -35,7 +35,6 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
35
  /**
36
  * check last login for check RefreshToken
37
  */
38
- //print_r($ee_additional_data); exit;
39
  if(isset($ee_additional_data['ee_last_login']) && $ee_additional_data['ee_last_login'] != ""){
40
  $this->last_login = $ee_additional_data['ee_last_login'];
41
  $current = current_time( 'timestamp' );
@@ -75,14 +74,14 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
75
  $data .= "<option value=''>".esc_html__("Please select country","conversios")."</option>";
76
  foreach ($contData as $key => $value) {
77
  $selected = ($value->code == $user_country) ? "selected='selected'" : "";
78
- $data .= "<option value=" . esc_attr($value->code) . " " . $selected . " >" . esc_attr($value->name) . "</option>";
79
  }
80
  $data .= "</select>";
81
  } else {
82
  $data = "<select id='selectCountry' name='country' class='form-control slect2bx'>";
83
  $data .= "<option value=''>".esc_html__("Please select country","conversios")."</option>";
84
  foreach ($contData as $key => $value) {
85
- $data .= "<option value=" . esc_attr($value->code) . ">" . esc_attr($value->name) . "</option>";
86
  }
87
  $data .= "</select>";
88
  }
@@ -116,8 +115,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
116
  $this->TVC_Admin_Helper->set_ee_additional_data($ee_additional_data);
117
 
118
  $this->is_refresh_token_expire = false;
119
- }
120
- //$this->tvc_data = json_encode($this->tvc_data);
121
  }
122
 
123
  if($this->subscriptionId != ""){
@@ -126,8 +124,8 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
126
  if( property_exists($google_detail, "data") && $google_detail->data != "" ){
127
  $googleDetail = $google_detail->data;
128
  $this->tvc_data['subscription_id'] = $googleDetail->id;
129
- $this->tvc_data['access_token'] = base64_encode($googleDetail->access_token);
130
- $this->tvc_data['refresh_token'] = base64_encode($googleDetail->refresh_token);
131
  $this->plan_id = $googleDetail->plan_id;
132
  $login_customer_id = $googleDetail->customer_id;
133
  $tracking_option = $googleDetail->tracking_option;
@@ -145,7 +143,6 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
145
  $complete_step["step-3"] = 1;
146
  }
147
  }
148
-
149
  }
150
  }
151
  }
@@ -271,7 +268,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
271
  </label>
272
  <div id="UA" class="slctunivr-filed">
273
  <div class="tvc-dropdown">
274
- <div class="tvc-dropdown-header" id="ua_web_property_id_option_val" data-accountid="<?php if($googleDetail->ua_analytic_account_id){ echo esc_attr($googleDetail->ua_analytic_account_id); } ?>" data-val="<?php if($googleDetail->property_id){ echo esc_attr($googleDetail->property_id); } ?>"><?php if($googleDetail->property_id){
275
  echo esc_attr($googleDetail->property_id);
276
  }else{?><?php esc_html_e("Select Property Id","conversios"); ?><?php } ?></div>
277
  <div class="tvc-dropdown-content" id="ua_web_property_id_option">
@@ -284,14 +281,14 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
284
  </div>
285
  <div class="cstmrdobtn-item">
286
  <label for="gglanytc">
287
- <input type="radio" <?php echo $this->is_checked($tracking_option, "GA4"); ?> name="analytic_tag_type" id="gglanytc" value="GA4">
288
  <span class="checkmark"></span>
289
  <?php esc_html_e("Google Analytics 4","conversios"); ?>
290
  </label>
291
  <div id="GA4" class="slctunivr-filed">
292
 
293
  <div class="tvc-dropdown">
294
- <div class="tvc-dropdown-header" id="ga4_web_measurement_id_option_val" data-accountid="<?php if($googleDetail->ga4_analytic_account_id){ echo esc_attr($googleDetail->ga4_analytic_account_id); } ?>" data-val="<?php if($googleDetail->measurement_id){ echo esc_attr($googleDetail->measurement_id); } ?>">
295
  <?php if($googleDetail->measurement_id){
296
  echo esc_attr($googleDetail->measurement_id);
297
  }else{?><?php esc_html_e("Select Measurement Id","conversios"); ?>
@@ -306,7 +303,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
306
  </div>
307
  <div class="cstmrdobtn-item">
308
  <label for="both">
309
- <input type="radio" <?php echo $this->is_checked($tracking_option, "BOTH"); ?> name="analytic_tag_type" id="both" value="BOTH">
310
  <span class="checkmark"></span>
311
  <?php esc_html_e("Both","conversios"); ?>
312
  </label>
@@ -314,7 +311,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
314
  <div class="botslectbxitem">
315
 
316
  <div class="tvc-dropdown">
317
- <div class="tvc-dropdown-header" id="both_ua_web_property_id_option_val" data-accountid="<?php if($googleDetail->ua_analytic_account_id){ echo esc_attr($googleDetail->ua_analytic_account_id); } ?>" data-val="<?php if($googleDetail->property_id){ echo esc_attr($googleDetail->property_id); } ?>"><?php if($googleDetail->property_id){
318
  echo esc_attr($googleDetail->property_id);
319
  }else{?><?php esc_html_e("Select Property Id","conversios"); ?><?php } ?></div>
320
  <div class="tvc-dropdown-content" id="both_ua_web_property_id_option">
@@ -327,7 +324,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
327
  <div class="botslectbxitem">
328
 
329
  <div class="tvc-dropdown">
330
- <div class="tvc-dropdown-header" id="both_ga4_web_measurement_id_option_val" data-accountid="<?php if($googleDetail->ga4_analytic_account_id){ echo esc_attr($googleDetail->ga4_analytic_account_id); } ?>" data-val="<?php if($googleDetail->measurement_id){ echo esc_attr($googleDetail->measurement_id); } ?>">
331
  <?php if($googleDetail->measurement_id){
332
  echo esc_attr($googleDetail->measurement_id);
333
  }else{?><?php esc_html_e("Select Measurement Id","conversios"); ?>
@@ -392,7 +389,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
392
  <option value=''><?php esc_html_e("Select Google Ads Account","conversios"); ?></option>
393
  </select>
394
  </div>
395
- <div class="orwrp">or</div>
396
  <div class="creatnewwrp">
397
  <button type="button" class="cretnewbtn newggladsbtn"><span class="plusicon"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png'); ?>" alt="" /></span> <?php esc_html_e("Create New","conversios"); ?></button>
398
  </div>
@@ -404,8 +401,8 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
404
  <p><?php esc_html_e("Your Google Ads Account has been created","conversios"); ?> <strong>(<b><span id="new_google_ads_id"></span></b>).</strong></p>
405
  <h5><?php esc_html_e("Steps to claim your Google Ads Account:","conversios"); ?></h5>
406
  <ol>
407
- <li><?php esc_html_e("Accept invitation mail from Google Ads sent to your email address","conversios"); ?> <em><?php echo (isset($this->tvc_data['g_mail']))?$this->tvc_data['g_mail']:""; ?></em></li>
408
- <li><?php esc_html_e("Log into your Google Ads account and set up your <em>billing preferences</em>","conversios"); ?></li>
409
  </ol>
410
  </div>
411
  </div>
@@ -490,7 +487,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
490
  <option value=''><?php esc_html_e("Select Google Merchant Center","conversios"); ?></option>
491
  </select>
492
  </div>
493
- <div class="orwrp">or</div>
494
  <div class="creatnewwrp">
495
  <button type="button" class="cretnewbtn newmrchntbtn"><span class="plusicon"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png'); ?>" alt="" /></span> <?php esc_html_e("Create New","conversios"); ?></button>
496
  </div>
@@ -506,11 +503,11 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
506
  <input type="hidden" id="plan_id" name="plan_id" value="<?php echo esc_attr($this->plan_id); ?>">
507
  <input type="hidden" id="conversios_onboarding_nonce" name="conversios_onboarding_nonce" value="<?php echo wp_create_nonce( 'conversios_onboarding_nonce' ); ?>">
508
 
509
- <input type="hidden" id="ga_view_id" name="ga_view_id" value="<?php echo esc_attr(get_option('ee_ga_view_id')); ?>">
510
  </form>
511
  </div>
512
  <div class="stepnotewrp">
513
- <?php esc_html_e('If you are in the European Economic Area or Switzerland your Merchant Center account must be associated with a Comparison Shopping Service (CSS). Please find more information at <a href="">Google Merchant Center Help</a> website. If you create a new Merchant Center account through this application, it will be associated with Google Shopping, Google’s CSS, by default. You can change the CSS associated with your account at any time. Please find more information about our CSS Partners <a href="">here</a>. Once you have set up your Merchant Center account you can use our onboarding tool regardless of which CSS you use.','conversios'); ?>
514
  </div>
515
  </div>
516
  </div>
@@ -729,11 +726,11 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
729
  * onboarding page javascript
730
  */
731
  public function page_script(){
732
- $j_tvc_data = json_encode($this->tvc_data);
733
  ?>
734
  <script>
735
- let tvc_data = <?php echo $j_tvc_data; ?>;
736
- var tvc_ajax_url = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
 
737
  let subscription_id ="<?php echo esc_attr($this->subscriptionId); ?>";
738
  let plan_id ="<?php echo esc_attr($this->plan_id); ?>";
739
  let app_id ="<?php echo esc_attr($this->app_id); ?>";
@@ -752,8 +749,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
752
  const systemZoom = width / window.screen.availWidth;
753
  const left = (width - w) / 2 / systemZoom + dualScreenLeft;
754
  const top = (height - h) / 2 / systemZoom + dualScreenTop;
755
- /*window.open('<?php echo $this->connect_url; ?>','newwindow', config=`height=670,width=670,top=100,left=${left},toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,status=no`);*/
756
- var url ='<?php echo $this->connect_url; ?>';
757
  url = url.replace(/&amp;/g, '&');
758
  const newWindow = window.open(url, "newwindow", config= `scrollbars=yes,
759
  width=${w / systemZoom},
@@ -1003,12 +999,12 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
1003
  if(isset($_GET['page']) && sanitize_text_field($_GET['page']) == "conversios_onboarding"){
1004
  wp_register_style('conversios-select2-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/select2.css'));
1005
  wp_enqueue_style('conversios-style-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/style.css'), array(), $this->version, 'all');
1006
- wp_enqueue_style('conversios-responsive-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/responsive.css'), array(), $this->version, 'all');
1007
  wp_enqueue_style('conversios-select2-css');
1008
 
1009
  wp_register_script('conversios-select2-js', esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/js/select2.min.js') );
1010
  wp_enqueue_script('conversios-select2-js');
1011
- wp_enqueue_script( 'conversios-onboarding-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/onboarding-custom.js') , array( 'jquery' ), $this->version, false );
1012
  }
1013
  }
1014
  /**
35
  /**
36
  * check last login for check RefreshToken
37
  */
 
38
  if(isset($ee_additional_data['ee_last_login']) && $ee_additional_data['ee_last_login'] != ""){
39
  $this->last_login = $ee_additional_data['ee_last_login'];
40
  $current = current_time( 'timestamp' );
74
  $data .= "<option value=''>".esc_html__("Please select country","conversios")."</option>";
75
  foreach ($contData as $key => $value) {
76
  $selected = ($value->code == $user_country) ? "selected='selected'" : "";
77
+ $data .= "<option value=" . esc_attr($value->code) . " " . esc_attr($selected) . " >" . esc_attr($value->name) . "</option>";
78
  }
79
  $data .= "</select>";
80
  } else {
81
  $data = "<select id='selectCountry' name='country' class='form-control slect2bx'>";
82
  $data .= "<option value=''>".esc_html__("Please select country","conversios")."</option>";
83
  foreach ($contData as $key => $value) {
84
+ $data .= "<option value=" . esc_attr($value->code) . ">" . esc_attr($value->name) . "</option>";
85
  }
86
  $data .= "</select>";
87
  }
115
  $this->TVC_Admin_Helper->set_ee_additional_data($ee_additional_data);
116
 
117
  $this->is_refresh_token_expire = false;
118
+ }
 
119
  }
120
 
121
  if($this->subscriptionId != ""){
124
  if( property_exists($google_detail, "data") && $google_detail->data != "" ){
125
  $googleDetail = $google_detail->data;
126
  $this->tvc_data['subscription_id'] = $googleDetail->id;
127
+ $this->tvc_data['access_token'] = base64_encode(sanitize_text_field($googleDetail->access_token));
128
+ $this->tvc_data['refresh_token'] = base64_encode(sanitize_text_field($googleDetail->refresh_token));
129
  $this->plan_id = $googleDetail->plan_id;
130
  $login_customer_id = $googleDetail->customer_id;
131
  $tracking_option = $googleDetail->tracking_option;
143
  $complete_step["step-3"] = 1;
144
  }
145
  }
 
146
  }
147
  }
148
  }
268
  </label>
269
  <div id="UA" class="slctunivr-filed">
270
  <div class="tvc-dropdown">
271
+ <div class="tvc-dropdown-header" id="ua_web_property_id_option_val" data-profileid="" data-accountid="<?php if($googleDetail->ua_analytic_account_id){ echo esc_attr($googleDetail->ua_analytic_account_id); } ?>" data-val="<?php if($googleDetail->property_id){ echo esc_attr($googleDetail->property_id); } ?>"><?php if($googleDetail->property_id){
272
  echo esc_attr($googleDetail->property_id);
273
  }else{?><?php esc_html_e("Select Property Id","conversios"); ?><?php } ?></div>
274
  <div class="tvc-dropdown-content" id="ua_web_property_id_option">
281
  </div>
282
  <div class="cstmrdobtn-item">
283
  <label for="gglanytc">
284
+ <input type="radio" <?php echo esc_attr($this->is_checked($tracking_option, "GA4")); ?> name="analytic_tag_type" id="gglanytc" value="GA4">
285
  <span class="checkmark"></span>
286
  <?php esc_html_e("Google Analytics 4","conversios"); ?>
287
  </label>
288
  <div id="GA4" class="slctunivr-filed">
289
 
290
  <div class="tvc-dropdown">
291
+ <div class="tvc-dropdown-header" id="ga4_web_measurement_id_option_val" data-name="" data-accountid="<?php if($googleDetail->ga4_analytic_account_id){ echo esc_attr($googleDetail->ga4_analytic_account_id); } ?>" data-val="<?php if($googleDetail->measurement_id){ echo esc_attr($googleDetail->measurement_id); } ?>">
292
  <?php if($googleDetail->measurement_id){
293
  echo esc_attr($googleDetail->measurement_id);
294
  }else{?><?php esc_html_e("Select Measurement Id","conversios"); ?>
303
  </div>
304
  <div class="cstmrdobtn-item">
305
  <label for="both">
306
+ <input type="radio" <?php echo esc_attr($this->is_checked($tracking_option, "BOTH")); ?> name="analytic_tag_type" id="both" value="BOTH">
307
  <span class="checkmark"></span>
308
  <?php esc_html_e("Both","conversios"); ?>
309
  </label>
311
  <div class="botslectbxitem">
312
 
313
  <div class="tvc-dropdown">
314
+ <div class="tvc-dropdown-header" id="both_ua_web_property_id_option_val" data-profileid="" data-accountid="<?php if($googleDetail->ua_analytic_account_id){ echo esc_attr($googleDetail->ua_analytic_account_id); } ?>" data-val="<?php if($googleDetail->property_id){ echo esc_attr($googleDetail->property_id); } ?>"><?php if($googleDetail->property_id){
315
  echo esc_attr($googleDetail->property_id);
316
  }else{?><?php esc_html_e("Select Property Id","conversios"); ?><?php } ?></div>
317
  <div class="tvc-dropdown-content" id="both_ua_web_property_id_option">
324
  <div class="botslectbxitem">
325
 
326
  <div class="tvc-dropdown">
327
+ <div class="tvc-dropdown-header" id="both_ga4_web_measurement_id_option_val" data-name="" data-accountid="<?php if($googleDetail->ga4_analytic_account_id){ echo esc_attr($googleDetail->ga4_analytic_account_id); } ?>" data-val="<?php if($googleDetail->measurement_id){ echo esc_attr($googleDetail->measurement_id); } ?>">
328
  <?php if($googleDetail->measurement_id){
329
  echo esc_attr($googleDetail->measurement_id);
330
  }else{?><?php esc_html_e("Select Measurement Id","conversios"); ?>
389
  <option value=''><?php esc_html_e("Select Google Ads Account","conversios"); ?></option>
390
  </select>
391
  </div>
392
+ <div class="orwrp"><?php esc_html_e("or","conversios"); ?></div>
393
  <div class="creatnewwrp">
394
  <button type="button" class="cretnewbtn newggladsbtn"><span class="plusicon"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png'); ?>" alt="" /></span> <?php esc_html_e("Create New","conversios"); ?></button>
395
  </div>
401
  <p><?php esc_html_e("Your Google Ads Account has been created","conversios"); ?> <strong>(<b><span id="new_google_ads_id"></span></b>).</strong></p>
402
  <h5><?php esc_html_e("Steps to claim your Google Ads Account:","conversios"); ?></h5>
403
  <ol>
404
+ <li><?php esc_html_e("Accept invitation mail from Google Ads sent to your email address","conversios"); ?> <em><?php echo (isset($this->tvc_data['g_mail']))?esc_attr($this->tvc_data['g_mail']):""; ?></em></li>
405
+ <li><?php esc_html_e("Log into your Google Ads account and set up your billing preferences","conversios"); ?></li>
406
  </ol>
407
  </div>
408
  </div>
487
  <option value=''><?php esc_html_e("Select Google Merchant Center","conversios"); ?></option>
488
  </select>
489
  </div>
490
+ <div class="orwrp"><?php esc_html_e("or","conversios"); ?></div>
491
  <div class="creatnewwrp">
492
  <button type="button" class="cretnewbtn newmrchntbtn"><span class="plusicon"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png'); ?>" alt="" /></span> <?php esc_html_e("Create New","conversios"); ?></button>
493
  </div>
503
  <input type="hidden" id="plan_id" name="plan_id" value="<?php echo esc_attr($this->plan_id); ?>">
504
  <input type="hidden" id="conversios_onboarding_nonce" name="conversios_onboarding_nonce" value="<?php echo wp_create_nonce( 'conversios_onboarding_nonce' ); ?>">
505
 
506
+ <input type="hidden" id="ga_view_id" name="ga_view_id" value="">
507
  </form>
508
  </div>
509
  <div class="stepnotewrp">
510
+ <?php esc_html_e('If you are in the European Economic Area or Switzerland your Merchant Center account must be associated with a Comparison Shopping Service (CSS). Please find more information at <a href="#">Google Merchant Center Help</a> website. If you create a new Merchant Center account through this application, it will be associated with Google Shopping, Google’s CSS, by default. You can change the CSS associated with your account at any time. Please find more information about our CSS Partners <a href="">here</a>. Once you have set up your Merchant Center account you can use our onboarding tool regardless of which CSS you use.','conversios'); ?>
511
  </div>
512
  </div>
513
  </div>
726
  * onboarding page javascript
727
  */
728
  public function page_script(){
 
729
  ?>
730
  <script>
731
+
732
+ var tvc_data = "<?php echo esc_js(wp_json_encode($this->tvc_data)); ?>";
733
+ var tvc_ajax_url = '<?php echo esc_url_raw(admin_url( 'admin-ajax.php' )); ?>';
734
  let subscription_id ="<?php echo esc_attr($this->subscriptionId); ?>";
735
  let plan_id ="<?php echo esc_attr($this->plan_id); ?>";
736
  let app_id ="<?php echo esc_attr($this->app_id); ?>";
749
  const systemZoom = width / window.screen.availWidth;
750
  const left = (width - w) / 2 / systemZoom + dualScreenLeft;
751
  const top = (height - h) / 2 / systemZoom + dualScreenTop;
752
+ var url ='<?php echo esc_url_raw($this->connect_url); ?>';
 
753
  url = url.replace(/&amp;/g, '&');
754
  const newWindow = window.open(url, "newwindow", config= `scrollbars=yes,
755
  width=${w / systemZoom},
999
  if(isset($_GET['page']) && sanitize_text_field($_GET['page']) == "conversios_onboarding"){
1000
  wp_register_style('conversios-select2-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/select2.css'));
1001
  wp_enqueue_style('conversios-style-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/style.css'), array(), $this->version, 'all');
1002
+ wp_enqueue_style('conversios-responsive-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/responsive.css'), array(), esc_attr($this->version), 'all');
1003
  wp_enqueue_style('conversios-select2-css');
1004
 
1005
  wp_register_script('conversios-select2-js', esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/js/select2.min.js') );
1006
  wp_enqueue_script('conversios-select2-js');
1007
+ wp_enqueue_script( 'conversios-onboarding-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/onboarding-custom.js') , array( 'jquery' ), esc_attr($this->version), false );
1008
  }
1009
  }
1010
  /**
admin/class-enhanced-ecommerce-google-analytics-admin.php CHANGED
@@ -46,14 +46,11 @@ class Enhanced_Ecommerce_Google_Analytics_Admin extends TVC_Admin_Helper {
46
  public function __construct($plugin_name, $version) {
47
  $this->plugin_name = $plugin_name;
48
  $this->version = $version;
49
- $this->url = $this->get_onboarding_page_url();
50
- $this->site_url = "admin.php?page=conversios";
51
- $this->pro_plan_site = $this->get_pro_plan_site();
52
  $this->google_detail = $this->get_ee_options_data();
53
  }
54
  public function tvc_admin_notice(){
55
  // add fixed message notification
56
- $this->add_tvc_fixed_nofification();
57
  $ee_additional_data = $this->get_ee_additional_data();
58
  if(isset($ee_additional_data['dismissed_ee_adimin_notic_a']) && $ee_additional_data['dismissed_ee_adimin_notic_a'] == 1){
59
  }else{
@@ -65,16 +62,16 @@ class Enhanced_Ecommerce_Google_Analytics_Admin extends TVC_Admin_Helper {
65
  }
66
  if(isset($ee_additional_data['dismissed_ee_adimin_notic_b']) && $ee_additional_data['dismissed_ee_adimin_notic_b'] == 1){
67
  }else{
68
- $google_detail = $this->get_ee_options_data();
69
- if(isset($google_detail['setting']) && $google_detail['setting']){
70
- $googleDetail = $google_detail['setting'];
71
- if(isset($googleDetail->google_merchant_center_id) && $googleDetail->google_merchant_center_id =="" && $this->subscriptionId != "" ){
72
- echo '<div class="notice notice-info is-dismissible" data-id="ee_adimin_notic_b">
73
- <p>'. esc_html__("Leverage the power of Google Shopping to reach out millions of shoppers across Google. Automate entire Google Shopping and get eligible for free listing when user searches on Google for products similar to your eCommerce business.","conversios").' <a href="'.esc_url_raw('admin.php?page=conversios').'"><b><u>'. esc_html__("Automate now","conversios").'</u></b></a></p>
74
- </div>';
75
-
76
- }
77
- }
78
  }
79
  if(isset($ee_additional_data['dismissed_ee_adimin_notic_c']) && $ee_additional_data['dismissed_ee_adimin_notic_c'] == 1){
80
  }else{
@@ -114,8 +111,7 @@ class Enhanced_Ecommerce_Google_Analytics_Admin extends TVC_Admin_Helper {
114
  if ($screen->id == 'toplevel_page_conversios' || (isset($_GET['page']) && strpos(sanitize_text_field($_GET['page']), 'conversios') !== false) ) {
115
  if(sanitize_text_field($_GET['page']) == "conversios_onboarding"){
116
  return;
117
- }
118
-
119
  if(is_rtl()){
120
  wp_register_style('plugin-bootstrap', esc_url_raw(ENHANCAD_PLUGIN_URL . '/includes/setup/plugins/bootstrap/css/bootstrap.rtl.min.css') );
121
  }else{
46
  public function __construct($plugin_name, $version) {
47
  $this->plugin_name = $plugin_name;
48
  $this->version = $version;
 
 
 
49
  $this->google_detail = $this->get_ee_options_data();
50
  }
51
  public function tvc_admin_notice(){
52
  // add fixed message notification
53
+ //$this->add_tvc_fixed_nofification();
54
  $ee_additional_data = $this->get_ee_additional_data();
55
  if(isset($ee_additional_data['dismissed_ee_adimin_notic_a']) && $ee_additional_data['dismissed_ee_adimin_notic_a'] == 1){
56
  }else{
62
  }
63
  if(isset($ee_additional_data['dismissed_ee_adimin_notic_b']) && $ee_additional_data['dismissed_ee_adimin_notic_b'] == 1){
64
  }else{
65
+ $google_detail = $this->get_ee_options_data();
66
+ if(isset($google_detail['setting']) && $google_detail['setting']){
67
+ $googleDetail = $google_detail['setting'];
68
+ if(isset($googleDetail->google_merchant_center_id) && $googleDetail->google_merchant_center_id =="" && $this->subscriptionId != "" ){
69
+ echo '<div class="notice notice-info is-dismissible" data-id="ee_adimin_notic_b">
70
+ <p>'. esc_html__("Leverage the power of Google Shopping to reach out millions of shoppers across Google. Automate entire Google Shopping and get eligible for free listing when user searches on Google for products similar to your eCommerce business.","conversios").' <a href="'.esc_url_raw('admin.php?page=conversios').'"><b><u>'. esc_html__("Automate now","conversios").'</u></b></a></p>
71
+ </div>';
72
+
73
+ }
74
+ }
75
  }
76
  if(isset($ee_additional_data['dismissed_ee_adimin_notic_c']) && $ee_additional_data['dismissed_ee_adimin_notic_c'] == 1){
77
  }else{
111
  if ($screen->id == 'toplevel_page_conversios' || (isset($_GET['page']) && strpos(sanitize_text_field($_GET['page']), 'conversios') !== false) ) {
112
  if(sanitize_text_field($_GET['page']) == "conversios_onboarding"){
113
  return;
114
+ }
 
115
  if(is_rtl()){
116
  wp_register_style('plugin-bootstrap', esc_url_raw(ENHANCAD_PLUGIN_URL . '/includes/setup/plugins/bootstrap/css/bootstrap.rtl.min.css') );
117
  }else{
admin/class-survey.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
  if ( ! class_exists( 'TVC_Survey' ) ) {
3
  class TVC_Survey {
4
- public $api_url = TVC_API_CALL_URL.'/customersurvey';
5
  public $name;
6
  public $plugin;
7
  protected $TVC_Admin_DB_Helper;
@@ -25,7 +24,7 @@ if ( ! class_exists( 'TVC_Survey' ) ) {
25
  $url = network_site_url( '/' );
26
  $is_local_url = false;
27
  // Trim it up
28
- $url = esc_url(strtolower( trim( $url ) ) );
29
  if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) {
30
  $url = 'http://' . $url;
31
  }
@@ -126,11 +125,6 @@ if ( ! class_exists( 'TVC_Survey' ) ) {
126
  plugin_name: 'ee-woocommerce'
127
  }
128
  add_survey(data);
129
- /*var submitSurvey = $.post('<?php echo $this->api_url; ?>', data);
130
- submitSurvey.always(function() {
131
- $(".ee-survey-modal").hide(100);
132
- location.href = $deactivateLink.attr('href');
133
- });*/
134
  });
135
  // Exit key closes survey when open.
136
  $(document).keyup(function(event) {
@@ -272,7 +266,7 @@ if ( ! class_exists( 'TVC_Survey' ) ) {
272
  ),
273
  );
274
  ?>
275
- <div class="ee-survey-modal" id="ee-survey-<?php echo $this->plugin; ?>">
276
  <div class="ee-survey-wrap">
277
  <form class="ee-survey" method="post">
278
  <span class="ee-survey-title"><span class="dashicons dashicons-admin-customizer"></span><?php echo ' ' . esc_html__( 'Quick Feedback', 'conversios' ); ?></span>
1
  <?php
2
  if ( ! class_exists( 'TVC_Survey' ) ) {
3
  class TVC_Survey {
 
4
  public $name;
5
  public $plugin;
6
  protected $TVC_Admin_DB_Helper;
24
  $url = network_site_url( '/' );
25
  $is_local_url = false;
26
  // Trim it up
27
+ $url = esc_url_raw(strtolower( trim( $url ) ) );
28
  if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) {
29
  $url = 'http://' . $url;
30
  }
125
  plugin_name: 'ee-woocommerce'
126
  }
127
  add_survey(data);
 
 
 
 
 
128
  });
129
  // Exit key closes survey when open.
130
  $(document).keyup(function(event) {
266
  ),
267
  );
268
  ?>
269
+ <div class="ee-survey-modal" id="ee-survey-<?php echo esc_attr($this->plugin); ?>">
270
  <div class="ee-survey-wrap">
271
  <form class="ee-survey" method="post">
272
  <span class="ee-survey-title"><span class="dashicons dashicons-admin-customizer"></span><?php echo ' ' . esc_html__( 'Quick Feedback', 'conversios' ); ?></span>
admin/class-tvc-admin-auto-product-sync-helper.php CHANGED
@@ -172,10 +172,10 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
172
  $postObj = (object) array_merge((array) get_post($postvalue->w_product_id), (array) $postmeta);
173
 
174
  $product = array(
175
- 'offer_id'=>esc_attr($postvalue->w_product_id),
176
  'channel'=>'online',
177
- 'link'=>get_permalink($postvalue->w_product_id),
178
- 'google_product_category'=>esc_attr($postvalue->g_cat_id)
179
  );
180
 
181
  $temp_product=array();
@@ -184,14 +184,14 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
184
  foreach ($fixed_att_select_list as $fixed_key) {
185
  if(isset($formArray[$fixed_key]) && $formArray[$fixed_key] != "" ){
186
  if($fixed_key == "shipping" && $formArray[$fixed_key] != ""){
187
- $temp_product[$fixed_key]['price']['value'] = $formArray[$fixed_key];
188
- $temp_product[$fixed_key]['price']['currency'] = $tvc_currency;
189
- $temp_product[$fixed_key]['country'] = $formArray['target_country'];
190
  }else if($fixed_key == "tax" && $formArray[$fixed_key] != ""){
191
- $temp_product['taxes']['rate'] = $formArray[$fixed_key];
192
- $temp_product['taxes']['country'] = $formArray['target_country'];
193
  }else if( $formArray[$fixed_key] != ""){
194
- $temp_product[$fixed_key] = $formArray[$fixed_key];
195
  }
196
  }
197
  unset($formArray[$fixed_key]);
@@ -211,7 +211,7 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
211
  unset($product['customAttributes']);
212
  $postmeta_var = (object)$this->TVC_Admin_Helper->tvc_get_post_meta($variation_id);
213
  $formArray_val = $formArray['title'];
214
- $product['title'] = (isset($postObj->$formArray_val))?$postObj->$formArray_val:get_the_title($postvalue->w_product_id);
215
  $tvc_temp_desc_key = $formArray['description'];
216
  $product['description'] = ( $variation_description != "")?$variation_description:$postObj->$tvc_temp_desc_key;
217
  $product['offer_id'] = esc_attr($variation_id);
@@ -222,7 +222,7 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
222
  $product['productTypes'] = $productTypes;
223
  }
224
  $image_id = $variation->get_image_id();
225
- $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
226
  if(isset($variation_attributes) && !empty($variation_attributes) ){
227
  foreach($variation_attributes as $va_key => $va_value ){
228
  $va_key = str_replace("_", " ", $va_key);
@@ -251,7 +251,7 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
251
  unset($product[$key]);
252
  }
253
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
254
- $product[$key]['currency'] = $tvc_currency;
255
  }else{
256
  $skipProducts[$postmeta_var->ID] = $postmeta_var;
257
  }
@@ -264,7 +264,7 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
264
  unset($product[$key]);
265
  }
266
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
267
- $product[$key]['currency'] = $tvc_currency;
268
  }
269
  }else if($key == 'availability'){
270
  $tvc_find = array("instock","outofstock","onbackorder");
@@ -272,24 +272,24 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
272
  if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
273
  $stock_status = $postmeta_var->$value;
274
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
275
- $product[$key] = $stock_status;
276
  }else{
277
  $stock_status = $postmeta_var->_stock_status;
278
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
279
- $product[$key] = $stock_status;
280
  }
281
  }else if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
282
- $product[$key] = $postmeta_var->$value;
283
  }else if(in_array($key, array("brand")) ){ //list of cutom option added
284
  $yith_product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
285
  if($yith_product_brand != ""){
286
- $product[$key] = $yith_product_brand;
287
  }
288
  }
289
  }
290
  $item = [
291
- 'merchant_id' => esc_attr($merchantId),
292
- 'batch_id' => ++$batchId,
293
  'method' => 'insert',
294
  'product' => $product
295
  ];
@@ -297,9 +297,9 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
297
  }
298
  }
299
 
300
- }else if( !empty($prd) ){ // for somple product
301
  $image_id = $prd->get_image_id();
302
- $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
303
  $productTypes = $this->get_product_category($postvalue->w_product_id);
304
  if(!empty($productTypes)){
305
  $product['productTypes'] = $productTypes;
@@ -316,7 +316,7 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
316
  $product[$key]['value'] = $postObj->_sale_price;
317
  }
318
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
319
- $product[$key]['currency'] = $tvc_currency;
320
  }else{
321
  $skipProducts[$postObj->ID] = $postObj;
322
  }
@@ -327,7 +327,7 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
327
  $product[$key]['value'] = $postObj->_sale_price;
328
  }
329
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
330
- $product[$key]['currency'] = $tvc_currency;
331
  }
332
  }else if($key == 'availability'){
333
  $tvc_find = array("instock","outofstock","onbackorder");
@@ -335,25 +335,24 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
335
  if(isset($postObj->$value) && $postObj->$value != ""){
336
  $stock_status = $postObj->$value;
337
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
338
- $product[$key] = $stock_status;
339
  }else{
340
  $stock_status = $postObj->_stock_status;
341
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
342
- $product[$key] = $stock_status;
343
  }
344
  }else if(isset($postObj->$value) && $postObj->$value != ""){
345
- //echo $key."==".$postObj->$value."<br>";
346
  $product[$key] = $postObj->$value;
347
  }else if(in_array($key, array("brand")) ){ //list of cutom option added
348
  $yith_product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
349
  if($yith_product_brand != ""){
350
- $product[$key] = $yith_product_brand;
351
  }
352
  }
353
  }
354
  $item = [
355
- 'merchant_id' => esc_attr($merchantId),
356
- 'batch_id' => ++$batchId,
357
  'method' => 'insert',
358
  'product' => $product
359
  ];
@@ -368,12 +367,12 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
368
  //$count = 0;
369
  $pre_last_sync_product_id = sanitize_text_field($last_sync_product_id);
370
  if( $product_count > 0 ){
371
- $tvc_currency = esc_attr($this->TVC_Admin_Helper->get_woo_currency());
372
- $merchantId = esc_attr($this->TVC_Admin_Helper->get_merchantId());
373
- $customerId = esc_attr($this->TVC_Admin_Helper->get_currentCustomerId());
374
- $accountId = esc_attr($this->TVC_Admin_Helper->get_main_merchantId());
375
- $subscriptionId = esc_attr($this->TVC_Admin_Helper->get_subscriptionId());
376
- $last_sync_product_id =esc_attr(( $last_sync_product_id > 0)?$last_sync_product_id:0);
377
  global $wpdb;
378
  $tablename = $wpdb->prefix .'ee_product_sync_data';
379
  $sql = "select * from ".esc_sql($tablename)." where id > ".esc_sql($last_sync_product_id)." LIMIT ".esc_sql($this->batch_size);
@@ -384,9 +383,9 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
384
  if(!empty($p_map_attribute) && isset($p_map_attribute['items']) && !empty($p_map_attribute['items'])){
385
  // call product sync API
386
  $data = [
387
- 'merchant_id' => esc_attr($accountId),
388
- 'account_id' => esc_attr($merchantId),
389
- 'subscription_id' => esc_attr($subscriptionId),
390
  'entries' => $p_map_attribute['items']
391
  ];
392
  $url = $this->apiDomain.'/products/batch';
@@ -488,9 +487,9 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
488
 
489
  $data = [
490
  "grant_type" => 'refresh_token',
491
- "client_id" => esc_attr($clientId),
492
- 'client_secret' => esc_attr($clientSecret),
493
- 'refresh_token' => esc_attr($refresh_token),
494
  ];
495
  $args = array(
496
  'headers' =>$header,
172
  $postObj = (object) array_merge((array) get_post($postvalue->w_product_id), (array) $postmeta);
173
 
174
  $product = array(
175
+ 'offer_id'=>sanitize_text_field($postvalue->w_product_id),
176
  'channel'=>'online',
177
+ 'link'=> esc_url_raw(get_permalink($postvalue->w_product_id)),
178
+ 'google_product_category'=>sanitize_text_field($postvalue->g_cat_id)
179
  );
180
 
181
  $temp_product=array();
184
  foreach ($fixed_att_select_list as $fixed_key) {
185
  if(isset($formArray[$fixed_key]) && $formArray[$fixed_key] != "" ){
186
  if($fixed_key == "shipping" && $formArray[$fixed_key] != ""){
187
+ $temp_product[$fixed_key]['price']['value'] = sanitize_text_field($formArray[$fixed_key]);
188
+ $temp_product[$fixed_key]['price']['currency'] = sanitize_text_field($tvc_currency);
189
+ $temp_product[$fixed_key]['country'] = sanitize_text_field($formArray['target_country']);
190
  }else if($fixed_key == "tax" && $formArray[$fixed_key] != ""){
191
+ $temp_product['taxes']['rate'] = sanitize_text_field($formArray[$fixed_key]);
192
+ $temp_product['taxes']['country'] = sanitize_text_field($formArray['target_country']);
193
  }else if( $formArray[$fixed_key] != ""){
194
+ $temp_product[$fixed_key] = sanitize_text_field($formArray[$fixed_key]);
195
  }
196
  }
197
  unset($formArray[$fixed_key]);
211
  unset($product['customAttributes']);
212
  $postmeta_var = (object)$this->TVC_Admin_Helper->tvc_get_post_meta($variation_id);
213
  $formArray_val = $formArray['title'];
214
+ $product['title'] = (isset($postObj->$formArray_val))?sanitize_text_field($postObj->$formArray_val):get_the_title($postvalue->w_product_id);
215
  $tvc_temp_desc_key = $formArray['description'];
216
  $product['description'] = ( $variation_description != "")?$variation_description:$postObj->$tvc_temp_desc_key;
217
  $product['offer_id'] = esc_attr($variation_id);
222
  $product['productTypes'] = $productTypes;
223
  }
224
  $image_id = $variation->get_image_id();
225
+ $product['image_link'] = esc_url_raw(wp_get_attachment_image_url($image_id, 'full'));
226
  if(isset($variation_attributes) && !empty($variation_attributes) ){
227
  foreach($variation_attributes as $va_key => $va_value ){
228
  $va_key = str_replace("_", " ", $va_key);
251
  unset($product[$key]);
252
  }
253
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
254
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
255
  }else{
256
  $skipProducts[$postmeta_var->ID] = $postmeta_var;
257
  }
264
  unset($product[$key]);
265
  }
266
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
267
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
268
  }
269
  }else if($key == 'availability'){
270
  $tvc_find = array("instock","outofstock","onbackorder");
272
  if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
273
  $stock_status = $postmeta_var->$value;
274
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
275
+ $product[$key] = sanitize_text_field($stock_status);
276
  }else{
277
  $stock_status = $postmeta_var->_stock_status;
278
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
279
+ $product[$key] = sanitize_text_field($stock_status);
280
  }
281
  }else if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
282
+ $product[$key] = sanitize_text_field($postmeta_var->$value);
283
  }else if(in_array($key, array("brand")) ){ //list of cutom option added
284
  $yith_product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
285
  if($yith_product_brand != ""){
286
+ $product[$key] = sanitize_text_field($yith_product_brand);
287
  }
288
  }
289
  }
290
  $item = [
291
+ 'merchant_id' => sanitize_text_field($merchantId),
292
+ 'batch_id' => sanitize_text_field(++$batchId),
293
  'method' => 'insert',
294
  'product' => $product
295
  ];
297
  }
298
  }
299
 
300
+ }else if( !empty($prd) ){ // for simple product
301
  $image_id = $prd->get_image_id();
302
+ $product['image_link'] = esc_url_raw(wp_get_attachment_image_url($image_id, 'full'));
303
  $productTypes = $this->get_product_category($postvalue->w_product_id);
304
  if(!empty($productTypes)){
305
  $product['productTypes'] = $productTypes;
316
  $product[$key]['value'] = $postObj->_sale_price;
317
  }
318
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
319
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
320
  }else{
321
  $skipProducts[$postObj->ID] = $postObj;
322
  }
327
  $product[$key]['value'] = $postObj->_sale_price;
328
  }
329
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
330
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
331
  }
332
  }else if($key == 'availability'){
333
  $tvc_find = array("instock","outofstock","onbackorder");
335
  if(isset($postObj->$value) && $postObj->$value != ""){
336
  $stock_status = $postObj->$value;
337
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
338
+ $product[$key] = sanitize_text_field($stock_status);
339
  }else{
340
  $stock_status = $postObj->_stock_status;
341
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
342
+ $product[$key] = sanitize_text_field($stock_status);
343
  }
344
  }else if(isset($postObj->$value) && $postObj->$value != ""){
 
345
  $product[$key] = $postObj->$value;
346
  }else if(in_array($key, array("brand")) ){ //list of cutom option added
347
  $yith_product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
348
  if($yith_product_brand != ""){
349
+ $product[$key] = sanitize_text_field($yith_product_brand);
350
  }
351
  }
352
  }
353
  $item = [
354
+ 'merchant_id' => sanitize_text_field($merchantId),
355
+ 'batch_id' => sanitize_text_field(++$batchId),
356
  'method' => 'insert',
357
  'product' => $product
358
  ];
367
  //$count = 0;
368
  $pre_last_sync_product_id = sanitize_text_field($last_sync_product_id);
369
  if( $product_count > 0 ){
370
+ $tvc_currency = sanitize_text_field($this->TVC_Admin_Helper->get_woo_currency());
371
+ $merchantId = sanitize_text_field($this->TVC_Admin_Helper->get_merchantId());
372
+ $customerId = sanitize_text_field($this->TVC_Admin_Helper->get_currentCustomerId());
373
+ $accountId = sanitize_text_field($this->TVC_Admin_Helper->get_main_merchantId());
374
+ $subscriptionId = sanitize_text_field($this->TVC_Admin_Helper->get_subscriptionId());
375
+ $last_sync_product_id =sanitize_text_field(( $last_sync_product_id > 0)?$last_sync_product_id:0);
376
  global $wpdb;
377
  $tablename = $wpdb->prefix .'ee_product_sync_data';
378
  $sql = "select * from ".esc_sql($tablename)." where id > ".esc_sql($last_sync_product_id)." LIMIT ".esc_sql($this->batch_size);
383
  if(!empty($p_map_attribute) && isset($p_map_attribute['items']) && !empty($p_map_attribute['items'])){
384
  // call product sync API
385
  $data = [
386
+ 'merchant_id' => sanitize_text_field($accountId),
387
+ 'account_id' => sanitize_text_field($merchantId),
388
+ 'subscription_id' => sanitize_text_field($subscriptionId),
389
  'entries' => $p_map_attribute['items']
390
  ];
391
  $url = $this->apiDomain.'/products/batch';
487
 
488
  $data = [
489
  "grant_type" => 'refresh_token',
490
+ "client_id" => sanitize_text_field($clientId),
491
+ 'client_secret' => sanitize_text_field($clientSecret),
492
+ 'refresh_token' => sanitize_text_field($refresh_token),
493
  ];
494
  $args = array(
495
  'headers' =>$header,
admin/class-tvc-admin-helper.php CHANGED
@@ -23,6 +23,8 @@ Class TVC_Admin_Helper{
23
  $this->includes();
24
  $this->customApiObj = new CustomApi();
25
  $this->TVC_Admin_DB_Helper = new TVC_Admin_DB_Helper();
 
 
26
  }
27
 
28
  public function includes() {
@@ -31,7 +33,72 @@ Class TVC_Admin_Helper{
31
  }
32
  if (!class_exists('ShoppingApi')) {
33
  require_once(ENHANCAD_PLUGIN_DIR . 'includes/setup/ShoppingApi.php');
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
  /*
37
  * verstion auto updated
@@ -50,14 +117,14 @@ Class TVC_Admin_Helper{
50
  $tablename = $wpdb->prefix ."ee_product_sync_call";
51
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
52
  new TVC_Admin_Auto_Product_sync_Helper();
53
- update_option("ee_auto_update_id", sanitize_option("ee_auto_update_id", $new_ee_auto_update_id) );
54
  }
55
  if($ee_auto_update_id == "tvc_4.5.1"){
56
  //tvc_4.5.1
57
  $this->update_subscription_details_api_to_db();
58
  }
59
  }else{
60
- update_option("ee_auto_update_id", sanitize_option("ee_auto_update_id", $old_ee_auto_update_id) );
61
  }
62
  }
63
  /*
@@ -98,8 +165,8 @@ Class TVC_Admin_Helper{
98
  $google_detail = $this->customApiObj->getGoogleAnalyticDetail();
99
  if(property_exists($google_detail,"error") && $google_detail->error == false){
100
  if(property_exists($google_detail,"data") && $google_detail->data != ""){
101
- $google_detail->data->access_token = base64_encode($google_detail->data->access_token);
102
- $google_detail->data->refresh_token = base64_encode($google_detail->data->refresh_token);
103
  $googleDetail = $google_detail->data;
104
  }
105
  }
@@ -118,8 +185,8 @@ Class TVC_Admin_Helper{
118
  $google_detail = $this->customApiObj->getGoogleAnalyticDetail();
119
  if(property_exists($google_detail,"error") && $google_detail->error == false){
120
  if(property_exists($google_detail,"data") && $google_detail->data != "") {
121
- $google_detail->data->access_token = base64_encode($google_detail->data->access_token);
122
- $google_detail->data->refresh_token = base64_encode($google_detail->data->refresh_token);
123
  $googleDetail = $google_detail->data;
124
  }
125
  }else{
@@ -130,15 +197,6 @@ Class TVC_Admin_Helper{
130
  $syncProductList = [];
131
  $campaigns_list = [];
132
  if(isset($googleDetail->google_merchant_center_id) && $googleDetail->google_merchant_center_id != ""){
133
- /*$syncProduct_list_res = $this->customApiObj->getSyncProductList(['merchant_id' => $this->get_merchantId()]);
134
- if(isset($syncProduct_list_res->data) && isset($syncProduct_list_res->status) && $syncProduct_list_res->status == 200){
135
- if (isset($syncProduct_list_res->data->statistics)) {
136
- $syncProductStat = $syncProduct_list_res->data->statistics;
137
- }
138
- if (isset($syncProduct_list_res->data->products)) {
139
- $syncProductList = $syncProduct_list_res->data->products;
140
- }
141
- }*/
142
  if($is_import_gmc_products){
143
  $this->import_gmc_products_sync_in_db();
144
  }
@@ -151,7 +209,7 @@ Class TVC_Admin_Helper{
151
  }
152
  $syncProductStat["total"] = $this->TVC_Admin_DB_Helper->tvc_row_count('ee_products_sync_list');
153
  }else{
154
- $syncProductStat = array("total" =>0, "approved" => 0, "disapproved" => 0, "pending" => 0 );
155
  }
156
  if(isset($googleDetail->google_ads_id) && $googleDetail->google_ads_id != ""){
157
  $this->update_remarketing_snippets();
@@ -163,7 +221,7 @@ Class TVC_Admin_Helper{
163
  }
164
  }
165
  }
166
-
167
  $this->set_ee_options_data(array("setting" => $googleDetail, "prod_sync_status" => (object) $syncProductStat, "campaigns_list"=>$campaigns_list, "sync_time"=>current_time( 'timestamp' )));
168
  return array("error"=>false, "message"=>esc_html__("Details updated successfully.","conversios"));
169
  }
@@ -176,12 +234,12 @@ Class TVC_Admin_Helper{
176
  $rs = $this->customApiObj->get_remarketing_snippets($customer_id);
177
  $remarketing_snippets=array();
178
  if(property_exists($rs,"error") && $rs->error == false){
179
- if(property_exists($rs,"data") && $rs->data != "") {
180
  $remarketing_snippets["snippets"]=base64_encode($rs->data->snippets);
181
  $remarketing_snippets["id"]=$rs->data->id;
182
  }
183
  }
184
- update_option("ee_remarketing_snippets", serialize(sanitize_option("ee_remarketing_snippets", $remarketing_snippets) ));
185
  }
186
  }
187
  /*
@@ -207,16 +265,14 @@ Class TVC_Admin_Helper{
207
  foreach ($con_array as $key => $con_value) {
208
  $con_val_array = explode(":", $con_value);
209
  if(in_array("send_to", $con_val_array)){
210
- update_option("ee_conversio_send_to", sanitize_option("ee_conversio_send_to", $con_val_array[1]) );
211
  break 2;
212
  }
213
  }
214
  }
215
  }
216
  }
217
- }
218
-
219
-
220
  }
221
  }
222
  /*
@@ -231,13 +287,11 @@ Class TVC_Admin_Helper{
231
  if(!empty($last_row) && isset($last_row['gmc_id']) && $last_row['gmc_id'] != $merchant_id){
232
  global $wpdb;
233
  $tablename = $wpdb->prefix ."ee_products_sync_list";
234
- //$wpdb->query("DROP TABLE IF EXISTS ".$tablename);
235
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
236
  $tablename = $wpdb->prefix ."ee_product_sync_data";
237
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
238
  $tablename = $wpdb->prefix ."ee_product_sync_call";
239
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
240
- //new TVC_Admin_Auto_Product_sync_Helper();
241
  }else if( $next_page_token =="" ){
242
  global $wpdb;
243
  $tablename = $wpdb->prefix ."ee_products_sync_list";
@@ -246,7 +300,7 @@ Class TVC_Admin_Helper{
246
  if( $merchant_id != "" ){
247
  $args = array( 'merchant_id' => $merchant_id );
248
  if($next_page_token != ""){
249
- $args["pageToken"] = $next_page_token;
250
  }
251
  $syncProduct_list_res = $this->customApiObj->getSyncProductList($args);
252
  if(isset($syncProduct_list_res->data) && isset($syncProduct_list_res->status) && $syncProduct_list_res->status == 200){
@@ -261,11 +315,11 @@ Class TVC_Admin_Helper{
261
  }
262
  $t_data = array(
263
  'gmc_id' => esc_sql($merchant_id),
264
- 'name'=> esc_sql($value->name),
265
- 'product_id'=> esc_sql($value->productId),
266
- 'google_status'=> esc_sql($googleStatus),
267
- 'image_link'=> esc_sql($value->imageLink),
268
- 'issues'=>json_encode($value->issues)
269
  );
270
  $where ="product_id = '".esc_sql($value->productId)."'";
271
  $row_count = $this->TVC_Admin_DB_Helper->tvc_check_row('ee_products_sync_list', $where);
@@ -298,13 +352,13 @@ Class TVC_Admin_Helper{
298
  * set API data in DB
299
  */
300
  public function set_ee_options_data($ee_options_data){
301
- update_option("ee_api_data", serialize(sanitize_option("ee_api_data", $ee_options_data) ));
302
  }
303
  /*
304
  * set additional data in DB
305
  */
306
  public function set_ee_additional_data($ee_additional_data){
307
- update_option("ee_additional_data", serialize(sanitize_option("ee_additional_data",$ee_additional_data) ));
308
  }
309
  /*
310
  * get additional data from DB
@@ -319,7 +373,7 @@ Class TVC_Admin_Helper{
319
  }
320
 
321
  public function save_ee_options_settings($settings){
322
- update_option("ee_options", serialize(sanitize_option("ee_options", $settings) ));
323
  }
324
  /*
325
  * get plugin setting data from DB
@@ -400,7 +454,7 @@ Class TVC_Admin_Helper{
400
  return $this->store_data;
401
  }else{
402
  return $this->store_data = array(
403
- "subscription_id"=>$this->get_subscriptionId(),
404
  "user_domain" => $this->get_connect_actual_link(),
405
  "currency_code" => $this->get_woo_currency(),
406
  "timezone_string" => $this->get_time_zone(),
@@ -444,7 +498,7 @@ Class TVC_Admin_Helper{
444
  return $this->woo_currency;
445
  }else{
446
  $this->woo_currency = get_option('woocommerce_currency');
447
- return $this->woo_currency;
448
  }
449
  }
450
 
@@ -494,7 +548,7 @@ Class TVC_Admin_Helper{
494
  public function add_spinner_html(){
495
  $spinner_gif = ENHANCAD_PLUGIN_URL . '/admin/images/ajax-loader.gif';
496
  echo '<div class="feed-spinner" id="feed-spinner" style="display:none;">
497
- <img id="img-spinner" src="' . esc_url($spinner_gif) . '" alt="Loading" />
498
  </div>';
499
  }
500
 
@@ -572,10 +626,8 @@ Class TVC_Admin_Helper{
572
  }
573
 
574
  public function add_additional_option_val_in_map_product_attribute($key, $product_id){
575
- //echo $key."__".$product_id;
576
  if($key != "" && $product_id != ""){
577
  if($key == "brand"){
578
- //echo $key."__".$product_id;
579
  $is_plugin='yith-woocommerce-brands-add-on/init.php';
580
  $is_plugin_premium='yith-woocommerce-brands-add-on-premium/init.php';
581
  if(is_plugin_active($is_plugin) || is_plugin_active($is_plugin_premium)){
@@ -607,158 +659,6 @@ Class TVC_Admin_Helper{
607
  }
608
 
609
  /* end from input*/
610
- public function check_setting_status(){
611
- if(!empty($this->setting_status)){
612
- return $this->setting_status;
613
- }else{
614
- $google_detail = $this->get_ee_options_data();
615
- $setting_status = array();
616
- if(isset($google_detail['setting'])){
617
- $googleDetail = $google_detail['setting'];
618
- //for google analytic
619
- if(isset($googleDetail->tracking_option) && isset($googleDetail->measurement_id) && isset($googleDetail->property_id) && $googleDetail->tracking_option == "BOTH" ){
620
- if($googleDetail->property_id != "" && $googleDetail->measurement_id != ""){
621
- $setting_status['google_analytic']= true;
622
- $setting_status['google_analytic_msg']= "";
623
- }else if($googleDetail->property_id == "" ){
624
- $setting_status['google_analytic']= false;
625
- $setting_status['google_analytic_msg']= "There is a configuration issue in your Google Analytics account set up <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
626
- }else if($googleDetail->measurement_id == "" ){
627
- $setting_status['google_analytic']= false;
628
- $setting_status['google_analytic_msg']= "There is a configuration issue in your Google Analytics account set up <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
629
- }
630
- }else if(isset($googleDetail->tracking_option) && isset($googleDetail->measurement_id) && $googleDetail->tracking_option == "GA4"){
631
- if( $googleDetail->measurement_id != ""){
632
- $setting_status['google_analytic']= true;
633
- $setting_status['google_analytic_msg']= "";
634
- }else{
635
- $setting_status['google_analytic']= false;
636
- $setting_status['google_analytic_msg']= "There is a configuration issue in your Google Analytics account set up <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
637
- }
638
- }else if(isset($googleDetail->tracking_option) && isset($googleDetail->property_id) && $googleDetail->tracking_option == "UA" ){
639
- if($googleDetail->property_id != ""){
640
- $setting_status['google_analytic']= true;
641
- $setting_status['google_analytic_msg']= "";
642
- }else{
643
- $setting_status['google_analytic']= false;
644
- $setting_status['google_analytic_msg']= "There is a configuration issue in your Google Analytics account set up <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
645
- }
646
- }else{
647
- $setting_status['google_analytic']= false;
648
- $setting_status['google_analytic_msg']= "";
649
- }
650
- // for google shopping
651
- if(property_exists($googleDetail,"google_merchant_center_id") && property_exists($googleDetail,"google_ads_id") ){
652
- //main tab
653
- if( $googleDetail->google_merchant_center_id != "" && $googleDetail->google_ads_id != ""){
654
- $setting_status['google_shopping']= true;
655
- $setting_status['google_shopping_msg']= "";
656
- }else if($googleDetail->google_merchant_center_id == ""){
657
- $setting_status['google_shopping']= false;
658
- $setting_status['google_shopping_msg']= "Connect your merchant center account and make your products available to shoppers across Google <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
659
- }else if($googleDetail->google_ads_id == ""){
660
- $setting_status['google_shopping']= false;
661
- $setting_status['google_shopping_msg']= "Link your Google Ads with Merchant center to start running shopping campaigns <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
662
- }
663
- }else{
664
- $setting_status['google_shopping']= false;
665
- $setting_status['google_shopping_msg']= "";
666
- }
667
-
668
- //google_ads_id
669
- if(property_exists($googleDetail,"google_ads_id") && property_exists($googleDetail,"google_merchant_center_id") ){
670
- if( $googleDetail->google_ads_id != "" && $googleDetail->google_merchant_center_id != ""){
671
- $setting_status['google_ads']= true;
672
- $setting_status['google_ads_msg']= "";
673
- }else if($googleDetail->google_merchant_center_id == ""){
674
- $setting_status['google_ads']= false;
675
- $setting_status['google_ads_msg']= "Link your Google Ads with Merchant center to start running shopping campaigns <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
676
- }else if($googleDetail->google_ads_id == ""){
677
- $setting_status['google_ads']= false;
678
- $setting_status['google_ads_msg']= "Configure Google Ads account to reach to millions of interested shoppers <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
679
- }
680
- }else{
681
- $setting_status['google_ads']= false;
682
- $setting_status['google_ads_msg']= "";
683
- }
684
- }
685
- $this->setting_status = $setting_status;
686
- return $setting_status;
687
- }
688
- }
689
- public function check_setting_status_sub_tabs(){
690
- $google_detail = $this->get_ee_options_data();
691
- $setting_status = array();
692
- if(isset($google_detail['setting'])){
693
- $googleDetail = $google_detail['setting'];
694
- //sub tab shopping config
695
- if(property_exists($googleDetail,"google_merchant_center_id") && property_exists($googleDetail,"is_site_verified") && property_exists($googleDetail,"is_domain_claim") && property_exists($googleDetail,"google_ads_id")){
696
- if( $googleDetail->google_merchant_center_id != "" && $googleDetail->google_ads_id != "" && $googleDetail->is_site_verified == 1 && $googleDetail->is_domain_claim == 1 ){
697
- $setting_status['google_shopping_conf']= true;
698
- $setting_status['google_shopping_conf_msg']= esc_html__("Google Shopping Configuration Success.","conversios");
699
- }else if($googleDetail->google_merchant_center_id == "" || $googleDetail->google_ads_id == "" ){
700
- $setting_status['google_shopping_conf']= false;
701
- $setting_status['google_shopping_conf_msg']= "Connect your merchant center account and make your products available to shoppers across Google <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
702
- }else if($googleDetail->is_site_verified ==0 && $googleDetail->is_domain_claim ==0 ){
703
- $setting_status['google_shopping_conf']= false;
704
- $setting_status['google_shopping_conf_msg']= esc_html__("Site verification and domain claim for your merchant center account failed.","conversios");
705
- }else if($googleDetail->is_site_verified ==0 ){
706
- $setting_status['google_shopping_conf']= false;
707
- $setting_status['google_shopping_conf_msg']= esc_html__("Site verification and domain claim for your merchant center account failed.","conversios");
708
- }
709
- }else{
710
- $setting_status['google_shopping_conf']= false;
711
- $missing="";
712
- }
713
- //sub tab product sync
714
- $syncProductList = [];
715
- $syncProductStat = [];
716
- if(property_exists($googleDetail,"google_merchant_center_id") && $googleDetail->google_merchant_center_id != ''){
717
- if(isset($google_detail['prod_sync_status']) && $google_detail['prod_sync_status']){
718
- $syncProductStat = $google_detail['prod_sync_status'];
719
- $sync_product_total = (!empty($syncProductStat)) ? $syncProductStat->total : "0";
720
- $sync_product_approved = (!empty($syncProductStat)) ? $syncProductStat->approved : "0";
721
- $sync_product_disapproved = (!empty($syncProductStat)) ? $syncProductStat->disapproved : "0";
722
- $sync_product_pending = (!empty($syncProductStat)) ? $syncProductStat->pending : "0";
723
-
724
- if($sync_product_total > 1 && $sync_product_approved > 1 && $sync_product_disapproved < 1){
725
- $setting_status['google_shopping_p_sync']= true;
726
- $setting_status['google_shopping_p_sync_msg']= esc_html__("Google Shopping product sync is a success.","conversios");
727
- }else if($sync_product_total < 1){
728
- $setting_status['google_shopping_p_sync']= false;
729
- $setting_status['google_shopping_p_sync_msg']= esc_html__("Sync your product data into Merchant center and get eligible for free listing across Google.","conversios");
730
- }else if($sync_product_disapproved > 0){
731
- $setting_status['google_shopping_p_sync']= false;
732
- $setting_status['google_shopping_p_sync_msg']= esc_html__("There seems to be some problem with your product data. Rectify the issues by selecting right attributes.","conversios");
733
- }
734
- }
735
- }else{
736
- $setting_status['google_shopping_p_sync']= false;
737
- $setting_status['google_shopping_p_sync_msg']= "Connect your merchant center account and make your products available to shoppers across Google <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
738
- }
739
-
740
- //sub tab product Campaigns
741
- if(property_exists($googleDetail,"google_merchant_center_id") && $googleDetail->google_merchant_center_id != ''){
742
- if(isset($google_detail['campaigns_list']) && $google_detail['campaigns_list']){
743
- $campaigns_list = $google_detail['campaigns_list'];
744
- $totalCampaigns = count($campaigns_list);
745
- if($totalCampaigns < 1){
746
- $setting_status['google_shopping_p_campaigns']= false;
747
- $setting_status['google_shopping_p_campaigns_msg']= esc_html__("Reach out to customers based on their past site behavior by running start shopping campaign.","conversios");
748
- }else{
749
- $setting_status['google_shopping_p_campaigns']= true;
750
- }
751
- }else{
752
- $setting_status['google_shopping_p_campaigns']= false;
753
- $setting_status['google_shopping_p_campaigns_msg']= esc_html__("Reach out to customers based on their past site behavior by running start shopping campaign.","conversios");
754
- }
755
- }else{
756
- $setting_status['google_shopping_p_campaigns']= false;
757
- $setting_status['google_shopping_p_campaigns_msg']= "Connect your merchant center account and make your products available to shoppers across Google <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
758
- }
759
- }
760
- return $setting_status;
761
- }
762
 
763
  public function is_current_tab_in($tabs){
764
  if(isset($_GET['tab']) && is_array($tabs) && in_array(sanitize_text_field($_GET['tab']), $tabs)){
@@ -823,11 +723,11 @@ Class TVC_Admin_Helper{
823
  <div class="errormsgtopbx claimalert">
824
  <div class="errmscntbx">
825
  <div class="errmsglft">
826
- <span class="errmsgicon"><img src="<?php echo esc_url(ENHANCAD_PLUGIN_URL.'/admin/images/error-white-icon.png'); ?>" alt="error" /></span>
827
  </div>
828
  <div class="erralertrigt">
829
- <h6><?php echo $title; ?></h6>
830
- <p><?php echo $message; ?> <a href="javascript:void(0)" id="call_both_verification" onclick="call_tvc_site_verified_and_domain_claim('<?php echo $call_js_function_args; ?>');">Click here</a> <?php esc_html_e("to verify and claim the domain.","conversios"); ?></p>
831
  </div>
832
  </div>
833
  </div>
@@ -898,10 +798,10 @@ Class TVC_Admin_Helper{
898
  }else if(property_exists($googleDetail,"is_domain_claim") && $googleDetail->is_domain_claim == '0'){
899
  //'website_url' => $googleDetail->site_url,
900
  $postData = [
901
- 'merchant_id' => $googleDetail->merchant_id,
902
- 'website_url' => get_site_url(),
903
- 'subscription_id' => $googleDetail->id,
904
- 'account_id' => $googleDetail->google_merchant_center_id
905
  ];
906
  $claimWebsite = $this->customApiObj->claimWebsite($postData);
907
  if(isset($claimWebsite->error) && !empty($claimWebsite->errors)){
@@ -925,10 +825,10 @@ Class TVC_Admin_Helper{
925
  if(property_exists($googleDetail,"is_site_verified") && $googleDetail->is_site_verified == '0'){
926
  //'website_url' => $googleDetail->site_url,
927
  $postData = [
928
- 'merchant_id' => $googleDetail->merchant_id,
929
  'website_url' => get_site_url(),
930
- 'subscription_id' => $googleDetail->id,
931
- 'account_id' => $googleDetail->google_merchant_center_id
932
  ];
933
  $postData['method']="file";
934
  $siteVerificationToken = $this->customApiObj->siteVerificationToken($postData);
@@ -954,19 +854,19 @@ Class TVC_Admin_Helper{
954
  if(isset($siteVerificationToken_tag->data->token) && $siteVerificationToken_tag->data->token){
955
  $ee_additional_data = $this->get_ee_additional_data();
956
  $ee_additional_data['add_site_varification_tag']=1;
957
- $ee_additional_data['site_varification_tag_val']=base64_encode($siteVerificationToken_tag->data->token);
958
 
959
  $this->set_ee_additional_data($ee_additional_data);
960
  sleep(1);
961
  $siteVerification_tag = $this->customApiObj->siteVerification($postData);
962
  if(isset($siteVerification_tag->error) && !empty($siteVerification_tag->errors)){
963
- return array('error'=>true, 'msg'=>$siteVerification_tag->errors[0]);
964
  }else{
965
  $this->update_subscription_details_api_to_db();
966
  return array('error'=>false, 'msg'=>esc_html__("Site verification successfully.","conversios"));
967
  }
968
  }else{
969
- return array('error'=>true, 'msg'=>$siteVerificationToken_tag->errors[0]);
970
  }
971
  // one more try
972
  }else{
@@ -998,7 +898,7 @@ Class TVC_Admin_Helper{
998
  }
999
 
1000
  public function get_auto_sync_batch_size(){
1001
- return "200";
1002
  }
1003
 
1004
  public function get_last_auto_sync_product_info(){
@@ -1019,7 +919,7 @@ Class TVC_Admin_Helper{
1019
 
1020
  public function getTableColumns($table) {
1021
  global $wpdb;
1022
- $tablename = $wpdb->prefix .$table;
1023
  return $wpdb->get_results("SELECT column_name as field FROM information_schema.columns WHERE table_name = '$table'");
1024
  }
1025
 
@@ -1032,12 +932,12 @@ Class TVC_Admin_Helper{
1032
  }
1033
  /* message notification */
1034
  public function set_ee_msg_nofification_list($ee_msg_list){
1035
- update_option("ee_msg_nofifications", serialize(sanitize_option("ee_msg_nofifications", $ee_msg_list) ));
1036
  }
1037
  public function get_ee_msg_nofification_list(){
1038
  return unserialize(get_option('ee_msg_nofifications'));
1039
  }
1040
- public function add_ee_msg_nofification($key, $html, $title = null, $link = null, $link_title = null, $overwrite= false, $link_type = "internal"){
1041
  $ee_msg_list = $this->get_ee_msg_nofification_list();
1042
  if((!isset($ee_msg_list[$key]) && $html !="") ||($overwrite == true && isset($ee_msg_list[$key]) && $html !="")){
1043
  $msg = array();
@@ -1061,9 +961,7 @@ Class TVC_Admin_Helper{
1061
 
1062
  public function add_tvc_fixed_nofification(){
1063
  $nofifications = [];
1064
- /*
1065
- * add fixed notification
1066
- */
1067
  $nofifications["tvc_f_notif_1"] = array(
1068
  "tittle"=>esc_html__("Congratulations..!! You are one step closer.","conversios"),
1069
  "html"=>esc_html__("Thanks for installing the new avatar of Enhanced Ecommerce for WooCommerce plugin. Explore the full potential of Google Analytics, Google Ads and Google shopping by setting up all your Google accounts and take data driven decisions to scale your eCommerce business faster.", "conversios")
@@ -1075,9 +973,7 @@ Class TVC_Admin_Helper{
1075
  "link_title"=>esc_html__("Share Feedback", "conversios"),
1076
  "link_type"=>"external"
1077
  );
1078
- /*
1079
- * add payment notification
1080
- */
1081
  $google_detail = $this->get_ee_options_data();
1082
  if(isset($google_detail['setting'])){
1083
  $googleDetail = $google_detail['setting'];
@@ -1096,12 +992,7 @@ Class TVC_Admin_Helper{
1096
  );
1097
  }
1098
  $diffrent_day = floor(( $current - $subscription_expiry_time)/(60*60*24)-1);
1099
- /*if($diffrent_day == 5 ){
1100
- $nofifications["tvc_expired_plan_not_".date("YYYY_m_d",$current)] = array(
1101
- "tittle"=>"Your plan expired.",
1102
- "html"=>"Your subscription plan has been expiring in some time."
1103
- );
1104
- }*/
1105
  if($diffrent_day == 6 ){
1106
  $nofifications["tvc_expired_plan_not_".date("YYYY_m_d",$current)] = array(
1107
  "tittle"=>"Plan Expired..!!",
@@ -1111,9 +1002,7 @@ Class TVC_Admin_Helper{
1111
  }
1112
 
1113
  }
1114
- /*
1115
- * add notifications
1116
- */
1117
  if(!empty($nofifications)){
1118
  foreach ($nofifications as $key => $value){
1119
  if(isset($value["html"]) && $value["html"] != ""){
@@ -1124,7 +1013,7 @@ Class TVC_Admin_Helper{
1124
  }
1125
  }
1126
  }
1127
- }
1128
 
1129
  public function active_licence($licence_key, $subscription_id){
1130
  if($licence_key != ""){
23
  $this->includes();
24
  $this->customApiObj = new CustomApi();
25
  $this->TVC_Admin_DB_Helper = new TVC_Admin_DB_Helper();
26
+ add_action('init',array($this, 'init'));
27
+
28
  }
29
 
30
  public function includes() {
33
  }
34
  if (!class_exists('ShoppingApi')) {
35
  require_once(ENHANCAD_PLUGIN_DIR . 'includes/setup/ShoppingApi.php');
36
+ }
37
+ }
38
+
39
+ public function init(){
40
+ add_filter('sanitize_option_ee_auto_update_id', array($this, 'sanitize_option_ee_general'), 10, 2);
41
+ add_filter('sanitize_option_ee_remarketing_snippets', array($this, 'sanitize_option_ee_general'), 10, 2);
42
+ add_filter('sanitize_option_ee_conversio_send_to', array($this, 'sanitize_option_ee_general'), 10, 2);
43
+ add_filter('sanitize_option_ee_api_data', array($this, 'sanitize_option_ee_general'), 10, 2);
44
+ add_filter('sanitize_option_ee_additional_data', array($this, 'sanitize_option_ee_general'), 10, 2);
45
+ add_filter('sanitize_option_ee_options', array($this, 'sanitize_option_ee_general'), 10, 2);
46
+ add_filter('sanitize_option_ee_msg_nofifications', array($this, 'sanitize_option_ee_general'), 10, 2);
47
+ add_filter('sanitize_option_google_ads_conversion_tracking', array($this, 'sanitize_option_ee_general'), 10, 2);
48
+ add_filter('sanitize_option_ads_tracking_id', array($this, 'sanitize_option_ee_general'), 10, 2);
49
+ add_filter('sanitize_option_ads_ert', array($this, 'sanitize_option_ee_general'), 10, 2);
50
+ add_filter('sanitize_option_ads_edrt', array($this, 'sanitize_option_ee_general'), 10, 2);
51
+ add_filter('sanitize_option_ee_customer_gmail', array($this, 'sanitize_option_ee_email'), 10, 2);
52
+ add_filter('sanitize_option_ee_prod_mapped_cats', array($this, 'sanitize_option_ee_general'), 10, 2);
53
+ add_filter('sanitize_option_ee_prod_mapped_attrs', array($this, 'sanitize_option_ee_general'), 10, 2);
54
+
55
+ add_filter( 'sanitize_post_meta__tracked', array($this, 'sanitize_meta_ee_number'));
56
+ }
57
+
58
+ public function sanitize_meta_ee_number($value){
59
+ $value = (int) $value;
60
+ if ( empty( $value ) ) {
61
+ $value = 1;
62
+ }
63
+ if ( $value < -1 ) {
64
+ $value = abs( $value );
65
+ }
66
+ return $value;
67
+ }
68
+
69
+ public function sanitize_option_ee_email($value, $option){
70
+ global $wpdb;
71
+ $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
72
+ if ( is_wp_error( $value ) ) {
73
+ $error = $value->get_error_message();
74
+ } else {
75
+ $value = sanitize_email( $value );
76
+ if ( ! is_email( $value ) ) {
77
+ $error = esc_html__( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' );
78
+ }
79
+ }
80
+ if ( ! empty( $error ) ) {
81
+ $value = get_option( $option );
82
+ if ( function_exists( 'add_settings_error' ) ) {
83
+ add_settings_error( $option, "invalid_{$option}", $error );
84
+ }
85
+ }
86
+ return $value;
87
+ }
88
+
89
+ public function sanitize_option_ee_general($value, $option){
90
+ global $wpdb;
91
+ $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
92
+ if ( is_wp_error( $value ) ) {
93
+ $error = $value->get_error_message();
94
+ }
95
+ if ( ! empty( $error ) ) {
96
+ $value = get_option( $option );
97
+ if ( function_exists( 'add_settings_error' ) ) {
98
+ add_settings_error( $option, "invalid_{$option}", $error );
99
+ }
100
+ }
101
+ return $value;
102
  }
103
  /*
104
  * verstion auto updated
117
  $tablename = $wpdb->prefix ."ee_product_sync_call";
118
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
119
  new TVC_Admin_Auto_Product_sync_Helper();
120
+ update_option("ee_auto_update_id", $new_ee_auto_update_id );
121
  }
122
  if($ee_auto_update_id == "tvc_4.5.1"){
123
  //tvc_4.5.1
124
  $this->update_subscription_details_api_to_db();
125
  }
126
  }else{
127
+ update_option("ee_auto_update_id", $old_ee_auto_update_id );
128
  }
129
  }
130
  /*
165
  $google_detail = $this->customApiObj->getGoogleAnalyticDetail();
166
  if(property_exists($google_detail,"error") && $google_detail->error == false){
167
  if(property_exists($google_detail,"data") && $google_detail->data != ""){
168
+ $google_detail->data->access_token = base64_encode(sanitize_text_field($google_detail->data->access_token));
169
+ $google_detail->data->refresh_token = base64_encode(sanitize_text_field($google_detail->data->refresh_token));
170
  $googleDetail = $google_detail->data;
171
  }
172
  }
185
  $google_detail = $this->customApiObj->getGoogleAnalyticDetail();
186
  if(property_exists($google_detail,"error") && $google_detail->error == false){
187
  if(property_exists($google_detail,"data") && $google_detail->data != "") {
188
+ $google_detail->data->access_token = base64_encode(sanitize_text_field($google_detail->data->access_token));
189
+ $google_detail->data->refresh_token = base64_encode(sanitize_text_field($google_detail->data->refresh_token));
190
  $googleDetail = $google_detail->data;
191
  }
192
  }else{
197
  $syncProductList = [];
198
  $campaigns_list = [];
199
  if(isset($googleDetail->google_merchant_center_id) && $googleDetail->google_merchant_center_id != ""){
 
 
 
 
 
 
 
 
 
200
  if($is_import_gmc_products){
201
  $this->import_gmc_products_sync_in_db();
202
  }
209
  }
210
  $syncProductStat["total"] = $this->TVC_Admin_DB_Helper->tvc_row_count('ee_products_sync_list');
211
  }else{
212
+ $syncProductStat = array("total" =>0, "approved" => 0, "disapproved" => 0, "pending" => 0 );
213
  }
214
  if(isset($googleDetail->google_ads_id) && $googleDetail->google_ads_id != ""){
215
  $this->update_remarketing_snippets();
221
  }
222
  }
223
  }
224
+
225
  $this->set_ee_options_data(array("setting" => $googleDetail, "prod_sync_status" => (object) $syncProductStat, "campaigns_list"=>$campaigns_list, "sync_time"=>current_time( 'timestamp' )));
226
  return array("error"=>false, "message"=>esc_html__("Details updated successfully.","conversios"));
227
  }
234
  $rs = $this->customApiObj->get_remarketing_snippets($customer_id);
235
  $remarketing_snippets=array();
236
  if(property_exists($rs,"error") && $rs->error == false){
237
+ if(property_exists($rs,"data") && $rs->data != "" && isset($remarketing_snippets["snippets"])) {
238
  $remarketing_snippets["snippets"]=base64_encode($rs->data->snippets);
239
  $remarketing_snippets["id"]=$rs->data->id;
240
  }
241
  }
242
+ update_option("ee_remarketing_snippets", serialize( $remarketing_snippets ));
243
  }
244
  }
245
  /*
265
  foreach ($con_array as $key => $con_value) {
266
  $con_val_array = explode(":", $con_value);
267
  if(in_array("send_to", $con_val_array)){
268
+ update_option("ee_conversio_send_to", $con_val_array[1] );
269
  break 2;
270
  }
271
  }
272
  }
273
  }
274
  }
275
+ }
 
 
276
  }
277
  }
278
  /*
287
  if(!empty($last_row) && isset($last_row['gmc_id']) && $last_row['gmc_id'] != $merchant_id){
288
  global $wpdb;
289
  $tablename = $wpdb->prefix ."ee_products_sync_list";
 
290
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
291
  $tablename = $wpdb->prefix ."ee_product_sync_data";
292
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
293
  $tablename = $wpdb->prefix ."ee_product_sync_call";
294
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
 
295
  }else if( $next_page_token =="" ){
296
  global $wpdb;
297
  $tablename = $wpdb->prefix ."ee_products_sync_list";
300
  if( $merchant_id != "" ){
301
  $args = array( 'merchant_id' => $merchant_id );
302
  if($next_page_token != ""){
303
+ $args["pageToken"] = sanitize_text_field($next_page_token);
304
  }
305
  $syncProduct_list_res = $this->customApiObj->getSyncProductList($args);
306
  if(isset($syncProduct_list_res->data) && isset($syncProduct_list_res->status) && $syncProduct_list_res->status == 200){
315
  }
316
  $t_data = array(
317
  'gmc_id' => esc_sql($merchant_id),
318
+ 'name' => esc_sql($value->name),
319
+ 'product_id' => esc_sql($value->productId),
320
+ 'google_status' => esc_sql($googleStatus),
321
+ 'image_link' => esc_sql($value->imageLink),
322
+ 'issues' => json_encode($value->issues)
323
  );
324
  $where ="product_id = '".esc_sql($value->productId)."'";
325
  $row_count = $this->TVC_Admin_DB_Helper->tvc_check_row('ee_products_sync_list', $where);
352
  * set API data in DB
353
  */
354
  public function set_ee_options_data($ee_options_data){
355
+ update_option("ee_api_data", serialize( $ee_options_data ));
356
  }
357
  /*
358
  * set additional data in DB
359
  */
360
  public function set_ee_additional_data($ee_additional_data){
361
+ update_option("ee_additional_data", serialize($ee_additional_data));
362
  }
363
  /*
364
  * get additional data from DB
373
  }
374
 
375
  public function save_ee_options_settings($settings){
376
+ update_option("ee_options", serialize( $settings) );
377
  }
378
  /*
379
  * get plugin setting data from DB
454
  return $this->store_data;
455
  }else{
456
  return $this->store_data = array(
457
+ "subscription_id"=> $this->get_subscriptionId(),
458
  "user_domain" => $this->get_connect_actual_link(),
459
  "currency_code" => $this->get_woo_currency(),
460
  "timezone_string" => $this->get_time_zone(),
498
  return $this->woo_currency;
499
  }else{
500
  $this->woo_currency = get_option('woocommerce_currency');
501
+ return $this->woo_currency;
502
  }
503
  }
504
 
548
  public function add_spinner_html(){
549
  $spinner_gif = ENHANCAD_PLUGIN_URL . '/admin/images/ajax-loader.gif';
550
  echo '<div class="feed-spinner" id="feed-spinner" style="display:none;">
551
+ <img id="img-spinner" src="' . esc_url_raw($spinner_gif) . '" alt="Loading" />
552
  </div>';
553
  }
554
 
626
  }
627
 
628
  public function add_additional_option_val_in_map_product_attribute($key, $product_id){
 
629
  if($key != "" && $product_id != ""){
630
  if($key == "brand"){
 
631
  $is_plugin='yith-woocommerce-brands-add-on/init.php';
632
  $is_plugin_premium='yith-woocommerce-brands-add-on-premium/init.php';
633
  if(is_plugin_active($is_plugin) || is_plugin_active($is_plugin_premium)){
659
  }
660
 
661
  /* end from input*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662
 
663
  public function is_current_tab_in($tabs){
664
  if(isset($_GET['tab']) && is_array($tabs) && in_array(sanitize_text_field($_GET['tab']), $tabs)){
723
  <div class="errormsgtopbx claimalert">
724
  <div class="errmscntbx">
725
  <div class="errmsglft">
726
+ <span class="errmsgicon"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/error-white-icon.png'); ?>" alt="error" /></span>
727
  </div>
728
  <div class="erralertrigt">
729
+ <h6><?php echo esc_attr($title); ?></h6>
730
+ <p><?php echo esc_attr($message); ?> <a href="javascript:void(0)" id="call_both_verification" onclick="call_tvc_site_verified_and_domain_claim('<?php echo esc_attr($call_js_function_args); ?>');"><?php esc_html_e("Click here","conversios"); ?></a> <?php esc_html_e("to verify and claim the domain.","conversios"); ?></p>
731
  </div>
732
  </div>
733
  </div>
798
  }else if(property_exists($googleDetail,"is_domain_claim") && $googleDetail->is_domain_claim == '0'){
799
  //'website_url' => $googleDetail->site_url,
800
  $postData = [
801
+ 'merchant_id' => sanitize_text_field($googleDetail->merchant_id),
802
+ 'website_url' => get_site_url(),
803
+ 'subscription_id' => sanitize_text_field($googleDetail->id),
804
+ 'account_id' => sanitize_text_field($googleDetail->google_merchant_center_id)
805
  ];
806
  $claimWebsite = $this->customApiObj->claimWebsite($postData);
807
  if(isset($claimWebsite->error) && !empty($claimWebsite->errors)){
825
  if(property_exists($googleDetail,"is_site_verified") && $googleDetail->is_site_verified == '0'){
826
  //'website_url' => $googleDetail->site_url,
827
  $postData = [
828
+ 'merchant_id' => sanitize_text_field($googleDetail->merchant_id),
829
  'website_url' => get_site_url(),
830
+ 'subscription_id' => sanitize_text_field($googleDetail->id),
831
+ 'account_id' => sanitize_text_field($googleDetail->google_merchant_center_id)
832
  ];
833
  $postData['method']="file";
834
  $siteVerificationToken = $this->customApiObj->siteVerificationToken($postData);
854
  if(isset($siteVerificationToken_tag->data->token) && $siteVerificationToken_tag->data->token){
855
  $ee_additional_data = $this->get_ee_additional_data();
856
  $ee_additional_data['add_site_varification_tag']=1;
857
+ $ee_additional_data['site_varification_tag_val']=base64_encode(sanitize_text_field($siteVerificationToken_tag->data->token));
858
 
859
  $this->set_ee_additional_data($ee_additional_data);
860
  sleep(1);
861
  $siteVerification_tag = $this->customApiObj->siteVerification($postData);
862
  if(isset($siteVerification_tag->error) && !empty($siteVerification_tag->errors)){
863
+ return array('error'=>true, 'msg'=>esc_html($siteVerification_tag->errors[0]));
864
  }else{
865
  $this->update_subscription_details_api_to_db();
866
  return array('error'=>false, 'msg'=>esc_html__("Site verification successfully.","conversios"));
867
  }
868
  }else{
869
+ return array('error'=>true, 'msg'=> esc_html($siteVerificationToken_tag->errors[0]));
870
  }
871
  // one more try
872
  }else{
898
  }
899
 
900
  public function get_auto_sync_batch_size(){
901
+ return "100";
902
  }
903
 
904
  public function get_last_auto_sync_product_info(){
919
 
920
  public function getTableColumns($table) {
921
  global $wpdb;
922
+ $tablename = $wpdb->prefix .esc_sql($table);
923
  return $wpdb->get_results("SELECT column_name as field FROM information_schema.columns WHERE table_name = '$table'");
924
  }
925
 
932
  }
933
  /* message notification */
934
  public function set_ee_msg_nofification_list($ee_msg_list){
935
+ update_option("ee_msg_nofifications", serialize( $ee_msg_list ));
936
  }
937
  public function get_ee_msg_nofification_list(){
938
  return unserialize(get_option('ee_msg_nofifications'));
939
  }
940
+ /*public function add_ee_msg_nofification($key, $html, $title = null, $link = null, $link_title = null, $overwrite= false, $link_type = "internal"){
941
  $ee_msg_list = $this->get_ee_msg_nofification_list();
942
  if((!isset($ee_msg_list[$key]) && $html !="") ||($overwrite == true && isset($ee_msg_list[$key]) && $html !="")){
943
  $msg = array();
961
 
962
  public function add_tvc_fixed_nofification(){
963
  $nofifications = [];
964
+
 
 
965
  $nofifications["tvc_f_notif_1"] = array(
966
  "tittle"=>esc_html__("Congratulations..!! You are one step closer.","conversios"),
967
  "html"=>esc_html__("Thanks for installing the new avatar of Enhanced Ecommerce for WooCommerce plugin. Explore the full potential of Google Analytics, Google Ads and Google shopping by setting up all your Google accounts and take data driven decisions to scale your eCommerce business faster.", "conversios")
973
  "link_title"=>esc_html__("Share Feedback", "conversios"),
974
  "link_type"=>"external"
975
  );
976
+
 
 
977
  $google_detail = $this->get_ee_options_data();
978
  if(isset($google_detail['setting'])){
979
  $googleDetail = $google_detail['setting'];
992
  );
993
  }
994
  $diffrent_day = floor(( $current - $subscription_expiry_time)/(60*60*24)-1);
995
+
 
 
 
 
 
996
  if($diffrent_day == 6 ){
997
  $nofifications["tvc_expired_plan_not_".date("YYYY_m_d",$current)] = array(
998
  "tittle"=>"Plan Expired..!!",
1002
  }
1003
 
1004
  }
1005
+
 
 
1006
  if(!empty($nofifications)){
1007
  foreach ($nofifications as $key => $value){
1008
  if(isset($value["html"]) && $value["html"] != ""){
1013
  }
1014
  }
1015
  }
1016
+ } */
1017
 
1018
  public function active_licence($licence_key, $subscription_id){
1019
  if($licence_key != ""){
admin/helper/class-onboarding-helper.php CHANGED
@@ -62,7 +62,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
62
  public function get_analytics_web_properties(){
63
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
64
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
65
- $tvc_data = (object)$_POST['tvc_data'];
 
66
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
67
  echo json_encode($api_obj->getAnalyticsWebProperties($_POST));
68
  wp_die();
@@ -78,7 +79,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
78
  public function save_analytics_data(){
79
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
80
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
81
- $tvc_data = (object)$_POST['tvc_data'];
 
82
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
83
  /*sendingblue*/
84
  $data = array();
@@ -103,7 +105,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
103
  public function list_googl_ads_account(){
104
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
105
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
106
- $tvc_data = (object)$_POST['tvc_data'];
 
107
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
108
  echo json_encode($api_obj->getGoogleAdsAccountList($_POST));
109
  wp_die();
@@ -118,7 +121,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
118
  public function create_google_ads_account(){
119
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
120
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
121
- $tvc_data = (object)$_POST['tvc_data'];
 
122
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
123
  echo json_encode($api_obj->createGoogleAdsAccount($_POST));
124
  wp_die();
@@ -134,7 +138,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
134
  public function save_google_ads_data(){
135
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
136
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
137
- $tvc_data = (object)$_POST['tvc_data'];
 
138
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
139
  /*sendingblue*/
140
  $data = array();
@@ -159,7 +164,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
159
  public function link_analytic_to_ads_account(){
160
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
161
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
162
- $tvc_data = (object)$_POST['tvc_data'];
 
163
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
164
  echo json_encode($api_obj->linkAnalyticToAdsAccount($_POST));
165
  wp_die();
@@ -175,7 +181,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
175
  public function list_google_merchant_account(){
176
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
177
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
178
- $tvc_data = (object)$_POST['tvc_data'];
 
179
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
180
  echo json_encode($api_obj->listMerchantCenterAccount($_POST));
181
  wp_die();
@@ -190,7 +197,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
190
  public function create_google_merchant_center_account(){
191
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
192
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
193
- $tvc_data = (object)$_POST['tvc_data'];
 
194
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
195
  echo json_encode($api_obj->createMerchantAccount($_POST));
196
  wp_die();
@@ -206,7 +214,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
206
  public function save_merchant_data(){
207
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
208
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
209
- $tvc_data = (object)$_POST['tvc_data'];
 
210
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
211
  /*sendingblue*/
212
  $data = array();
@@ -230,7 +239,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
230
  public function get_conversion_list(){
231
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
232
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
233
- $tvc_data = (object)$_POST['tvc_data'];
 
234
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
235
  unset($_POST['tvc_data']);
236
  unset($_POST['conversios_onboarding_nonce']);
@@ -248,7 +258,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
248
  public function link_google_ads_to_merchant_center(){
249
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
250
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
251
- $tvc_data = (object)$_POST['tvc_data'];
 
252
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
253
  echo json_encode($api_obj->linkGoogleAdsToMerchantCenter($_POST));
254
  wp_die();
@@ -263,9 +274,10 @@ if(!class_exists('Conversios_Onboarding_Helper')):
263
  public function get_subscription_details(){
264
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
265
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
266
- $tvc_data = (object)$_POST['tvc_data'];
 
267
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
268
- echo json_encode($api_obj->getSubscriptionDetails($_POST['tvc_data'], sanitize_text_field($_POST['subscription_id']) ));
269
  wp_die();
270
  }else{
271
  echo esc_html__("Admin security nonce is not verified.","conversios");
@@ -279,7 +291,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
279
  public function update_setup_time_to_subscription(){
280
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
281
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
282
- $tvc_data = (object)$_POST['tvc_data'];
 
283
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
284
  $return_url = $this->save_wp_setting_from_subscription_api($api_obj, $tvc_data, sanitize_text_field($_POST['subscription_id']) );
285
  $return_rs = $api_obj->updateSetupTimeToSubscription($_POST);
@@ -341,10 +354,10 @@ if(!class_exists('Conversios_Onboarding_Helper')):
341
  $settings['ga_PrivacyPolicy'] = 'on';
342
  $settings['google-analytic'] = '';
343
  //update option in wordpress local database
344
- update_option('google_ads_conversion_tracking', sanitize_option('google_ads_conversion_tracking', $googleDetail->google_ads_conversion_tracking));
345
- update_option('ads_tracking_id', sanitize_option('ads_tracking_id', $googleDetail->google_ads_id));
346
- update_option('ads_ert', sanitize_option('ads_ert', $googleDetail->remarketing_tags));
347
- update_option('ads_edrt', sanitize_option('ads_edrt', $googleDetail->dynamic_remarketing_tags));
348
 
349
  $TVC_Admin_Helper->save_ee_options_settings($settings);
350
  /*
@@ -360,10 +373,7 @@ if(!class_exists('Conversios_Onboarding_Helper')):
360
  * save gmail and view ID in WP DB
361
  */
362
  if(property_exists($tvc_data,"g_mail") && sanitize_email($tvc_data->g_mail)){
363
- update_option('ee_customer_gmail', sanitize_option('ee_customer_gmail', $tvc_data->g_mail));
364
- }
365
- if(isset($_POST['ga_view_id']) && sanitize_text_field($_POST['ga_view_id'])){
366
- update_option('ee_ga_view_id', sanitize_text_field($_POST['ga_view_id']));
367
  }
368
  $return_url = "admin.php?page=conversios-google-shopping-feed&tab=gaa_config_page";
369
  if(isset($googleDetail->google_merchant_center_id) || isset($googleDetail->google_ads_id) ){
@@ -527,7 +537,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
527
  $tvc_data = (object)$tvc_data;
528
  $access_token = sanitize_text_field(base64_decode($this->access_token));
529
  $url = $this->apiDomain . '/customer-subscriptions/subscription-detail';
530
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json", "AccessToken: $access_token");
531
  $data = [
532
  'subscription_id' => sanitize_text_field($subscription_id),//$this->subscription_id,
533
  'domain' => sanitize_text_field($tvc_data->user_domain)
@@ -535,7 +545,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
535
  $args = array(
536
  'headers' =>$header,
537
  'method' => 'POST',
538
- 'body' => $data
539
  );
540
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
541
 
@@ -616,7 +626,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
616
  'Content-Type' => 'application/json',
617
  'RefreshToken' => $refresh_token
618
  ),
619
- 'body' => wp_json_encode($data)
620
  );
621
  $request = wp_remote_post(esc_url_raw($url), $args);
622
 
@@ -648,14 +658,14 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
648
  public function listMerchantCenterAccount() {
649
  try {
650
  $url = $this->apiDomain . '/gmc/user-merchant-center/list';
651
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
652
  $data = [
653
  'access_token' => sanitize_text_field(base64_decode($this->access_token)),
654
  ];
655
  $args = array(
656
  'headers' =>$header,
657
  'method' => 'POST',
658
- 'body' => $data
659
  );
660
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
661
  $return = new \stdClass();
@@ -677,21 +687,25 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
677
 
678
  public function createGoogleAdsAccount($postData) {
679
  try {
680
- $tvc_data = (object)$postData['tvc_data'];
 
 
681
  $url = $this->apiDomain . '/adwords/create-ads-account';
682
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
683
  $data = [
684
  'email' => sanitize_email($tvc_data->g_mail),
685
  'currency' => sanitize_text_field($tvc_data->currency_code),
686
  'time_zone' => sanitize_text_field($tvc_data->timezone_string), //'Asia/Kolkata',
687
  'domain' => sanitize_text_field($tvc_data->user_domain)
688
  ];
 
689
  $args = array(
690
  'headers' =>$header,
691
  'method' => 'POST',
692
- 'body' => $data
693
  );
694
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
 
695
  $return = new \stdClass();
696
  if($result->status == 200){
697
  $return->status = $result->status;
@@ -700,7 +714,8 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
700
  return $return;
701
  }else{
702
  $return->error = true;
703
- $return->data = $result->data;
 
704
  $return->status = $result->status;
705
  return $return;
706
  }
@@ -711,9 +726,12 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
711
  public function createMerchantAccount($postData) {
712
  try {
713
  $url = $this->apiDomain . '/gmc/create';
714
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
 
 
 
715
  $data = [
716
- 'merchant_id' => $this->merchantId, //'256922349',
717
  'name' => sanitize_text_field($postData['store_name']),
718
  'website_url' => esc_url_raw(sanitize_text_field($postData['website_url'])),
719
  'customer_id' => sanitize_text_field($postData['customer_id']),
@@ -734,12 +752,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
734
  $args = array(
735
  'headers' =>$header,
736
  'method' => 'POST',
737
- 'body' => $data
738
- );
739
- $args = array(
740
- 'headers' =>$header,
741
- 'method' => 'POST',
742
- 'body' => $data
743
  );
744
  $args['timeout']= "1000";
745
  $request = wp_remote_post(esc_url_raw($url), $args);
@@ -766,7 +779,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
766
  public function saveAnalyticsData($postData = array()) {
767
  try {
768
  $url = $this->apiDomain . '/customer-subscriptions/update-detail';
769
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
770
  $data = array(
771
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
772
  'tracking_option' => sanitize_text_field((isset($postData['tracking_option']))?$postData['tracking_option'] : ''),
@@ -784,7 +797,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
784
  $args = array(
785
  'headers' =>$header,
786
  'method' => 'POST',
787
- 'body' => $data
788
  );
789
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
790
  $return = new \stdClass();
@@ -807,7 +820,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
807
  public function saveGoogleAdsData($postData = array()){
808
  try {
809
  $url = $this->apiDomain . '/customer-subscriptions/update-detail';
810
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
811
  $data = [
812
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
813
  'google_ads_id' => sanitize_text_field((isset($postData['google_ads_id']))? $postData['google_ads_id'] : ''),
@@ -819,7 +832,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
819
  $args = array(
820
  'headers' =>$header,
821
  'method' => 'POST',
822
- 'body' => $data
823
  );
824
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
825
  $return = new \stdClass();
@@ -842,7 +855,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
842
  public function saveMechantData($postData = array()) {
843
  try {
844
  $url = $this->apiDomain . '/customer-subscriptions/update-detail';
845
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
846
  $data = [
847
  'merchant_id' => sanitize_text_field(($postData['merchant_id'] == 'NewMerchant') ? $this->merchantId: $postData['merchant_id']),
848
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
@@ -853,7 +866,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
853
  $args = array(
854
  'headers' =>$header,
855
  'method' => 'POST',
856
- 'body' => $data
857
  );
858
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
859
  $return = new \stdClass();
@@ -878,7 +891,6 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
878
  $url = $this->apiDomain . '/google-analytics/link-ads-to-analytics';
879
  $access_token = sanitize_text_field(base64_decode($this->access_token));
880
  $refresh_token = sanitize_text_field(base64_decode($this->refresh_token));
881
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json", "AccessToken:$access_token", "RefreshToken:$refresh_token");
882
  if ($postData['type'] == "UA") {
883
  $data = [
884
  'type' => sanitize_text_field($postData['type']),
@@ -897,22 +909,36 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
897
  'web_property' => sanitize_text_field($postData['web_property']),
898
  ];
899
  }
 
900
  $args = array(
901
- 'headers' =>$header,
 
 
 
 
 
 
902
  'method' => 'POST',
903
- 'body' => $data
904
  );
905
- $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
 
 
 
 
 
 
906
  $return = new \stdClass();
907
- if($result->status == 200){
908
- $return->status = $result->status;
909
  $return->data = $result->data;
910
  $return->error = false;
911
  return $return;
912
  }else{
913
  $return->error = true;
914
- $return->data = $result->data;
915
- $return->status = $result->status;
 
916
  return $return;
917
  }
918
  } catch (Exception $e) {
@@ -923,28 +949,39 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
923
  try {
924
  $url = $this->apiDomain . '/adwords/link-ads-to-merchant-center';
925
  $access_token = sanitize_text_field(base64_decode($this->access_token));
926
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json", "AccessToken:$access_token");
927
  $data = [
928
  'merchant_id' => sanitize_text_field(($postData['merchant_id']) == 'NewMerchant' ? $this->merchantId: $postData['merchant_id']),
929
  'account_id' => sanitize_text_field($postData['account_id']),
930
  'adwords_id' => sanitize_text_field($postData['adwords_id'])
931
  ];
932
  $args = array(
933
- 'headers' =>$header,
934
- 'method' => 'POST',
935
- 'body' => $data
 
 
 
 
936
  );
937
- $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
 
 
 
 
 
 
 
938
  $return = new \stdClass();
939
- if($result->status == 200){
940
- $return->status = $result->status;
941
  $return->data = $result->data;
942
  $return->error = false;
943
  return $return;
944
  }else{
945
  $return->error = true;
946
- $return->data = $result->data;
947
- $return->status = $result->status;
 
948
  return $return;
949
  }
950
 
@@ -955,27 +992,37 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
955
  public function updateSetupTimeToSubscription($postData) {
956
  try {
957
  $url = $this->apiDomain . '/customer-subscriptions/update-setup-time';
958
- $this->header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
959
  $data = [
960
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
961
  'setup_end_time' => date('Y-m-d H:i:s')
962
  ];
963
  $args = array(
964
- 'headers' =>$header,
965
- 'method' => 'POST',
966
- 'body' => $data
 
 
 
967
  );
968
- $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
 
 
 
 
 
 
 
969
  $return = new \stdClass();
970
- if($result->status == 200){
971
- $return->status = $result->status;
972
  $return->data = $result->data;
973
  $return->error = false;
974
  return $return;
975
  }else{
976
  $return->error = true;
977
- $return->data = $result->data;
978
- $return->status = $result->status;
 
979
  return $return;
980
  }
981
 
@@ -984,22 +1031,34 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
984
  }
985
  }
986
 
987
- public function getConversionList($data) {
988
  try {
 
 
 
 
 
989
  $url = $this->apiDomain . '/google-ads/conversion-list';
990
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
 
 
 
991
  $args = array(
992
  'headers' =>$header,
993
  'method' => 'POST',
994
- 'body' => $data
995
  );
996
- $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
 
 
 
 
997
  $return = new \stdClass();
998
- if($result->status == 200){
999
- $return->status = $result->status;
1000
- $return->data =$result->data;
1001
  $return->error = false;
1002
- if(isset($result->data) && count($result->data) > 0){
1003
  $return->message = esc_html__("Google Ads conversion tracking setting success.","conversios");
1004
  }else{
1005
  $response = $this->createConversion($data);
@@ -1015,8 +1074,9 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
1015
  return $return;
1016
  }else{
1017
  $return->error = true;
1018
- $return->data = $result->data;
1019
- $return->status = $result->status;
 
1020
  return $return;
1021
  }
1022
  } catch (Exception $e) {
@@ -1027,7 +1087,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
1027
  public function createConversion($postData) {
1028
  try {
1029
  $url = $this->apiDomain . '/google-ads/create-conversion';
1030
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
1031
  $data = [
1032
  'customer_id' => sanitize_text_field((isset($postData['customer_id']))?$postData['customer_id'] : ''),
1033
  'name' => "Order Conversion"
@@ -1035,7 +1095,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
1035
  $args = array(
1036
  'headers' =>$header,
1037
  'method' => 'POST',
1038
- 'body' => $data
1039
  );
1040
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
1041
  $return = new \stdClass();
@@ -1072,8 +1132,8 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
1072
  $data = [
1073
  "grant_type" => 'refresh_token',
1074
  "client_id" => sanitize_text_field($clientId),
1075
- 'client_secret' => $clientSecret,
1076
- 'refresh_token' => $refresh_token,
1077
  ];
1078
  $args = array(
1079
  'headers' =>$header,
62
  public function get_analytics_web_properties(){
63
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
64
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
65
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
66
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
67
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
68
  echo json_encode($api_obj->getAnalyticsWebProperties($_POST));
69
  wp_die();
79
  public function save_analytics_data(){
80
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
81
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
82
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
83
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
84
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
85
  /*sendingblue*/
86
  $data = array();
105
  public function list_googl_ads_account(){
106
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
107
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
108
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
109
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
110
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
111
  echo json_encode($api_obj->getGoogleAdsAccountList($_POST));
112
  wp_die();
121
  public function create_google_ads_account(){
122
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
123
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
124
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
125
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
126
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
127
  echo json_encode($api_obj->createGoogleAdsAccount($_POST));
128
  wp_die();
138
  public function save_google_ads_data(){
139
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
140
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
141
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
142
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
143
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
144
  /*sendingblue*/
145
  $data = array();
164
  public function link_analytic_to_ads_account(){
165
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
166
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
167
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
168
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
169
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
170
  echo json_encode($api_obj->linkAnalyticToAdsAccount($_POST));
171
  wp_die();
181
  public function list_google_merchant_account(){
182
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
183
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
184
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
185
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
186
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
187
  echo json_encode($api_obj->listMerchantCenterAccount($_POST));
188
  wp_die();
197
  public function create_google_merchant_center_account(){
198
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
199
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
200
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
201
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
202
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
203
  echo json_encode($api_obj->createMerchantAccount($_POST));
204
  wp_die();
214
  public function save_merchant_data(){
215
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
216
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
217
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
218
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
219
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
220
  /*sendingblue*/
221
  $data = array();
239
  public function get_conversion_list(){
240
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
241
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
242
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
243
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
244
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
245
  unset($_POST['tvc_data']);
246
  unset($_POST['conversios_onboarding_nonce']);
258
  public function link_google_ads_to_merchant_center(){
259
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
260
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
261
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
262
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
263
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
264
  echo json_encode($api_obj->linkGoogleAdsToMerchantCenter($_POST));
265
  wp_die();
274
  public function get_subscription_details(){
275
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
276
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
277
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
278
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
279
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
280
+ echo json_encode($api_obj->getSubscriptionDetails($tvc_data, sanitize_text_field($_POST['subscription_id']) ));
281
  wp_die();
282
  }else{
283
  echo esc_html__("Admin security nonce is not verified.","conversios");
291
  public function update_setup_time_to_subscription(){
292
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
293
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
294
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
295
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
296
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
297
  $return_url = $this->save_wp_setting_from_subscription_api($api_obj, $tvc_data, sanitize_text_field($_POST['subscription_id']) );
298
  $return_rs = $api_obj->updateSetupTimeToSubscription($_POST);
354
  $settings['ga_PrivacyPolicy'] = 'on';
355
  $settings['google-analytic'] = '';
356
  //update option in wordpress local database
357
+ update_option('google_ads_conversion_tracking', $googleDetail->google_ads_conversion_tracking);
358
+ update_option('ads_tracking_id', $googleDetail->google_ads_id);
359
+ update_option('ads_ert', $googleDetail->remarketing_tags);
360
+ update_option('ads_edrt', $googleDetail->dynamic_remarketing_tags);
361
 
362
  $TVC_Admin_Helper->save_ee_options_settings($settings);
363
  /*
373
  * save gmail and view ID in WP DB
374
  */
375
  if(property_exists($tvc_data,"g_mail") && sanitize_email($tvc_data->g_mail)){
376
+ update_option('ee_customer_gmail', $tvc_data->g_mail);
 
 
 
377
  }
378
  $return_url = "admin.php?page=conversios-google-shopping-feed&tab=gaa_config_page";
379
  if(isset($googleDetail->google_merchant_center_id) || isset($googleDetail->google_ads_id) ){
537
  $tvc_data = (object)$tvc_data;
538
  $access_token = sanitize_text_field(base64_decode($this->access_token));
539
  $url = $this->apiDomain . '/customer-subscriptions/subscription-detail';
540
+ $header = array("Authorization: Bearer MTIzNA==", "Content-Type" => "application/json", "AccessToken: $access_token");
541
  $data = [
542
  'subscription_id' => sanitize_text_field($subscription_id),//$this->subscription_id,
543
  'domain' => sanitize_text_field($tvc_data->user_domain)
545
  $args = array(
546
  'headers' =>$header,
547
  'method' => 'POST',
548
+ 'body' => wp_json_encode($data)
549
  );
550
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
551
 
626
  'Content-Type' => 'application/json',
627
  'RefreshToken' => $refresh_token
628
  ),
629
+ 'body' => ""
630
  );
631
  $request = wp_remote_post(esc_url_raw($url), $args);
632
 
658
  public function listMerchantCenterAccount() {
659
  try {
660
  $url = $this->apiDomain . '/gmc/user-merchant-center/list';
661
+ $header = array("Authorization: Bearer MTIzNA==", "Content-Type" => "application/json");
662
  $data = [
663
  'access_token' => sanitize_text_field(base64_decode($this->access_token)),
664
  ];
665
  $args = array(
666
  'headers' =>$header,
667
  'method' => 'POST',
668
+ 'body' => wp_json_encode($data)
669
  );
670
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
671
  $return = new \stdClass();
687
 
688
  public function createGoogleAdsAccount($postData) {
689
  try {
690
+ //$tvc_data = (object)$postData['tvc_data'];
691
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
692
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
693
  $url = $this->apiDomain . '/adwords/create-ads-account';
694
+ $header = array("Authorization: Bearer MTIzNA==", "Content-Type" => "application/json");
695
  $data = [
696
  'email' => sanitize_email($tvc_data->g_mail),
697
  'currency' => sanitize_text_field($tvc_data->currency_code),
698
  'time_zone' => sanitize_text_field($tvc_data->timezone_string), //'Asia/Kolkata',
699
  'domain' => sanitize_text_field($tvc_data->user_domain)
700
  ];
701
+ //print_r( $data );
702
  $args = array(
703
  'headers' =>$header,
704
  'method' => 'POST',
705
+ 'body' => wp_json_encode($data)
706
  );
707
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
708
+ //print_r($result);
709
  $return = new \stdClass();
710
  if($result->status == 200){
711
  $return->status = $result->status;
714
  return $return;
715
  }else{
716
  $return->error = true;
717
+ $return->error = $result->errors;
718
+ //$return->data = $result->data;
719
  $return->status = $result->status;
720
  return $return;
721
  }
726
  public function createMerchantAccount($postData) {
727
  try {
728
  $url = $this->apiDomain . '/gmc/create';
729
+ $header = array(
730
+ "Authorization: Bearer MTIzNA==",
731
+ "Content-Type" => "application/json"
732
+ );
733
  $data = [
734
+ 'merchant_id' => sanitize_text_field($this->merchantId), //'256922349',
735
  'name' => sanitize_text_field($postData['store_name']),
736
  'website_url' => esc_url_raw(sanitize_text_field($postData['website_url'])),
737
  'customer_id' => sanitize_text_field($postData['customer_id']),
752
  $args = array(
753
  'headers' =>$header,
754
  'method' => 'POST',
755
+ 'body' => wp_json_encode($data)
 
 
 
 
 
756
  );
757
  $args['timeout']= "1000";
758
  $request = wp_remote_post(esc_url_raw($url), $args);
779
  public function saveAnalyticsData($postData = array()) {
780
  try {
781
  $url = $this->apiDomain . '/customer-subscriptions/update-detail';
782
+ $header = array("Authorization: Bearer MTIzNA==", "Content-Type" => "application/json");
783
  $data = array(
784
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
785
  'tracking_option' => sanitize_text_field((isset($postData['tracking_option']))?$postData['tracking_option'] : ''),
797
  $args = array(
798
  'headers' =>$header,
799
  'method' => 'POST',
800
+ 'body' => wp_json_encode($data)
801
  );
802
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
803
  $return = new \stdClass();
820
  public function saveGoogleAdsData($postData = array()){
821
  try {
822
  $url = $this->apiDomain . '/customer-subscriptions/update-detail';
823
+ $header = array("Authorization: Bearer MTIzNA==", "Content-Type" => "application/json");
824
  $data = [
825
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
826
  'google_ads_id' => sanitize_text_field((isset($postData['google_ads_id']))? $postData['google_ads_id'] : ''),
832
  $args = array(
833
  'headers' =>$header,
834
  'method' => 'POST',
835
+ 'body' => wp_json_encode($data)
836
  );
837
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
838
  $return = new \stdClass();
855
  public function saveMechantData($postData = array()) {
856
  try {
857
  $url = $this->apiDomain . '/customer-subscriptions/update-detail';
858
+ $header = array("Authorization: Bearer MTIzNA==", "Content-Type" => "application/json");
859
  $data = [
860
  'merchant_id' => sanitize_text_field(($postData['merchant_id'] == 'NewMerchant') ? $this->merchantId: $postData['merchant_id']),
861
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
866
  $args = array(
867
  'headers' =>$header,
868
  'method' => 'POST',
869
+ 'body' => wp_json_encode($data)
870
  );
871
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
872
  $return = new \stdClass();
891
  $url = $this->apiDomain . '/google-analytics/link-ads-to-analytics';
892
  $access_token = sanitize_text_field(base64_decode($this->access_token));
893
  $refresh_token = sanitize_text_field(base64_decode($this->refresh_token));
 
894
  if ($postData['type'] == "UA") {
895
  $data = [
896
  'type' => sanitize_text_field($postData['type']),
909
  'web_property' => sanitize_text_field($postData['web_property']),
910
  ];
911
  }
912
+
913
  $args = array(
914
+ 'timeout' => 10000,
915
+ 'headers' => array(
916
+ 'Authorization' => "Bearer $this->token",
917
+ 'Content-Type' => 'application/json',
918
+ 'AccessToken' => $access_token,
919
+ 'RefreshToken' => $refresh_token
920
+ ),
921
  'method' => 'POST',
922
+ 'body' => wp_json_encode($data)
923
  );
924
+ $request = wp_remote_post(esc_url_raw($url), $args);
925
+
926
+ // Retrieve information
927
+ $response_code = wp_remote_retrieve_response_code($request);
928
+ $response_message = wp_remote_retrieve_response_message($request);
929
+ $result = json_decode(wp_remote_retrieve_body($request));
930
+ //print_r($result);
931
  $return = new \stdClass();
932
+ if($response_code == 200 && isset($result->error) && $result->error == ''){
933
+ $return->status = $response_code;
934
  $return->data = $result->data;
935
  $return->error = false;
936
  return $return;
937
  }else{
938
  $return->error = true;
939
+ $return->errors = $result->errors;
940
+ //$return->data = $result->data;
941
+ $return->status = $response_code;
942
  return $return;
943
  }
944
  } catch (Exception $e) {
949
  try {
950
  $url = $this->apiDomain . '/adwords/link-ads-to-merchant-center';
951
  $access_token = sanitize_text_field(base64_decode($this->access_token));
 
952
  $data = [
953
  'merchant_id' => sanitize_text_field(($postData['merchant_id']) == 'NewMerchant' ? $this->merchantId: $postData['merchant_id']),
954
  'account_id' => sanitize_text_field($postData['account_id']),
955
  'adwords_id' => sanitize_text_field($postData['adwords_id'])
956
  ];
957
  $args = array(
958
+ 'headers' => array(
959
+ 'Authorization' => "Bearer $this->token",
960
+ 'Content-Type' => 'application/json',
961
+ 'AccessToken' => $access_token
962
+ ),
963
+ 'method' => 'POST',
964
+ 'body' => wp_json_encode($data)
965
  );
966
+
967
+ // Send remote request
968
+ $request = wp_remote_post(esc_url_raw($url), $args);
969
+
970
+ // Retrieve information
971
+ $response_code = wp_remote_retrieve_response_code($request);
972
+ $response_message = wp_remote_retrieve_response_message($request);
973
+ $result = json_decode(wp_remote_retrieve_body($request));
974
  $return = new \stdClass();
975
+ if($response_code == 200){
976
+ $return->status = $response_code;
977
  $return->data = $result->data;
978
  $return->error = false;
979
  return $return;
980
  }else{
981
  $return->error = true;
982
+ $return->errors = $result->errors;
983
+ //$return->data = $result->data;
984
+ $return->status = $response_code;
985
  return $return;
986
  }
987
 
992
  public function updateSetupTimeToSubscription($postData) {
993
  try {
994
  $url = $this->apiDomain . '/customer-subscriptions/update-setup-time';
 
995
  $data = [
996
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
997
  'setup_end_time' => date('Y-m-d H:i:s')
998
  ];
999
  $args = array(
1000
+ 'headers' => array(
1001
+ 'Authorization' => "Bearer $this->token",
1002
+ 'Content-Type' => 'application/json'
1003
+ ),
1004
+ 'method' => 'POST',
1005
+ 'body' => wp_json_encode($data)
1006
  );
1007
+
1008
+ // Send remote request
1009
+ $request = wp_remote_post(esc_url_raw($url), $args);
1010
+
1011
+ // Retrieve information
1012
+ $response_code = wp_remote_retrieve_response_code($request);
1013
+ $response_message = wp_remote_retrieve_response_message($request);
1014
+ $result = json_decode(wp_remote_retrieve_body($request));
1015
  $return = new \stdClass();
1016
+ if($response_code == 200){
1017
+ $return->status = $response_code;
1018
  $return->data = $result->data;
1019
  $return->error = false;
1020
  return $return;
1021
  }else{
1022
  $return->error = true;
1023
+ $return->errors = $result->errors;
1024
+ //$return->data = $result->data;
1025
+ $return->status = $response_code;
1026
  return $return;
1027
  }
1028
 
1031
  }
1032
  }
1033
 
1034
+ public function getConversionList($postData) {
1035
  try {
1036
+ if(!empty($postData)){
1037
+ foreach ($postData as $key => $value) {
1038
+ $postData[$key] = sanitize_text_field($value);
1039
+ }
1040
+ }
1041
  $url = $this->apiDomain . '/google-ads/conversion-list';
1042
+ $header = array(
1043
+ "Authorization: Bearer MTIzNA==",
1044
+ "Content-Type" => "application/json"
1045
+ );
1046
  $args = array(
1047
  'headers' =>$header,
1048
  'method' => 'POST',
1049
+ 'body' => wp_json_encode($postData)
1050
  );
1051
+ $request = wp_remote_post(esc_url_raw($url), $args);
1052
+ $response_code = wp_remote_retrieve_response_code($request);
1053
+ $response_message = wp_remote_retrieve_response_message($request);
1054
+ $response = json_decode(wp_remote_retrieve_body($request));
1055
+
1056
  $return = new \stdClass();
1057
+ if ((isset($response->error) && $response->error == '')) {
1058
+ $return->status = $response_code;
1059
+ $return->data =$response->data;
1060
  $return->error = false;
1061
+ if(isset($response->data) && count($response->data) > 0){
1062
  $return->message = esc_html__("Google Ads conversion tracking setting success.","conversios");
1063
  }else{
1064
  $response = $this->createConversion($data);
1074
  return $return;
1075
  }else{
1076
  $return->error = true;
1077
+ $return->errors = $response->errors[0];
1078
+ //$return->data = $result->data;
1079
+ $return->status = $response_code;
1080
  return $return;
1081
  }
1082
  } catch (Exception $e) {
1087
  public function createConversion($postData) {
1088
  try {
1089
  $url = $this->apiDomain . '/google-ads/create-conversion';
1090
+ $header = array("Authorization: Bearer MTIzNA==", "Content-Type" => "application/json");
1091
  $data = [
1092
  'customer_id' => sanitize_text_field((isset($postData['customer_id']))?$postData['customer_id'] : ''),
1093
  'name' => "Order Conversion"
1095
  $args = array(
1096
  'headers' =>$header,
1097
  'method' => 'POST',
1098
+ 'body' => wp_json_encode($data)
1099
  );
1100
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
1101
  $return = new \stdClass();
1132
  $data = [
1133
  "grant_type" => 'refresh_token',
1134
  "client_id" => sanitize_text_field($clientId),
1135
+ 'client_secret' => sanitize_text_field($clientSecret),
1136
+ 'refresh_token' => sanitize_text_field($refresh_token),
1137
  ];
1138
  $args = array(
1139
  'headers' =>$header,
admin/js/onboarding-custom.js CHANGED
@@ -104,18 +104,18 @@ $(document).ready(function () {
104
  var text = $(this).html();
105
  let tracking_option = $('input:radio[name=analytic_tag_type]:checked').val();
106
 
107
- if(tracking_option == "UA" || tracking_option == "BOTH"){
108
  var profileid = $(this).attr("data-profileid");
109
  profileid = (profileid == undefined)?"":profileid;
110
  accountid = (accountid == undefined)?"":accountid;
111
- console.log(accountid+"="+profileid);
112
 
113
  $("#"+option_id+"_val").html(text);
114
  $("#"+option_id+"_val").attr("data-accountid",accountid);
115
  $("#"+option_id+"_val").attr("data-profileid",profileid);
116
  $("#"+option_id+"_val").attr("data-val",val);
117
 
118
- }else if(tracking_option == "GA4" || tracking_option == "BOTH"){
119
  var name = $(this).attr("data-name");
120
  name = (name == undefined)?"":name;
121
  accountid = (accountid == undefined)?"":accountid;
@@ -315,6 +315,7 @@ function save_google_ads_data(google_ads_id, tvc_data, subscription_id, is_skip=
315
  beforeSend: function () {
316
  },
317
  success: function (response) {
 
318
  if(response.error === false) {
319
  add_message("success","Google Ads successfully updated.");
320
  //$("#ads-account").val(google_ads_id);
@@ -323,7 +324,7 @@ function save_google_ads_data(google_ads_id, tvc_data, subscription_id, is_skip=
323
  if(plan_id != 1){
324
  check_oradd_conversion_list(google_ads_id, tvc_data);
325
  }
326
- //console.log("s_tracking_option"+s_tracking_option);
327
  if ($("#link_google_analytics_with_google_ads").is(':checked')) {
328
  if(tracking_option == "UA" || tracking_option == "BOTH"){
329
  if(tracking_option == "BOTH"){
@@ -340,6 +341,7 @@ function save_google_ads_data(google_ads_id, tvc_data, subscription_id, is_skip=
340
  tvc_data:tvc_data,
341
  conversios_onboarding_nonce:conversios_onboarding_nonce
342
  };
 
343
  //console.log(UalinkData);
344
  if(google_ads_id != "" && profile_id != undefined){
345
  setTimeout(function(){
@@ -444,9 +446,9 @@ function save_merchant_data(google_merchant_center_id, merchant_id, tvc_data, su
444
  }
445
 
446
  /* get conversion list */
447
- function check_oradd_conversion_list(google_ads_id, google_merchant_center_id, tvc_data){
448
  var conversios_onboarding_nonce = $("#conversios_onboarding_nonce").val();
449
- if(google_ads_id && google_merchant_center_id){
450
  var data = {
451
  action: "get_conversion_list",
452
  customer_id:google_ads_id,
@@ -490,8 +492,8 @@ function link_analytic_to_ads_account(data) {
490
  if(response.error === false){
491
  add_message("success","Google ananlytics and google ads linked successfully.");
492
  }else{
493
- const errors = JSON.parse(response.errors[0]);
494
- add_message("error",errors.message);
495
  }
496
  }
497
  });
@@ -605,12 +607,14 @@ function list_analytics_web_properties(type, tvc_data, page =1) {
605
  data: {action: "get_analytics_web_properties", type: type, page:page, tvc_data:tvc_data, conversios_onboarding_nonce:conversios_onboarding_nonce},
606
  success: function (response) {
607
  //console.log(response);
 
608
  if (response != null && response.error == false) {
609
  if (type == "UA" || type == "BOTH") {
610
  //web_properties_dropdown
611
  var subscriptionPropertyId = $("#subscriptionPropertyId").val();
612
  var ga_view_id = $("#ga_view_id").val();
613
  var PropOptions = '';
 
614
  //console.log("call option");
615
  //console.log(Object.keys(response.data.wep_properties).length +"=="+response.data.wep_properties.length);
616
  if(response.data != null && response.data.wep_properties.length > 0){
@@ -622,7 +626,10 @@ function list_analytics_web_properties(type, tvc_data, page =1) {
622
  }else if(ga_view_id =="" ){
623
  selected = "selected='selected'";
624
  }
625
-
 
 
 
626
  }else{
627
  selected = "";
628
  }
@@ -641,12 +648,16 @@ function list_analytics_web_properties(type, tvc_data, page =1) {
641
  var MeasOptions = '';
642
  if(response.data != null && response.data.wep_measurement.length > 0){
643
  $.each(response.data.wep_measurement, function (measKey, measValue) {
 
644
  if (subscriptionMeasurementId == measValue.measurementId) {
645
  var selected = "selected='selected'";
 
 
 
 
646
  } else {
647
  var selected = "";
648
- }
649
- var web_property = measValue.name.split("/");
650
  MeasOptions = MeasOptions + '<option value="' + measValue.measurementId + '" ' + selected + ' data-name="'+web_property[1] +'"'+ ' data-accountid="' + measValue.accountId + '"> ' + measValue.accountName + ' - ' + web_property[1] + ' - ' + measValue.measurementId + '</option>';
651
  });
652
  }else{
104
  var text = $(this).html();
105
  let tracking_option = $('input:radio[name=analytic_tag_type]:checked').val();
106
 
107
+ if(tracking_option == "UA" || (tracking_option == "BOTH" && option_id == "both_ua_web_property_id_option")){
108
  var profileid = $(this).attr("data-profileid");
109
  profileid = (profileid == undefined)?"":profileid;
110
  accountid = (accountid == undefined)?"":accountid;
111
+ //console.log(accountid+"="+profileid);
112
 
113
  $("#"+option_id+"_val").html(text);
114
  $("#"+option_id+"_val").attr("data-accountid",accountid);
115
  $("#"+option_id+"_val").attr("data-profileid",profileid);
116
  $("#"+option_id+"_val").attr("data-val",val);
117
 
118
+ }else if(tracking_option == "GA4" || (tracking_option == "BOTH" && option_id == "both_ga4_web_measurement_id_option") ){
119
  var name = $(this).attr("data-name");
120
  name = (name == undefined)?"":name;
121
  accountid = (accountid == undefined)?"":accountid;
315
  beforeSend: function () {
316
  },
317
  success: function (response) {
318
+ //console.log(response);
319
  if(response.error === false) {
320
  add_message("success","Google Ads successfully updated.");
321
  //$("#ads-account").val(google_ads_id);
324
  if(plan_id != 1){
325
  check_oradd_conversion_list(google_ads_id, tvc_data);
326
  }
327
+
328
  if ($("#link_google_analytics_with_google_ads").is(':checked')) {
329
  if(tracking_option == "UA" || tracking_option == "BOTH"){
330
  if(tracking_option == "BOTH"){
341
  tvc_data:tvc_data,
342
  conversios_onboarding_nonce:conversios_onboarding_nonce
343
  };
344
+ //console.log("google_ads_id"+google_ads_id+"profile_id"+profile_id);
345
  //console.log(UalinkData);
346
  if(google_ads_id != "" && profile_id != undefined){
347
  setTimeout(function(){
446
  }
447
 
448
  /* get conversion list */
449
+ function check_oradd_conversion_list(google_ads_id, tvc_data){
450
  var conversios_onboarding_nonce = $("#conversios_onboarding_nonce").val();
451
+ if(google_ads_id ){
452
  var data = {
453
  action: "get_conversion_list",
454
  customer_id:google_ads_id,
492
  if(response.error === false){
493
  add_message("success","Google ananlytics and google ads linked successfully.");
494
  }else{
495
+ const errors = JSON.parse(response?.errors[0]);
496
+ add_message("error",errors?.message);
497
  }
498
  }
499
  });
607
  data: {action: "get_analytics_web_properties", type: type, page:page, tvc_data:tvc_data, conversios_onboarding_nonce:conversios_onboarding_nonce},
608
  success: function (response) {
609
  //console.log(response);
610
+ var s_tracking_option = type.toLowerCase()
611
  if (response != null && response.error == false) {
612
  if (type == "UA" || type == "BOTH") {
613
  //web_properties_dropdown
614
  var subscriptionPropertyId = $("#subscriptionPropertyId").val();
615
  var ga_view_id = $("#ga_view_id").val();
616
  var PropOptions = '';
617
+
618
  //console.log("call option");
619
  //console.log(Object.keys(response.data.wep_properties).length +"=="+response.data.wep_properties.length);
620
  if(response.data != null && response.data.wep_properties.length > 0){
626
  }else if(ga_view_id =="" ){
627
  selected = "selected='selected'";
628
  }
629
+ if(type == "BOTH"){
630
+ s_tracking_option = "both_ua";
631
+ }
632
+ $("#"+s_tracking_option+"_web_property_id_option_val").attr("data-profileid",propValue.id);
633
  }else{
634
  selected = "";
635
  }
648
  var MeasOptions = '';
649
  if(response.data != null && response.data.wep_measurement.length > 0){
650
  $.each(response.data.wep_measurement, function (measKey, measValue) {
651
+ var web_property = measValue.name.split("/");
652
  if (subscriptionMeasurementId == measValue.measurementId) {
653
  var selected = "selected='selected'";
654
+ if(type == "BOTH"){
655
+ s_tracking_option = "both_ga4";
656
+ }
657
+ $("#"+s_tracking_option+"_web_measurement_id_option_val").attr('data-name',web_property[1]);
658
  } else {
659
  var selected = "";
660
+ }
 
661
  MeasOptions = MeasOptions + '<option value="' + measValue.measurementId + '" ' + selected + ' data-name="'+web_property[1] +'"'+ ' data-accountid="' + measValue.accountId + '"> ' + measValue.accountName + ' - ' + web_property[1] + ' - ' + measValue.measurementId + '</option>';
662
  });
663
  }else{
admin/partials/general-fields.php CHANGED
@@ -36,10 +36,10 @@ if (isset($_GET['connect']) && isset($_GET['subscription_id'])) {
36
  }
37
  //'website_url' => $googleDetail->site_url,
38
  $postData = [
39
- 'merchant_id' => esc_attr($googleDetail->merchant_id),
40
  'website_url' => get_site_url(),
41
- 'subscription_id' => esc_attr($googleDetail->id),
42
- 'account_id' => esc_attr($googleDetail->google_merchant_center_id)
43
  ];
44
 
45
  if ($googleDetail->is_site_verified == '0') {
@@ -102,10 +102,10 @@ if (isset($_GET['connect']) && isset($_GET['subscription_id'])) {
102
  $settings['ga_PrivacyPolicy'] = 'on';
103
  $settings['google-analytic'] = '';
104
  //update option in wordpress local database
105
- update_option('google_ads_conversion_tracking', sanitize_option('google_ads_conversion_tracking',$googleDetail->google_ads_conversion_tracking) );
106
- update_option('ads_tracking_id', sanitize_option('ads_tracking_id', $googleDetail->google_ads_id));
107
- update_option('ads_ert', sanitize_option( 'ads_ert', $googleDetail->remarketing_tags));
108
- update_option('ads_edrt', sanitize_option('ads_edrt', $googleDetail->dynamic_remarketing_tags));
109
  $TVC_Admin_Helper->save_ee_options_settings($settings);
110
 
111
  /*
@@ -146,7 +146,7 @@ if (isset($_POST['ee_submit_plugin'])) {
146
  if(!empty(sanitize_text_field($_POST['gm_id'])) && !empty(sanitize_text_field($_POST['ga_id']))){
147
  $settings['tracking_option'] = "BOTH";
148
  }
149
- update_option('ads_tracking_id', sanitize_option('ads_tracking_id', $_POST['google_ads_id']));
150
 
151
  $settings['ga_eeT'] = isset($_POST["ga_eeT"])?sanitize_text_field($_POST["ga_eeT"]):"";
152
 
@@ -233,7 +233,7 @@ if(isset($google_detail['setting'])){
233
  <div class="col-6 col-md-6 col-lg-6 text-right">
234
  <div class="acc-num">
235
  <p class="ga-text">
236
- <?php echo (isset($data['gm_id']) && $data['gm_id'] != '') ? $data['gm_id'] : '<span>'.esc_html__("Get started","conversios").'</span>'; ?>
237
  </p>
238
  <?php
239
  if (isset($data['gm_id']) && esc_attr($data['gm_id']) != '') {
@@ -251,7 +251,7 @@ if(isset($google_detail['setting'])){
251
  <div class="col-6 col-md-6 col-lg-6 text-right">
252
  <div class="acc-num">
253
  <p class="ga-text">
254
- <?php echo (isset($data['google_ads_id']) && $data['google_ads_id'] != '') ? $data['google_ads_id'] : '<span>'.esc_html__("Get started","conversios").'</span>'; ?>
255
  </p>
256
  <?php
257
  if (isset($data['google_ads_id']) && esc_attr($data['google_ads_id']) != '') {
@@ -269,7 +269,7 @@ if(isset($google_detail['setting'])){
269
  <div class="col-6 col-md-6 col-lg-6 text-right">
270
  <div class="acc-num">
271
  <p class="ga-text">
272
- <?php echo (isset($data['google_merchant_id']) && $data['google_merchant_id'] != '') ? $data['google_merchant_id'] : '<span>'.esc_html__("Get started","conversios").'</span>'; ?>
273
  </p>
274
  <?php
275
  if (isset($data['google_merchant_id']) && esc_attr($data['google_merchant_id']) != '') {
36
  }
37
  //'website_url' => $googleDetail->site_url,
38
  $postData = [
39
+ 'merchant_id' => sanitize_text_field($googleDetail->merchant_id),
40
  'website_url' => get_site_url(),
41
+ 'subscription_id' => sanitize_text_field($googleDetail->id),
42
+ 'account_id' => sanitize_text_field($googleDetail->google_merchant_center_id)
43
  ];
44
 
45
  if ($googleDetail->is_site_verified == '0') {
102
  $settings['ga_PrivacyPolicy'] = 'on';
103
  $settings['google-analytic'] = '';
104
  //update option in wordpress local database
105
+ update_option('google_ads_conversion_tracking', $googleDetail->google_ads_conversion_tracking);
106
+ update_option('ads_tracking_id', $googleDetail->google_ads_id);
107
+ update_option('ads_ert', $googleDetail->remarketing_tags);
108
+ update_option('ads_edrt', $googleDetail->dynamic_remarketing_tags);
109
  $TVC_Admin_Helper->save_ee_options_settings($settings);
110
 
111
  /*
146
  if(!empty(sanitize_text_field($_POST['gm_id'])) && !empty(sanitize_text_field($_POST['ga_id']))){
147
  $settings['tracking_option'] = "BOTH";
148
  }
149
+ update_option('ads_tracking_id', sanitize_text_field($_POST['google_ads_id']));
150
 
151
  $settings['ga_eeT'] = isset($_POST["ga_eeT"])?sanitize_text_field($_POST["ga_eeT"]):"";
152
 
233
  <div class="col-6 col-md-6 col-lg-6 text-right">
234
  <div class="acc-num">
235
  <p class="ga-text">
236
+ <?php echo (isset($data['gm_id']) && $data['gm_id'] != '') ? esc_attr($data['gm_id']) : '<span>'.esc_html__("Get started","conversios").'</span>'; ?>
237
  </p>
238
  <?php
239
  if (isset($data['gm_id']) && esc_attr($data['gm_id']) != '') {
251
  <div class="col-6 col-md-6 col-lg-6 text-right">
252
  <div class="acc-num">
253
  <p class="ga-text">
254
+ <?php echo (isset($data['google_ads_id']) && $data['google_ads_id'] != '') ? esc_attr($data['google_ads_id']) : '<span>'.esc_html__("Get started","conversios").'</span>'; ?>
255
  </p>
256
  <?php
257
  if (isset($data['google_ads_id']) && esc_attr($data['google_ads_id']) != '') {
269
  <div class="col-6 col-md-6 col-lg-6 text-right">
270
  <div class="acc-num">
271
  <p class="ga-text">
272
+ <?php echo (isset($data['google_merchant_id']) && $data['google_merchant_id'] != '') ? esc_attr($data['google_merchant_id']) : '<span>'.esc_html__("Get started","conversios").'</span>'; ?>
273
  </p>
274
  <?php
275
  if (isset($data['google_merchant_id']) && esc_attr($data['google_merchant_id']) != '') {
enhanced-ecommerce-google-analytics.php CHANGED
@@ -15,14 +15,14 @@
15
  * Plugin Name: Conversios.io - Google Analytics and Google Shopping plugin for WooCommerce
16
  * Plugin URI: https://www.tatvic.com/tatvic-labs/woocommerce-extension/
17
  * Description: Automates eCommerce tracking in Google Analytics, dynamic remarkting in Google Ads, and provides complete Google Shopping features.
18
- * Version: 4.5.7
19
  * Author: Tatvic
20
  * Author URI: www.tatvic.com
21
  * License: GPL-2.0+
22
  * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
23
  * Text Domain: www.tatvic.com
24
  * Domain Path: /languages
25
- * WC requires at least: 3.0.0
26
  * WC tested up to: 6.0.0
27
  */
28
 
@@ -37,7 +37,7 @@ if ( ! defined( 'WPINC' ) ) {
37
  * Start at version 1.0.0 and use SemVer - https://semver.org
38
  * Rename this for your plugin and update it as you release new versions.
39
  */
40
- define( 'PLUGIN_TVC_VERSION', '4.5.7' );
41
  $fullName = plugin_basename( __FILE__ );
42
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
43
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
15
  * Plugin Name: Conversios.io - Google Analytics and Google Shopping plugin for WooCommerce
16
  * Plugin URI: https://www.tatvic.com/tatvic-labs/woocommerce-extension/
17
  * Description: Automates eCommerce tracking in Google Analytics, dynamic remarkting in Google Ads, and provides complete Google Shopping features.
18
+ * Version: 4.5.8
19
  * Author: Tatvic
20
  * Author URI: www.tatvic.com
21
  * License: GPL-2.0+
22
  * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
23
  * Text Domain: www.tatvic.com
24
  * Domain Path: /languages
25
+ * WC requires at least: 3.5.0
26
  * WC tested up to: 6.0.0
27
  */
28
 
37
  * Start at version 1.0.0 and use SemVer - https://semver.org
38
  * Rename this for your plugin and update it as you release new versions.
39
  */
40
+ define( 'PLUGIN_TVC_VERSION', '4.5.8' );
41
  $fullName = plugin_basename( __FILE__ );
42
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
43
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
includes/class-enhanced-ecommerce-google-analytics-activator.php CHANGED
@@ -32,7 +32,7 @@ class Enhanced_Ecommerce_Google_Analytics_Activator {
32
  */
33
  public static function activate() {
34
  if (!is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
35
- wp_die(wp_sprintf("%s <br><a href='" . esc_url(admin_url( 'plugins.php' )) . "'>&laquo; %s</a>",esc_html__("Hey, It seems WooCommerce plugin is not active on your wp-admin. Conversios.io - Google Analytics and Google Shopping plugin can only be activated if you have active WooCommerce plugin in your wp-admin.","conversios"), esc_html__("Return to Plugins","conversios")));
36
  }
37
  }
38
  }
32
  */
33
  public static function activate() {
34
  if (!is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
35
+ wp_die(wp_sprintf("%s <br><a href='" . esc_url_raw(admin_url( 'plugins.php' )) . "'>&laquo; %s</a>", esc_html__("Hey, It seems WooCommerce plugin is not active on your wp-admin. Conversios.io - Google Analytics and Google Shopping plugin can only be activated if you have active WooCommerce plugin in your wp-admin.","conversios"), esc_html__("Return to Plugins","conversios")));
36
  }
37
  }
38
  }
includes/data/class-tvc-ajax-file.php CHANGED
@@ -42,6 +42,7 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
42
 
43
  public function tvcajax_product_sync_bantch_wise(){
44
  global $wpdb;
 
45
  // barch size for inser data in DB
46
  $product_db_batch_size = 100;
47
  // barch size for inser product in GMC
@@ -77,9 +78,9 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
77
  $skip_products =isset($sync_progressive_data['skip_products'])?sanitize_text_field($sync_progressive_data['skip_products']):"0";
78
  $skip_products = sanitize_text_field($skip_products);
79
 
80
- $account_id = esc_attr(isset($_POST['account_id'])?sanitize_text_field($_POST['account_id']):"");
81
- $customer_id = esc_attr(isset($_POST['customer_id'])?sanitize_text_field($_POST['customer_id']):"");
82
- $subscription_id = esc_attr(isset($_POST['subscription_id'])?sanitize_text_field($_POST['subscription_id']):"");
83
  $data = isset($_POST['tvc_data'])?$_POST['tvc_data']:"";
84
  parse_str($data, $formArray);
85
  if(!empty($formArray)){
@@ -130,8 +131,8 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
130
  }else{
131
  $TVC_Admin_DB_Helper->tvc_update_row("ee_product_sync_profile",$profile_data,array("id"=>1));
132
  }
133
- update_option("ee_prod_mapped_cats", serialize(sanitize_option("ee_prod_mapped_cats",$mappedCatsDB)));
134
- update_option("ee_prod_mapped_attrs", serialize(sanitize_option("ee_prod_mapped_attrs",$mappedAttrs)));
135
 
136
  /*
137
  * start product add in DB
@@ -161,14 +162,7 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
161
  */
162
  if(!empty($all_products)){
163
  foreach($all_products as $postkey => $postvalue){
164
- $batch_count++;
165
- $t_data = array(
166
- 'w_product_id'=>$postvalue->ID,
167
- 'w_cat_id'=>$mc_key,
168
- 'g_cat_id'=>$mappedCat,
169
- 'product_sync_profile_id'=> 1,
170
- 'update_date'=>date('Y-m-d')
171
- );
172
  array_push( $values, esc_sql($postvalue->ID), esc_sql($mc_key), esc_sql($mappedCat), 1, date('Y-m-d') );
173
  $place_holders[] = "('%d', '%d', '%d','%d', '%s')";
174
  if($batch_count >= $product_db_batch_size){
@@ -212,8 +206,8 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
212
  $is_synced_up = ($total_product <= $sync_produt)?true:false;
213
  $sync_message = esc_html__("Initiated, products are being synced to Merchant Center.Do not refresh..","conversios");
214
  if($total_product <= $sync_produt){
215
- $customObj->setGmcCategoryMapping($catMapRequest);
216
- $customObj->setGmcAttributeMapping($attrMapRequest);
217
  $TVC_Admin_Auto_Product_sync_Helper = new TVC_Admin_Auto_Product_sync_Helper();
218
  $TVC_Admin_Auto_Product_sync_Helper->update_last_sync_in_db();
219
  $sync_message = esc_html__("Initiated, products are being synced to Merchant Center.Do not refresh..","conversios");
@@ -269,7 +263,6 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
269
  public function tvc_call_notification_dismiss(){
270
  if($this->safe_ajax_call(filter_input(INPUT_POST, 'TVCNonce'), 'tvc_call_notification_dismiss-nonce')){
271
  $ee_dismiss_id = isset($_POST['data']['ee_dismiss_id'])?sanitize_text_field($_POST['data']['ee_dismiss_id']):"";
272
- $ee_dismiss_id = sanitize_text_field($ee_dismiss_id);
273
  if($ee_dismiss_id != ""){
274
  $TVC_Admin_Helper = new TVC_Admin_Helper();
275
  $ee_msg_list = $TVC_Admin_Helper->get_ee_msg_nofification_list();
@@ -278,8 +271,7 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
278
  $ee_msg_list[$ee_dismiss_id]["active"]=0;
279
  $TVC_Admin_Helper->set_ee_msg_nofification_list($ee_msg_list);
280
  echo json_encode(array('status' => 'success', 'message' => ""));
281
- }
282
-
283
  }
284
  }
285
  exit;
@@ -366,15 +358,15 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
366
  // make sure this call is legal
367
  if($this->safe_ajax_call(filter_input(INPUT_POST, 'campaignDeleteNonce'), 'tvcajax-delete-campaign-nonce')){
368
 
369
- $merchantId = sanitize_text_field(filter_input(INPUT_POST, 'merchantId'));
370
- $customerId = sanitize_text_field(filter_input(INPUT_POST, 'customerId'));
371
- $campaignId = sanitize_text_field(filter_input(INPUT_POST, 'campaignId'));
372
 
373
  $url = $this->apiDomain.'/campaigns/delete';
374
  $data = [
375
- 'merchant_id' => $merchantId,
376
- 'customer_id' => $customerId,
377
- 'campaign_id' => $campaignId
378
  ];
379
  $args = array(
380
  'headers' => array(
@@ -416,50 +408,50 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
416
 
417
  $header = array(
418
  "Authorization: Bearer MTIzNA==",
419
- "content-type: application/json"
420
  );
421
 
422
- $merchantId = sanitize_text_field(filter_input(INPUT_POST, 'merchantId'));
423
- $customerId = sanitize_text_field(filter_input(INPUT_POST, 'customerId'));
424
- $campaignId = sanitize_text_field(filter_input(INPUT_POST, 'campaignId'));
425
- $budgetId = sanitize_text_field(filter_input(INPUT_POST, 'budgetId'));
426
- $campaignName = sanitize_text_field(filter_input(INPUT_POST, 'campaignName'));
427
- $budget = sanitize_text_field(filter_input(INPUT_POST, 'budget'));
428
- $status = sanitize_text_field(filter_input(INPUT_POST, 'status'));
429
  $curl_url = $this->apiDomain.'/campaigns/update';
430
  $shoppingObj = new ShoppingApi();
431
  $campaignData = $shoppingObj->getCampaignDetails($campaignId);
432
 
433
  $data = [
434
- 'merchant_id' => $merchantId,
435
- 'customer_id' => $customerId,
436
- 'campaign_id' => $campaignId,
437
- 'account_budget_id' => $budgetId,
438
- 'campaign_name' => $campaignName,
439
- 'budget' => $budget,
440
- 'status' => $status,
441
- 'target_country' => $campaignData->data['data']->targetCountry,
442
- 'ad_group_id' => $campaignData->data['data']->adGroupId,
443
- 'ad_group_resource_name' => $campaignData->data['data']->adGroupResourceName
444
  ];
445
 
446
  $args = array(
447
  'headers' =>$header,
448
  'method' => 'PATCH',
449
- 'body' => $data
450
  );
451
  $request = wp_remote_request(esc_url_raw($curl_url), $args);
452
  //print_r($request);
453
- // Retrieve information
454
- $response_code = wp_remote_retrieve_response_code($request);
455
- $response_message = wp_remote_retrieve_response_message($request);
456
- $response = json_decode(wp_remote_retrieve_body($request));
457
  if (isset($response->error) && $response->error == false) {
458
  $message = $response->message;
459
- echo json_encode(['status' => 'success', 'message' => $message]);
460
  }else{
461
  $message = is_array($response->errors) ? $response->errors[0] : esc_html__("Face some unprocessable entity","conversios");
462
- echo json_encode(['status' => 'error', 'message' => $message]);
463
  }
464
  }
465
  exit;
@@ -472,13 +464,13 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
472
  // make sure this call is legal
473
  if($this->safe_ajax_call(filter_input(INPUT_POST, 'campaignCategoryListsNonce'), 'tvcajax-campaign-category-lists-nonce')){
474
 
475
- $country_code = sanitize_text_field(filter_input(INPUT_POST, 'countryCode'));
476
- $customer_id = sanitize_text_field(filter_input(INPUT_POST, 'customerId'));
477
  $url = $this->apiDomain.'/products/categories';
478
 
479
  $data = [
480
- 'customer_id' => $customer_id,
481
- 'country_code' => $country_code
482
  ];
483
 
484
  $args = array(
@@ -525,15 +517,15 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
525
  // make sure this call is legal
526
  if($this->safe_ajax_call(filter_input(INPUT_POST, 'gmcCategoryListsNonce'), 'tvcajax-gmc-category-lists-nonce')){
527
 
528
- $country_code = sanitize_text_field(filter_input(INPUT_POST, 'countryCode'));
529
- $customer_id = sanitize_text_field(filter_input(INPUT_POST, 'customerId'));
530
- $parent = sanitize_text_field(filter_input(INPUT_POST, 'parent'));
531
  $url = $this->apiDomain.'/products/gmc-categories';
532
 
533
  $data = [
534
- 'customer_id' => $customer_id,
535
- 'country_code' => $country_code,
536
- 'parent' => $parent
537
  ];
538
 
539
  $args = array(
42
 
43
  public function tvcajax_product_sync_bantch_wise(){
44
  global $wpdb;
45
+ $rs = array();
46
  // barch size for inser data in DB
47
  $product_db_batch_size = 100;
48
  // barch size for inser product in GMC
78
  $skip_products =isset($sync_progressive_data['skip_products'])?sanitize_text_field($sync_progressive_data['skip_products']):"0";
79
  $skip_products = sanitize_text_field($skip_products);
80
 
81
+ $account_id = isset($_POST['account_id'])?sanitize_text_field($_POST['account_id']):"";
82
+ $customer_id = isset($_POST['customer_id'])?sanitize_text_field($_POST['customer_id']):"";
83
+ $subscription_id = isset($_POST['subscription_id'])?sanitize_text_field($_POST['subscription_id']):"";
84
  $data = isset($_POST['tvc_data'])?$_POST['tvc_data']:"";
85
  parse_str($data, $formArray);
86
  if(!empty($formArray)){
131
  }else{
132
  $TVC_Admin_DB_Helper->tvc_update_row("ee_product_sync_profile",$profile_data,array("id"=>1));
133
  }
134
+ update_option("ee_prod_mapped_cats", serialize($mappedCatsDB));
135
+ update_option("ee_prod_mapped_attrs", serialize($mappedAttrs));
136
 
137
  /*
138
  * start product add in DB
162
  */
163
  if(!empty($all_products)){
164
  foreach($all_products as $postkey => $postvalue){
165
+ $batch_count++;
 
 
 
 
 
 
 
166
  array_push( $values, esc_sql($postvalue->ID), esc_sql($mc_key), esc_sql($mappedCat), 1, date('Y-m-d') );
167
  $place_holders[] = "('%d', '%d', '%d','%d', '%s')";
168
  if($batch_count >= $product_db_batch_size){
206
  $is_synced_up = ($total_product <= $sync_produt)?true:false;
207
  $sync_message = esc_html__("Initiated, products are being synced to Merchant Center.Do not refresh..","conversios");
208
  if($total_product <= $sync_produt){
209
+ //$customObj->setGmcCategoryMapping($catMapRequest);
210
+ //$customObj->setGmcAttributeMapping($attrMapRequest);
211
  $TVC_Admin_Auto_Product_sync_Helper = new TVC_Admin_Auto_Product_sync_Helper();
212
  $TVC_Admin_Auto_Product_sync_Helper->update_last_sync_in_db();
213
  $sync_message = esc_html__("Initiated, products are being synced to Merchant Center.Do not refresh..","conversios");
263
  public function tvc_call_notification_dismiss(){
264
  if($this->safe_ajax_call(filter_input(INPUT_POST, 'TVCNonce'), 'tvc_call_notification_dismiss-nonce')){
265
  $ee_dismiss_id = isset($_POST['data']['ee_dismiss_id'])?sanitize_text_field($_POST['data']['ee_dismiss_id']):"";
 
266
  if($ee_dismiss_id != ""){
267
  $TVC_Admin_Helper = new TVC_Admin_Helper();
268
  $ee_msg_list = $TVC_Admin_Helper->get_ee_msg_nofification_list();
271
  $ee_msg_list[$ee_dismiss_id]["active"]=0;
272
  $TVC_Admin_Helper->set_ee_msg_nofification_list($ee_msg_list);
273
  echo json_encode(array('status' => 'success', 'message' => ""));
274
+ }
 
275
  }
276
  }
277
  exit;
358
  // make sure this call is legal
359
  if($this->safe_ajax_call(filter_input(INPUT_POST, 'campaignDeleteNonce'), 'tvcajax-delete-campaign-nonce')){
360
 
361
+ $merchantId = filter_input(INPUT_POST, 'merchantId');
362
+ $customerId = filter_input(INPUT_POST, 'customerId');
363
+ $campaignId = filter_input(INPUT_POST, 'campaignId');
364
 
365
  $url = $this->apiDomain.'/campaigns/delete';
366
  $data = [
367
+ 'merchant_id' => sanitize_text_field($merchantId),
368
+ 'customer_id' => sanitize_text_field($customerId),
369
+ 'campaign_id' => sanitize_text_field($campaignId)
370
  ];
371
  $args = array(
372
  'headers' => array(
408
 
409
  $header = array(
410
  "Authorization: Bearer MTIzNA==",
411
+ "Content-Type" => "application/json"
412
  );
413
 
414
+ $merchantId = filter_input(INPUT_POST, 'merchantId');
415
+ $customerId = filter_input(INPUT_POST, 'customerId');
416
+ $campaignId = filter_input(INPUT_POST, 'campaignId');
417
+ $budgetId = filter_input(INPUT_POST, 'budgetId');
418
+ $campaignName = filter_input(INPUT_POST, 'campaignName');
419
+ $budget = filter_input(INPUT_POST, 'budget');
420
+ $status = filter_input(INPUT_POST, 'status');
421
  $curl_url = $this->apiDomain.'/campaigns/update';
422
  $shoppingObj = new ShoppingApi();
423
  $campaignData = $shoppingObj->getCampaignDetails($campaignId);
424
 
425
  $data = [
426
+ 'merchant_id' => sanitize_text_field($merchantId),
427
+ 'customer_id' => sanitize_text_field($customerId),
428
+ 'campaign_id' => sanitize_text_field($campaignId),
429
+ 'account_budget_id' => sanitize_text_field($budgetId),
430
+ 'campaign_name' => sanitize_text_field($campaignName),
431
+ 'budget' => sanitize_text_field($budget),
432
+ 'status' => sanitize_text_field($status),
433
+ 'target_country' => sanitize_text_field($campaignData->data['data']->targetCountry),
434
+ 'ad_group_id' => sanitize_text_field($campaignData->data['data']->adGroupId),
435
+ 'ad_group_resource_name' => sanitize_text_field($campaignData->data['data']->adGroupResourceName)
436
  ];
437
 
438
  $args = array(
439
  'headers' =>$header,
440
  'method' => 'PATCH',
441
+ 'body' => wp_json_encode($data)
442
  );
443
  $request = wp_remote_request(esc_url_raw($curl_url), $args);
444
  //print_r($request);
445
+ // Retrieve information
446
+ $response_code = wp_remote_retrieve_response_code($request);
447
+ $response_message = wp_remote_retrieve_response_message($request);
448
+ $response = json_decode(wp_remote_retrieve_body($request));
449
  if (isset($response->error) && $response->error == false) {
450
  $message = $response->message;
451
+ echo json_encode(['status' => 'success', 'message' => $message]);
452
  }else{
453
  $message = is_array($response->errors) ? $response->errors[0] : esc_html__("Face some unprocessable entity","conversios");
454
+ echo json_encode(['status' => 'error', 'message' => $message]);
455
  }
456
  }
457
  exit;
464
  // make sure this call is legal
465
  if($this->safe_ajax_call(filter_input(INPUT_POST, 'campaignCategoryListsNonce'), 'tvcajax-campaign-category-lists-nonce')){
466
 
467
+ $country_code = filter_input(INPUT_POST, 'countryCode');
468
+ $customer_id = filter_input(INPUT_POST, 'customerId');
469
  $url = $this->apiDomain.'/products/categories';
470
 
471
  $data = [
472
+ 'customer_id' => sanitize_text_field($customer_id),
473
+ 'country_code' =>sanitize_text_field( $country_code)
474
  ];
475
 
476
  $args = array(
517
  // make sure this call is legal
518
  if($this->safe_ajax_call(filter_input(INPUT_POST, 'gmcCategoryListsNonce'), 'tvcajax-gmc-category-lists-nonce')){
519
 
520
+ $country_code = filter_input(INPUT_POST, 'countryCode');
521
+ $customer_id = filter_input(INPUT_POST, 'customerId');
522
+ $parent = filter_input(INPUT_POST, 'parent');
523
  $url = $this->apiDomain.'/products/gmc-categories';
524
 
525
  $data = [
526
+ 'customer_id' => sanitize_text_field($customer_id),
527
+ 'country_code' => sanitize_text_field($country_code),
528
+ 'parent' => sanitize_text_field($parent)
529
  ];
530
 
531
  $args = array(
includes/setup/CustomApi.php CHANGED
@@ -9,16 +9,16 @@ class CustomApi{
9
  $this->token = 'MTIzNA==';
10
  }
11
  public function get_tvc_access_token(){
12
- if(!empty($this->access_token)){
13
- return $this->access_token;
14
- }else{
15
- $TVC_Admin_Helper = new TVC_Admin_Helper();
16
- $google_detail = $TVC_Admin_Helper->get_ee_options_data();
17
- if((isset($google_detail['setting']->access_token))){
18
- $this->access_token = sanitize_text_field(base64_decode($google_detail['setting']->access_token));
19
- }
20
- return $this->access_token;
21
  }
 
 
22
  }
23
 
24
  public function get_tvc_refresh_token(){
@@ -73,11 +73,11 @@ class CustomApi{
73
  $url = $this->apiDomain . '/customer-subscriptions/subscription-detail';
74
  $header = array(
75
  "Authorization: Bearer ".$this->token,
76
- "content-type: application/json"
77
  );
78
  $ee_options_data = unserialize(get_option('ee_options'));
79
  if($subscription_id == null && isset($ee_options_data['subscription_id'])) {
80
- $subscription_id = esc_attr($ee_options_data['subscription_id']);
81
  }
82
  $data = [
83
  'subscription_id' => sanitize_text_field($subscription_id),
@@ -91,10 +91,10 @@ class CustomApi{
91
  $args = array(
92
  'headers' =>$header,
93
  'method' => 'POST',
94
- 'body' => $data
95
  );
96
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
97
-
98
  $return = new \stdClass();
99
  if($result->status == 200){
100
  $return->status = $result->status;
@@ -117,6 +117,11 @@ class CustomApi{
117
  try {
118
  $url = $this->apiDomain . '/customer-subscriptions/tracking-options';
119
 
 
 
 
 
 
120
  $args = array(
121
  'headers' => array(
122
  'Authorization' => "Bearer $this->token",
@@ -150,51 +155,57 @@ class CustomApi{
150
  return $e->getMessage();
151
  }
152
  }
153
- public function add_survey_of_deactivate_plugin($data) {
154
- try {
155
- $header = array(
156
- "Authorization: Bearer MTIzNA==",
157
- "content-type: application/json"
158
- );
159
- $args = array(
160
- 'headers' =>$header,
161
- 'method' => 'POST',
162
- 'body' => $data
163
- );
164
- $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
 
 
 
 
 
 
165
 
166
- $return = new \stdClass();
167
- if($result->status == 200){
168
- $return->status = $result->status;
169
- $return->data = $result->data;
170
- $return->error = false;
171
- return $return;
172
- }else{
173
- $return->error = true;
174
- $return->data = $result->data;
175
- $return->status = $result->status;
176
- return $return;
177
- }
178
- } catch (Exception $e) {
179
- return $e->getMessage();
180
  }
 
 
 
181
  }
182
  public function active_licence_Key($licence_key, $subscription_id) {
183
  try {
184
  $header = array(
185
  "Authorization: Bearer MTIzNA==",
186
- "content-type: application/json"
187
  );
188
  $url = $this->apiDomain . "/licence/activation";
189
  $data = [
190
- 'key' => esc_attr($licence_key),
191
  'domain' => get_site_url(),
192
- 'subscription_id'=>esc_attr($subscription_id)
193
  ];
194
  $args = array(
195
  'headers' =>$header,
196
  'method' => 'POST',
197
- 'body' => $data
198
  );
199
  $request = wp_remote_post(esc_url_raw($url), $args);
200
  // Retrieve information
@@ -233,16 +244,16 @@ class CustomApi{
233
  try {
234
  $header = array(
235
  "Authorization: Bearer MTIzNA==",
236
- "content-type: application/json"
237
  );
238
  $url = $this->apiDomain . "/google-ads/remarketing-snippets";
239
  $data = [
240
- 'customer_id' => esc_attr($customer_id)
241
  ];
242
  $args = array(
243
  'headers' =>$header,
244
  'method' => 'POST',
245
- 'body' => $data
246
  );
247
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
248
 
@@ -266,30 +277,36 @@ class CustomApi{
266
  try {
267
  $header = array(
268
  "Authorization: Bearer MTIzNA==",
269
- "content-type: application/json"
270
  );
271
  $url = $this->apiDomain . "/google-ads/conversion-list";
272
  $data = [
273
- 'merchant_id' => esc_attr($merchant_id),
274
- 'customer_id' => esc_attr($customer_id)
275
  ];
276
  $args = array(
277
  'headers' =>$header,
278
  'method' => 'POST',
279
- 'body' => $data
280
  );
281
- $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
 
 
 
 
 
282
 
283
  $return = new \stdClass();
284
- if($result->status == 200){
285
- $return->status = $result->status;
286
  $return->data = $result->data;
287
  $return->error = false;
288
  return $return;
289
  }else{
290
  $return->error = true;
291
- $return->data = $result->data;
292
- $return->status = $result->status;
 
293
  return $return;
294
  }
295
  } catch (Exception $e) {
@@ -300,21 +317,69 @@ class CustomApi{
300
  * @since 4.1.4
301
  * Get view ID for GA3 reporting API
302
  */
303
- public function get_analytics_viewid_currency($data) {
304
- try {
305
- $header = array(
306
- "Authorization: Bearer MTIzNA==",
307
- "content-type: application/json"
308
- );
309
- $url = $this->apiDomain . "/actionable-dashboard/analytics-viewid-currency";
310
- $data['access_token']= $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  $args = array(
312
  'headers' =>$header,
313
  'method' => 'POST',
314
- 'body' => $data
315
  );
316
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
317
-
318
  $return = new \stdClass();
319
  if($result->status == 200){
320
  $return->status = $result->status;
@@ -327,166 +392,149 @@ class CustomApi{
327
  $return->status = $result->status;
328
  return $return;
329
  }
330
- } catch (Exception $e) {
331
- return $e->getMessage();
332
- }
333
- }
334
- /**
335
- * @since 4.1.4
336
- * Get google analytics reports call using reporting API
337
- */
338
- public function get_google_analytics_reports($data) {
339
- try {
340
- $url = $this->apiDomain . "/actionable-dashboard/google-analytics-reports";
341
- $header = array(
342
- "Authorization: Bearer MTIzNA==",
343
- "content-type: application/json"
344
- );
345
-
346
- $access_token = $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token());
347
- if($access_token != ""){
348
- $data['access_token']= $access_token;
349
- $args = array(
350
- 'headers' =>$header,
351
- 'method' => 'POST',
352
- 'body' => $data
353
- );
354
- $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
355
- //print_r($result);
356
- $return = new \stdClass();
357
- if($result->status == 200){
358
- $return->status = $result->status;
359
- $return->data = $result->data;
360
- $return->error = false;
361
- return $return;
362
- }else{
363
- $return->error = true;
364
- $return->data = $result->data;
365
- $return->status = $result->status;
366
- return $return;
367
- }
368
- }else{
369
- $return = new \stdClass();
370
- $return->error = true;
371
- $return->message = 'access_token_error';
372
- return $return;
373
- }
374
- } catch (Exception $e) {
375
- return $e->getMessage();
376
- }
377
  }
378
 
379
  public function setGmcCategoryMapping($postData) {
380
- try {
381
- $url = $this->apiDomain . '/gmc/gmc-category-mapping';
382
-
383
- $args = array(
384
- 'headers' => array(
385
- 'Authorization' => "Bearer $this->token",
386
- 'Content-Type' => 'application/json'
387
- ),
388
- 'method' => 'POST',
389
- 'body' => wp_json_encode($postData)
390
- );
391
-
392
- // Send remote request
393
- $request = wp_remote_post(esc_url_raw($url), $args);
394
 
395
- // Retrieve information
396
- $response_code = wp_remote_retrieve_response_code($request);
397
- $response_message = wp_remote_retrieve_response_message($request);
398
- $response_body = json_decode(wp_remote_retrieve_body($request));
 
 
 
 
399
 
400
- if ((isset($response_body->error) && $response_body->error == '')) {
 
401
 
402
- return new WP_REST_Response(
403
- array(
404
- 'status' => $response_code,
405
- 'message' => $response_message,
406
- 'data' => $response_body->data
407
- )
408
- );
409
- } else {
410
- return new WP_Error($response_code, $response_message, $response_body);
411
- }
412
- } catch (Exception $e) {
413
- return $e->getMessage();
 
 
 
414
  }
 
 
 
415
  }
416
  public function setGmcAttributeMapping($postData) {
417
- try {
418
- $url = $this->apiDomain . '/gmc/gmc-attribute-mapping';
 
 
 
 
 
419
 
420
- $args = array(
421
- 'headers' => array(
422
- 'Authorization' => "Bearer $this->token",
423
- 'Content-Type' => 'application/json'
424
- ),
425
- 'method' => 'POST',
426
- 'body' => wp_json_encode($postData)
427
- );
428
 
429
- // Send remote request
430
- $request = wp_remote_post($url, $args);
431
 
432
- // Retrieve information
433
- $response_code = wp_remote_retrieve_response_code($request);
434
- $response_message = wp_remote_retrieve_response_message($request);
435
- $response_body = json_decode(wp_remote_retrieve_body($request));
436
 
437
- if ((isset($response_body->error) && $response_body->error == '')) {
438
 
439
- return new WP_REST_Response(
440
- array(
441
- 'status' => $response_code,
442
- 'message' => $response_message,
443
- 'data' => $response_body->data
444
- )
445
- );
446
- } else {
447
- return new WP_Error($response_code, $response_message, $response_body);
448
- }
449
- } catch (Exception $e) {
450
- return $e->getMessage();
451
  }
 
 
 
452
  }
453
- public function products_sync($data) {
454
- try {
455
- $url = $this->apiDomain . "/products/batch";
456
- $args = array(
457
- 'timeout' => 10000,
458
- 'headers' => array(
459
- 'Authorization' => "Bearer MTIzNA==",
460
- 'Content-Type' => 'application/json',
461
- 'AccessToken' => $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token())
462
- ),
463
- 'body' => wp_json_encode($data)
464
- );
465
- $request = wp_remote_post(esc_url_raw($url), $args);
466
-
467
- // Retrieve information
468
- $response_code = wp_remote_retrieve_response_code($request);
469
- $response_message = wp_remote_retrieve_response_message($request);
470
- $response = json_decode(wp_remote_retrieve_body($request));
471
- $return = new \stdClass();
472
- if (isset($response->error) && $response->error == '') {
473
- $return->error = false;
474
- $return->products_sync = count($response->data->entries);
475
- return $return;
476
- }else{
477
- $return->error = true;
478
- foreach($response->errors as $err){
479
- $return->message = $err;
480
- break;
481
- }
482
- return $return;
483
  }
484
- } catch (Exception $e) {
485
- return $e->getMessage();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  }
 
 
 
487
  }
488
  public function getSyncProductList($postData) {
489
- try {
 
 
 
 
 
490
  $url = $this->apiDomain . "/products/list";
491
  $postData["maxResults"] = 25;
492
  $args = array(
@@ -530,35 +578,40 @@ class CustomApi{
530
 
531
  public function getCampaignCurrencySymbol($postData) {
532
  try {
533
- $url = $this->apiDomain . '/campaigns/currency-symbol';
534
-
535
- $args = array(
536
- 'headers' => array(
537
- 'Authorization' => "Bearer $this->token",
538
- 'Content-Type' => 'application/json'
539
- ),
540
- 'body' => wp_json_encode($postData)
541
- );
542
 
543
- // Send remote request
544
- $request = wp_remote_post(esc_url_raw($url), $args);
 
 
 
 
 
545
 
546
- // Retrieve information
547
- $response_code = wp_remote_retrieve_response_code($request);
548
- $response_message = wp_remote_retrieve_response_message($request);
549
- $response_body = json_decode(wp_remote_retrieve_body($request));
550
- if ((isset($response_body->error) && $response_body->error == '')) {
551
 
552
- return new WP_REST_Response(
553
- array(
554
- 'status' => $response_code,
555
- 'message' => $response_message,
556
- 'data' => $response_body->data
557
- )
558
- );
559
- } else {
560
- return new WP_Error($response_code, $response_message, $response_body);
561
- }
 
 
 
 
 
 
562
  } catch (Exception $e) {
563
  return $e->getMessage();
564
  }
@@ -581,9 +634,9 @@ class CustomApi{
581
 
582
  $data = [
583
  "grant_type" => 'refresh_token',
584
- "client_id" => esc_attr($clientId),
585
- 'client_secret' => esc_attr($clientSecret),
586
- 'refresh_token' => esc_attr($refresh_token),
587
  ];
588
  $args = array(
589
  'headers' =>$header,
@@ -609,21 +662,21 @@ class CustomApi{
609
  try {
610
  $url = $this->apiDomain . '/gmc/site-verification-token';
611
  $header = array("Authorization: Bearer MTIzNA==",
612
- "content-type: application/json",
613
  "AccessToken:" . $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token())
614
  );
615
 
616
  $data = [
617
- 'merchant_id' => esc_attr($postData['merchant_id']),
618
- 'website' => esc_url_raw($postData['website_url']),
619
- 'account_id' => esc_attr($postData['account_id']),
620
- 'method' => esc_attr($postData['method'])
621
  ];
622
 
623
  $args = array(
624
  'headers' =>$header,
625
  'method' => 'POST',
626
- 'body' => $data
627
  );
628
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
629
 
@@ -648,22 +701,22 @@ class CustomApi{
648
  try {
649
  $url = $this->apiDomain . '/gmc/site-verification';
650
  $header = array("Authorization: Bearer MTIzNA==",
651
- "content-type: application/json",
652
- "AccessToken:" . $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token())
653
  );
654
 
655
  $data = [
656
- 'merchant_id' => esc_attr($postData['merchant_id']),
657
  'website' => esc_url_raw($postData['website_url']),
658
- 'subscription_id' => esc_attr($postData['subscription_id']),
659
- 'account_id' => esc_attr($postData['account_id']),
660
- 'method' => esc_attr($postData['method'])
661
  ];
662
 
663
  $args = array(
664
  'headers' =>$header,
665
  'method' => 'POST',
666
- 'body' => $data
667
  );
668
  $request = wp_remote_post(esc_url_raw($url), $args);
669
  // Retrieve information
@@ -690,46 +743,45 @@ class CustomApi{
690
  }
691
 
692
  public function claimWebsite($postData) {
693
- try {
694
- $url = $this->apiDomain . '/gmc/claim-website';
695
- $header = array("Authorization: Bearer MTIzNA==",
696
- "content-type: application/json",
697
- "AccessToken:" . $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token())
698
- );
699
- $data = [
700
- 'merchant_id' => esc_attr($postData['merchant_id']),
701
- 'account_id' => esc_attr($postData['account_id']),
702
- 'website' => $postData['website_url'],
703
- 'access_token' => $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token()),
704
- 'subscription_id' => esc_attr($postData['subscription_id']),
705
- ];
706
- $args = array(
707
- 'headers' =>$header,
708
- 'method' => 'POST',
709
- 'body' => $data
710
- );
711
- $request = wp_remote_post(esc_url_raw($url), $args);
712
- // Retrieve information
713
- $response_code = wp_remote_retrieve_response_code($request);
714
- $response_message = wp_remote_retrieve_response_message($request);
715
- $result = json_decode(wp_remote_retrieve_body($request));
716
-
717
 
718
- $return = new \stdClass();
719
- if ((isset($result->error) && $result->error == '')) {
720
-
721
- $return->data = $result->data;
722
- $return->error = false;
723
- return $return;
724
- }else{
725
- $return->error = true;
726
- $return->errors = $result->errors;
727
-
728
- return $return;
729
- }
730
- } catch (Exception $e) {
731
- return $e->getMessage();
732
- }
733
- }
734
 
735
  }
9
  $this->token = 'MTIzNA==';
10
  }
11
  public function get_tvc_access_token(){
12
+ if(!empty($this->access_token)){
13
+ return $this->access_token;
14
+ }else{
15
+ $TVC_Admin_Helper = new TVC_Admin_Helper();
16
+ $google_detail = $TVC_Admin_Helper->get_ee_options_data();
17
+ if((isset($google_detail['setting']->access_token))){
18
+ $this->access_token = sanitize_text_field(base64_decode($google_detail['setting']->access_token));
 
 
19
  }
20
+ return $this->access_token;
21
+ }
22
  }
23
 
24
  public function get_tvc_refresh_token(){
73
  $url = $this->apiDomain . '/customer-subscriptions/subscription-detail';
74
  $header = array(
75
  "Authorization: Bearer ".$this->token,
76
+ "Content-Type" => "application/json"
77
  );
78
  $ee_options_data = unserialize(get_option('ee_options'));
79
  if($subscription_id == null && isset($ee_options_data['subscription_id'])) {
80
+ $subscription_id = sanitize_text_field($ee_options_data['subscription_id']);
81
  }
82
  $data = [
83
  'subscription_id' => sanitize_text_field($subscription_id),
91
  $args = array(
92
  'headers' =>$header,
93
  'method' => 'POST',
94
+ 'body' => wp_json_encode($data)
95
  );
96
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
97
+ //print_r($result);
98
  $return = new \stdClass();
99
  if($result->status == 200){
100
  $return->status = $result->status;
117
  try {
118
  $url = $this->apiDomain . '/customer-subscriptions/tracking-options';
119
 
120
+ if(!empty($postData)){
121
+ foreach ($postData as $key => $value) {
122
+ $postData[$key] = sanitize_text_field($value);
123
+ }
124
+ }
125
  $args = array(
126
  'headers' => array(
127
  'Authorization' => "Bearer $this->token",
155
  return $e->getMessage();
156
  }
157
  }
158
+ public function add_survey_of_deactivate_plugin($postData) {
159
+ try {
160
+ $url = $this->apiDomain . "/customersurvey";
161
+ if(!empty($postData)){
162
+ foreach ($postData as $key => $value) {
163
+ $postData[$key] = sanitize_text_field($value);
164
+ }
165
+ }
166
+ $header = array(
167
+ "Authorization: Bearer MTIzNA==",
168
+ "Content-Type" => "application/json"
169
+ );
170
+ $args = array(
171
+ 'headers' =>$header,
172
+ 'method' => 'POST',
173
+ 'body' => wp_json_encode($postData)
174
+ );
175
+ $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
176
 
177
+ $return = new \stdClass();
178
+ if($result->status == 200){
179
+ $return->status = $result->status;
180
+ $return->data = $result->data;
181
+ $return->error = false;
182
+ return $return;
183
+ }else{
184
+ $return->error = true;
185
+ $return->data = $result->data;
186
+ $return->status = $result->status;
187
+ return $return;
 
 
 
188
  }
189
+ } catch (Exception $e) {
190
+ return $e->getMessage();
191
+ }
192
  }
193
  public function active_licence_Key($licence_key, $subscription_id) {
194
  try {
195
  $header = array(
196
  "Authorization: Bearer MTIzNA==",
197
+ "Content-Type" => "application/json"
198
  );
199
  $url = $this->apiDomain . "/licence/activation";
200
  $data = [
201
+ 'key' => sanitize_text_field($licence_key),
202
  'domain' => get_site_url(),
203
+ 'subscription_id'=>sanitize_text_field($subscription_id)
204
  ];
205
  $args = array(
206
  'headers' =>$header,
207
  'method' => 'POST',
208
+ 'body' => wp_json_encode($data)
209
  );
210
  $request = wp_remote_post(esc_url_raw($url), $args);
211
  // Retrieve information
244
  try {
245
  $header = array(
246
  "Authorization: Bearer MTIzNA==",
247
+ "Content-Type" => "application/json"
248
  );
249
  $url = $this->apiDomain . "/google-ads/remarketing-snippets";
250
  $data = [
251
+ 'customer_id' => sanitize_text_field($customer_id)
252
  ];
253
  $args = array(
254
  'headers' =>$header,
255
  'method' => 'POST',
256
+ 'body' => wp_json_encode($data)
257
  );
258
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
259
 
277
  try {
278
  $header = array(
279
  "Authorization: Bearer MTIzNA==",
280
+ "Content-Type" => "application/json"
281
  );
282
  $url = $this->apiDomain . "/google-ads/conversion-list";
283
  $data = [
284
+ 'merchant_id' => sanitize_text_field($merchant_id),
285
+ 'customer_id' => sanitize_text_field($customer_id)
286
  ];
287
  $args = array(
288
  'headers' =>$header,
289
  'method' => 'POST',
290
+ 'body' => wp_json_encode($data)
291
  );
292
+
293
+ // $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
294
+ $request = wp_remote_post(esc_url_raw($url), $args);
295
+ $response_code = wp_remote_retrieve_response_code($request);
296
+ $response_message = wp_remote_retrieve_response_message($request);
297
+ $result = json_decode(wp_remote_retrieve_body($request));
298
 
299
  $return = new \stdClass();
300
+ if ((isset($response_body->error) && $response_body->error == '')) {
301
+ $return->status = $response_code;
302
  $return->data = $result->data;
303
  $return->error = false;
304
  return $return;
305
  }else{
306
  $return->error = true;
307
+ $return->errors = $result->errors;
308
+ //$return->error = $result->data;
309
+ $return->status = $response_code;
310
  return $return;
311
  }
312
  } catch (Exception $e) {
317
  * @since 4.1.4
318
  * Get view ID for GA3 reporting API
319
  */
320
+ public function get_analytics_viewid_currency($postData) {
321
+ try {
322
+ if(!empty($postData)){
323
+ foreach ($postData as $key => $value) {
324
+ $postData[$key] = sanitize_text_field($value);
325
+ }
326
+ }
327
+ $header = array(
328
+ "Authorization: Bearer MTIzNA==",
329
+ "Content-Type" => "application/json"
330
+ );
331
+ $url = $this->apiDomain . "/actionable-dashboard/analytics-viewid-currency";
332
+ $postData['access_token']= $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token());
333
+ $args = array(
334
+ 'headers' =>$header,
335
+ 'method' => 'POST',
336
+ 'body' => wp_json_encode($postData)
337
+ );
338
+ $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
339
+
340
+ $return = new \stdClass();
341
+ if($result->status == 200){
342
+ $return->status = $result->status;
343
+ $return->data = $result->data;
344
+ $return->error = false;
345
+ return $return;
346
+ }else{
347
+ $return->error = true;
348
+ $return->data = $result->data;
349
+ $return->status = $result->status;
350
+ return $return;
351
+ }
352
+ } catch (Exception $e) {
353
+ return $e->getMessage();
354
+ }
355
+ }
356
+ /**
357
+ * @since 4.1.4
358
+ * Get google analytics reports call using reporting API
359
+ */
360
+ public function get_google_analytics_reports($postData) {
361
+ try {
362
+ if(!empty($postData)){
363
+ foreach ($postData as $key => $value) {
364
+ $postData[$key] = sanitize_text_field($value);
365
+ }
366
+ }
367
+ $url = $this->apiDomain . "/actionable-dashboard/google-analytics-reports";
368
+ $header = array(
369
+ "Authorization: Bearer MTIzNA==",
370
+ "Content-Type" => "application/json"
371
+ );
372
+
373
+ $access_token = $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token());
374
+ if($access_token != ""){
375
+ $postData['access_token']= $access_token;
376
  $args = array(
377
  'headers' =>$header,
378
  'method' => 'POST',
379
+ 'body' => wp_json_encode($postData)
380
  );
381
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
382
+ //print_r($result);
383
  $return = new \stdClass();
384
  if($result->status == 200){
385
  $return->status = $result->status;
392
  $return->status = $result->status;
393
  return $return;
394
  }
395
+ }else{
396
+ $return = new \stdClass();
397
+ $return->error = true;
398
+ $return->message = 'access_token_error';
399
+ return $return;
400
+ }
401
+ } catch (Exception $e) {
402
+ return $e->getMessage();
403
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
  }
405
 
406
  public function setGmcCategoryMapping($postData) {
407
+ try {
408
+ if(!empty($postData)){
409
+ foreach ($postData as $key => $value) {
410
+ $postData[$key] = sanitize_text_field($value);
411
+ }
412
+ }
413
+ $url = $this->apiDomain . '/gmc/gmc-category-mapping';
 
 
 
 
 
 
 
414
 
415
+ $args = array(
416
+ 'headers' => array(
417
+ 'Authorization' => "Bearer $this->token",
418
+ 'Content-Type' => 'application/json'
419
+ ),
420
+ 'method' => 'POST',
421
+ 'body' => wp_json_encode($postData)
422
+ );
423
 
424
+ // Send remote request
425
+ $request = wp_remote_post(esc_url_raw($url), $args);
426
 
427
+ // Retrieve information
428
+ $response_code = wp_remote_retrieve_response_code($request);
429
+ $response_message = wp_remote_retrieve_response_message($request);
430
+ $response_body = json_decode(wp_remote_retrieve_body($request));
431
+
432
+ if ((isset($response_body->error) && $response_body->error == '')) {
433
+ return new WP_REST_Response(
434
+ array(
435
+ 'status' => $response_code,
436
+ 'message' => $response_message,
437
+ 'data' => $response_body->data
438
+ )
439
+ );
440
+ } else {
441
+ return new WP_Error($response_code, $response_message, $response_body);
442
  }
443
+ } catch (Exception $e) {
444
+ return $e->getMessage();
445
+ }
446
  }
447
  public function setGmcAttributeMapping($postData) {
448
+ try {
449
+ if(!empty($postData)){
450
+ foreach ($postData as $key => $value) {
451
+ $postData[$key] = sanitize_text_field($value);
452
+ }
453
+ }
454
+ $url = $this->apiDomain . '/gmc/gmc-attribute-mapping';
455
 
456
+ $args = array(
457
+ 'headers' => array(
458
+ 'Authorization' => "Bearer $this->token",
459
+ 'Content-Type' => 'application/json'
460
+ ),
461
+ 'method' => 'POST',
462
+ 'body' => wp_json_encode($postData)
463
+ );
464
 
465
+ // Send remote request
466
+ $request = wp_remote_post($url, $args);
467
 
468
+ // Retrieve information
469
+ $response_code = wp_remote_retrieve_response_code($request);
470
+ $response_message = wp_remote_retrieve_response_message($request);
471
+ $response_body = json_decode(wp_remote_retrieve_body($request));
472
 
473
+ if ((isset($response_body->error) && $response_body->error == '')) {
474
 
475
+ return new WP_REST_Response(
476
+ array(
477
+ 'status' => $response_code,
478
+ 'message' => $response_message,
479
+ 'data' => $response_body->data
480
+ )
481
+ );
482
+ } else {
483
+ return new WP_Error($response_code, $response_message, $response_body);
 
 
 
484
  }
485
+ } catch (Exception $e) {
486
+ return $e->getMessage();
487
+ }
488
  }
489
+ public function products_sync($postData) {
490
+ try {
491
+ if(!empty($postData)){
492
+ foreach ($postData as $key => $value) {
493
+ if( in_array($key, array("merchant_id", "account_id", "subscription_id") ) ){
494
+ $postData[$key] = sanitize_text_field($value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
495
  }
496
+ }
497
+ }
498
+ $url = $this->apiDomain . "/products/batch";
499
+ $args = array(
500
+ 'timeout' => 10000,
501
+ 'headers' => array(
502
+ 'Authorization' => "Bearer MTIzNA==",
503
+ 'Content-Type' => 'application/json',
504
+ 'AccessToken' => $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token())
505
+ ),
506
+ 'body' => wp_json_encode($postData)
507
+ );
508
+ $request = wp_remote_post(esc_url_raw($url), $args);
509
+
510
+ // Retrieve information
511
+ $response_code = wp_remote_retrieve_response_code($request);
512
+ $response_message = wp_remote_retrieve_response_message($request);
513
+ $response = json_decode(wp_remote_retrieve_body($request));
514
+ $return = new \stdClass();
515
+ if (isset($response->error) && $response->error == '') {
516
+ $return->error = false;
517
+ $return->products_sync = count($response->data->entries);
518
+ return $return;
519
+ }else{
520
+ $return->error = true;
521
+ foreach($response->errors as $err){
522
+ $return->message = $err;
523
+ break;
524
+ }
525
+ return $return;
526
  }
527
+ } catch (Exception $e) {
528
+ return $e->getMessage();
529
+ }
530
  }
531
  public function getSyncProductList($postData) {
532
+ try {
533
+ if(!empty($postData)){
534
+ foreach ($postData as $key => $value) {
535
+ $postData[$key] = sanitize_text_field($value);
536
+ }
537
+ }
538
  $url = $this->apiDomain . "/products/list";
539
  $postData["maxResults"] = 25;
540
  $args = array(
578
 
579
  public function getCampaignCurrencySymbol($postData) {
580
  try {
581
+ if(!empty($postData)){
582
+ foreach ($postData as $key => $value) {
583
+ $postData[$key] = sanitize_text_field($value);
584
+ }
585
+ }
586
+ $url = $this->apiDomain . '/campaigns/currency-symbol';
 
 
 
587
 
588
+ $args = array(
589
+ 'headers' => array(
590
+ 'Authorization' => "Bearer $this->token",
591
+ 'Content-Type' => 'application/json'
592
+ ),
593
+ 'body' => wp_json_encode($postData)
594
+ );
595
 
596
+ // Send remote request
597
+ $request = wp_remote_post(esc_url_raw($url), $args);
 
 
 
598
 
599
+ // Retrieve information
600
+ $response_code = wp_remote_retrieve_response_code($request);
601
+ $response_message = wp_remote_retrieve_response_message($request);
602
+ $response_body = json_decode(wp_remote_retrieve_body($request));
603
+ if ((isset($response_body->error) && $response_body->error == '')) {
604
+
605
+ return new WP_REST_Response(
606
+ array(
607
+ 'status' => $response_code,
608
+ 'message' => $response_message,
609
+ 'data' => $response_body->data
610
+ )
611
+ );
612
+ } else {
613
+ return new WP_Error($response_code, $response_message, $response_body);
614
+ }
615
  } catch (Exception $e) {
616
  return $e->getMessage();
617
  }
634
 
635
  $data = [
636
  "grant_type" => 'refresh_token',
637
+ "client_id" => sanitize_text_field($clientId),
638
+ 'client_secret' => sanitize_text_field($clientSecret),
639
+ 'refresh_token' => sanitize_text_field($refresh_token),
640
  ];
641
  $args = array(
642
  'headers' =>$header,
662
  try {
663
  $url = $this->apiDomain . '/gmc/site-verification-token';
664
  $header = array("Authorization: Bearer MTIzNA==",
665
+ "Content-Type" => "application/json",
666
  "AccessToken:" . $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token())
667
  );
668
 
669
  $data = [
670
+ 'merchant_id' => sanitize_text_field($postData['merchant_id']),
671
+ 'website' => sanitize_text_field($postData['website_url']),
672
+ 'account_id' => sanitize_text_field($postData['account_id']),
673
+ 'method' => sanitize_text_field($postData['method'])
674
  ];
675
 
676
  $args = array(
677
  'headers' =>$header,
678
  'method' => 'POST',
679
+ 'body' => wp_json_encode($data)
680
  );
681
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
682
 
701
  try {
702
  $url = $this->apiDomain . '/gmc/site-verification';
703
  $header = array("Authorization: Bearer MTIzNA==",
704
+ "Content-Type" => "application/json",
705
+ "AccessToken:" . $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token())
706
  );
707
 
708
  $data = [
709
+ 'merchant_id' => sanitize_text_field($postData['merchant_id']),
710
  'website' => esc_url_raw($postData['website_url']),
711
+ 'subscription_id' => sanitize_text_field($postData['subscription_id']),
712
+ 'account_id' => sanitize_text_field($postData['account_id']),
713
+ 'method' => sanitize_text_field($postData['method'])
714
  ];
715
 
716
  $args = array(
717
  'headers' =>$header,
718
  'method' => 'POST',
719
+ 'body' => wp_json_encode($data)
720
  );
721
  $request = wp_remote_post(esc_url_raw($url), $args);
722
  // Retrieve information
743
  }
744
 
745
  public function claimWebsite($postData) {
746
+ try {
747
+ $url = $this->apiDomain . '/gmc/claim-website';
748
+ $data = [
749
+ 'merchant_id' => sanitize_text_field($postData['merchant_id']),
750
+ 'account_id' => sanitize_text_field($postData['account_id']),
751
+ 'website' => esc_url_raw($postData['website_url']),
752
+ 'access_token' => $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token()),
753
+ 'subscription_id' => sanitize_text_field($postData['subscription_id']),
754
+ ];
755
+ $args = array(
756
+ 'timeout' => 10000,
757
+ 'headers' => array(
758
+ 'Authorization' => "Bearer MTIzNA==",
759
+ 'Content-Type' => 'application/json',
760
+ 'AccessToken' => $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token())
761
+ ),
762
+ 'body' => wp_json_encode($data)
763
+ );
764
+ $request = wp_remote_post(esc_url_raw($url), $args);
765
+ // Retrieve information
766
+ $response_code = wp_remote_retrieve_response_code($request);
767
+ $response_message = wp_remote_retrieve_response_message($request);
768
+ $result = json_decode(wp_remote_retrieve_body($request));
 
769
 
770
+ $return = new \stdClass();
771
+ if ((isset($result->error) && $result->error == '')) {
772
+
773
+ $return->data = $result->data;
774
+ $return->error = false;
775
+ return $return;
776
+ }else{
777
+ $return->error = true;
778
+ $return->errors = $result->errors;
779
+
780
+ return $return;
781
+ }
782
+ } catch (Exception $e) {
783
+ return $e->getMessage();
784
+ }
785
+ }
786
 
787
  }
includes/setup/ShoppingApi.php CHANGED
@@ -46,7 +46,7 @@ class ShoppingApi {
46
  return new WP_REST_Response(
47
  array(
48
  'status' => $response_code,
49
- 'message' => $response_message,
50
  'data' => $response_body->data
51
  )
52
  );
@@ -88,7 +88,7 @@ class ShoppingApi {
88
  return new WP_REST_Response(
89
  array(
90
  'status' => $response_code,
91
- 'message' => $response_message,
92
  'data' => $response_body->data
93
  )
94
  );
@@ -138,7 +138,7 @@ class ShoppingApi {
138
  return new WP_REST_Response(
139
  array(
140
  'status' => $response_code,
141
- 'message' => $response_message,
142
  'data' => $response_body->data
143
  )
144
  );
@@ -169,12 +169,12 @@ class ShoppingApi {
169
 
170
  $header = array(
171
  "Authorization: Bearer $this->token",
172
- "content-type: application/json"
173
  );
174
  $args = array(
175
  'headers' =>$header,
176
  'method' => 'POST',
177
- 'body' => $data
178
  );
179
  // Send remote request
180
  $request = wp_remote_post(esc_url_raw($url), $args);
@@ -218,12 +218,12 @@ class ShoppingApi {
218
  ];
219
  $header = array(
220
  "Authorization: Bearer $this->token",
221
- "content-type: application/json"
222
  );
223
  $args = array(
224
  'headers' =>$header,
225
  'method' => 'POST',
226
- 'body' => $data
227
  );
228
  // Send remote request
229
  $request = wp_remote_post(esc_url_raw($url), $args);
@@ -287,7 +287,7 @@ class ShoppingApi {
287
  return new WP_REST_Response(
288
  array(
289
  'status' => $response_code,
290
- 'message' => $response_message,
291
  'data' => $response_body->data
292
  )
293
  );
@@ -333,7 +333,7 @@ class ShoppingApi {
333
  return new WP_REST_Response(
334
  array(
335
  'status' => $response_code,
336
- 'message' => $response_message,
337
  'data' => $response_body->data
338
  )
339
  );
@@ -379,7 +379,7 @@ class ShoppingApi {
379
  return new WP_REST_Response(
380
  array(
381
  'status' => $response_code,
382
- 'message' => $response_message,
383
  'data' => $response_body->data
384
  )
385
  );
@@ -424,7 +424,7 @@ class ShoppingApi {
424
  return new WP_REST_Response(
425
  array(
426
  'status' => $response_code,
427
- 'message' => $response_message,
428
  'data' => $response_body->data
429
  )
430
  );
@@ -439,7 +439,7 @@ class ShoppingApi {
439
  try {
440
  $header = array(
441
  "Authorization: Bearer MTIzNA==",
442
- "content-type: application/json"
443
  );
444
  $curl_url = $this->apiDomain . "/campaigns/create";
445
  $data = [
@@ -456,7 +456,7 @@ class ShoppingApi {
456
  $args = array(
457
  'headers' =>$header,
458
  'method' => 'POST',
459
- 'body' => $data
460
  );
461
  $request = wp_remote_post(esc_url_raw($curl_url), $args);
462
 
@@ -467,7 +467,7 @@ class ShoppingApi {
467
  $return = new \stdClass();
468
  if (isset($response->error) && $response->error == false) {
469
  $return->error = false;
470
- $return->message = $response->message;
471
  $return->data = $response->data;
472
  return $return;
473
  } else {
@@ -484,7 +484,7 @@ class ShoppingApi {
484
  try {
485
  $header = array(
486
  "Authorization: Bearer MTIzNA==",
487
- "content-type: application/json"
488
  );
489
  $curl_url = $this->apiDomain . '/campaigns/update';
490
  $data = [
@@ -506,7 +506,7 @@ class ShoppingApi {
506
  $args = array(
507
  'headers' =>$header,
508
  'method' => 'PATCH',
509
- 'body' => $data
510
  );
511
  $request = wp_remote_post(esc_url_raw($curl_url), $args);
512
  $response_code = wp_remote_retrieve_response_code($request);
@@ -515,7 +515,7 @@ class ShoppingApi {
515
  $return = new \stdClass();
516
  if (isset($response->error) && $response->error == false) {
517
  $return->error = false;
518
- $return->message = $response->message;
519
  $return->data = $response->data;
520
  return $return;
521
  } else {
46
  return new WP_REST_Response(
47
  array(
48
  'status' => $response_code,
49
+ 'message' => esc_attr($response_message),
50
  'data' => $response_body->data
51
  )
52
  );
88
  return new WP_REST_Response(
89
  array(
90
  'status' => $response_code,
91
+ 'message' => esc_attr($response_message),
92
  'data' => $response_body->data
93
  )
94
  );
138
  return new WP_REST_Response(
139
  array(
140
  'status' => $response_code,
141
+ 'message' => esc_attr($response_message),
142
  'data' => $response_body->data
143
  )
144
  );
169
 
170
  $header = array(
171
  "Authorization: Bearer $this->token",
172
+ "Content-Type" => "application/json"
173
  );
174
  $args = array(
175
  'headers' =>$header,
176
  'method' => 'POST',
177
+ 'body' => wp_json_encode($data)
178
  );
179
  // Send remote request
180
  $request = wp_remote_post(esc_url_raw($url), $args);
218
  ];
219
  $header = array(
220
  "Authorization: Bearer $this->token",
221
+ "Content-Type" => "application/json"
222
  );
223
  $args = array(
224
  'headers' =>$header,
225
  'method' => 'POST',
226
+ 'body' => wp_json_encode($data)
227
  );
228
  // Send remote request
229
  $request = wp_remote_post(esc_url_raw($url), $args);
287
  return new WP_REST_Response(
288
  array(
289
  'status' => $response_code,
290
+ 'message' => esc_attr($response_message),
291
  'data' => $response_body->data
292
  )
293
  );
333
  return new WP_REST_Response(
334
  array(
335
  'status' => $response_code,
336
+ 'message' => esc_attr($response_message),
337
  'data' => $response_body->data
338
  )
339
  );
379
  return new WP_REST_Response(
380
  array(
381
  'status' => $response_code,
382
+ 'message' => esc_attr($response_message),
383
  'data' => $response_body->data
384
  )
385
  );
424
  return new WP_REST_Response(
425
  array(
426
  'status' => $response_code,
427
+ 'message' => esc_attr($response_message),
428
  'data' => $response_body->data
429
  )
430
  );
439
  try {
440
  $header = array(
441
  "Authorization: Bearer MTIzNA==",
442
+ "Content-Type" => "application/json"
443
  );
444
  $curl_url = $this->apiDomain . "/campaigns/create";
445
  $data = [
456
  $args = array(
457
  'headers' =>$header,
458
  'method' => 'POST',
459
+ 'body' => wp_json_encode($data)
460
  );
461
  $request = wp_remote_post(esc_url_raw($curl_url), $args);
462
 
467
  $return = new \stdClass();
468
  if (isset($response->error) && $response->error == false) {
469
  $return->error = false;
470
+ $return->message = esc_attr($response->message);
471
  $return->data = $response->data;
472
  return $return;
473
  } else {
484
  try {
485
  $header = array(
486
  "Authorization: Bearer MTIzNA==",
487
+ "Content-Type" => "application/json"
488
  );
489
  $curl_url = $this->apiDomain . '/campaigns/update';
490
  $data = [
506
  $args = array(
507
  'headers' =>$header,
508
  'method' => 'PATCH',
509
+ 'body' => wp_json_encode($data)
510
  );
511
  $request = wp_remote_post(esc_url_raw($curl_url), $args);
512
  $response_code = wp_remote_retrieve_response_code($request);
515
  $return = new \stdClass();
516
  if (isset($response->error) && $response->error == false) {
517
  $return->error = false;
518
+ $return->message = esc_attr($response->message);
519
  $return->data = $response->data;
520
  return $return;
521
  } else {
includes/setup/account.php CHANGED
@@ -30,31 +30,31 @@ class TVC_Account {
30
  if ($this->google_detail['setting']) {
31
  $googleDetail = $this->google_detail['setting'];
32
  if(isset($googleDetail->plan_id) && !in_array($googleDetail->plan_id, array("1"))){
33
- $plan_id = esc_attr($googleDetail->plan_id);
34
  }
35
  if(isset($googleDetail->licence_key) && !in_array($googleDetail->plan_id, array("1"))){
36
- $api_licence_key = esc_attr($googleDetail->licence_key);
37
  }
38
  if(isset($googleDetail->plan_name) && !in_array($googleDetail->plan_id, array("1"))){
39
- $plan_name = esc_attr($googleDetail->plan_name);
40
  }
41
  if(isset($googleDetail->price) && !in_array($googleDetail->plan_id, array("1"))){
42
- $plan_price = esc_attr($googleDetail->price." USD");
43
  }
44
  if(isset($googleDetail->paypal_subscr_id) && !in_array($googleDetail->plan_id, array("1"))){
45
- $paypal_subscr_id = esc_attr($googleDetail->paypal_subscr_id);
46
  }
47
  if(isset($googleDetail->max_limit)){
48
- $product_sync_max_limit = esc_attr($googleDetail->max_limit);
49
  if(in_array($plan_id, array("7","8"))){
50
  $product_sync_max_limit = esc_html__("Unlimited","conversios");
51
  }
52
  }
53
  if(isset($googleDetail->subscription_activation_date) && !in_array($googleDetail->plan_id, array("1"))){
54
- $activation_date = esc_attr($googleDetail->subscription_activation_date);
55
  }
56
  if(isset($googleDetail->subscription_expiry_date) && !in_array($googleDetail->plan_id, array("1"))){
57
- $next_payment_date = esc_attr($googleDetail->subscription_expiry_date);
58
  }
59
  }
60
  }
30
  if ($this->google_detail['setting']) {
31
  $googleDetail = $this->google_detail['setting'];
32
  if(isset($googleDetail->plan_id) && !in_array($googleDetail->plan_id, array("1"))){
33
+ $plan_id = $googleDetail->plan_id;
34
  }
35
  if(isset($googleDetail->licence_key) && !in_array($googleDetail->plan_id, array("1"))){
36
+ $api_licence_key = $googleDetail->licence_key;
37
  }
38
  if(isset($googleDetail->plan_name) && !in_array($googleDetail->plan_id, array("1"))){
39
+ $plan_name = $googleDetail->plan_name;
40
  }
41
  if(isset($googleDetail->price) && !in_array($googleDetail->plan_id, array("1"))){
42
+ $plan_price = $googleDetail->price." USD";
43
  }
44
  if(isset($googleDetail->paypal_subscr_id) && !in_array($googleDetail->plan_id, array("1"))){
45
+ $paypal_subscr_id = $googleDetail->paypal_subscr_id;
46
  }
47
  if(isset($googleDetail->max_limit)){
48
+ $product_sync_max_limit = $googleDetail->max_limit;
49
  if(in_array($plan_id, array("7","8"))){
50
  $product_sync_max_limit = esc_html__("Unlimited","conversios");
51
  }
52
  }
53
  if(isset($googleDetail->subscription_activation_date) && !in_array($googleDetail->plan_id, array("1"))){
54
+ $activation_date = $googleDetail->subscription_activation_date;
55
  }
56
  if(isset($googleDetail->subscription_expiry_date) && !in_array($googleDetail->plan_id, array("1"))){
57
+ $next_payment_date = $googleDetail->subscription_expiry_date;
58
  }
59
  }
60
  }
includes/setup/add-campaign.php CHANGED
@@ -61,23 +61,14 @@ class AddCampaign {
61
  }
62
 
63
  $defaultCountry = $this->TVC_Admin_Helper->get_woo_country();
64
- /*$category_list = $api_obj->getCategories($defaultCountry);
65
- if(isset($category_list->errors) && !empty($category_list->errors)){
66
- }else{
67
- $category_list = isset($category_list->data) ? $category_list->data : [];
68
- if (isset($category_list['status']) && $category_list['status'] == 200) {
69
- $categories = $category_list['data'];
70
- }
71
- }*/
72
-
73
 
74
  if (isset($_POST['create_campaign'])) {
75
- $campaign_name = esc_attr(isset($_POST['campaign_name'])?sanitize_text_field($_POST['campaign_name']):"");
76
- $campaign_budget = esc_attr(isset($_POST['campaign_budget'])?sanitize_text_field($_POST['campaign_budget']):"");
77
- $sales_country = esc_attr(isset($_POST['sales_country'])?sanitize_text_field($_POST['sales_country']):"");
78
- $all_products = esc_attr(isset($_POST['all_products'])?sanitize_text_field($_POST['all_products']):"");
79
- $category_id = esc_attr(isset($_POST['dimension'])?sanitize_text_field($_POST['dimension']):"");
80
- $category_level = esc_attr(isset($_POST['category_level'])?sanitize_text_field($_POST['category_level']):"");
81
 
82
  $campaign = $api_obj->createCampaign($campaign_name, $campaign_budget, $sales_country, $all_products, $category_id, $category_level);
83
  if(isset($campaign->errors) && !empty($campaign->errors)){
@@ -89,16 +80,16 @@ class AddCampaign {
89
  $message = esc_html__('Smart Shopping Campaign Created Successfully '.$campaign_neme, 'conversios');
90
  }
91
  }else if (isset($_POST['update_campaign'])) {
92
- $campaign_name = esc_attr(isset($_POST['campaign_name'])?sanitize_text_field($_POST['campaign_name']):"");
93
- $campaign_budget = esc_attr(isset($_POST['campaign_budget'])?sanitize_text_field($_POST['campaign_budget']):"");
94
- $campaign_id = esc_attr(isset($_POST['campaign_id'])?sanitize_text_field($_POST['campaign_id']):"");
95
- $budget_id = esc_attr(isset($_POST['budget_id'])?sanitize_text_field($_POST['budget_id']):"");
96
- $sales_country = esc_attr(isset($_POST['sales_country'])?sanitize_text_field($_POST['sales_country']):"");
97
- $all_products = esc_attr(isset($_POST['all_products'])?sanitize_text_field($_POST['all_products']):"");
98
- $ad_group_id = esc_attr(isset($_POST['ad_group_id'])?sanitize_text_field($_POST['ad_group_id']):"");
99
- $ad_group_resource_name = esc_attr(isset($_POST['ad_group_resource_name'])?sanitize_text_field($_POST['ad_group_resource_name']):"");
100
- $category_id = esc_attr(isset($_POST['dimension']) ? sanitize_text_field($_POST['dimension']):"");
101
- $category_level = esc_attr(isset($_POST['category_level'])?sanitize_text_field($_POST['category_level']):"");
102
 
103
  $campaign = $api_obj->updateCampaign($campaign_name, $campaign_budget, $campaign_id, $budget_id, $sales_country, $all_products, $category_id, $category_level, $ad_group_id, $ad_group_resource_name);
104
  if (isset($campaign->errors) && !empty($campaign->errors)) {
@@ -215,7 +206,7 @@ class AddCampaign {
215
  <input type="text" class="form-group col-md-6" name="campaign_name" value="<?php echo (isset($campaign_details) && $campaign_details != '')?esc_attr($campaign_details->compaignName):""; ?>" id="campaign-name" required>
216
  </div>
217
  <div class="col-md-12 row">
218
- <label for="campaign-budget" class="form-group col-md-4 mt-2 mb-0 text-left"><span class="font-weight-bold"><?php esc_html_e("Daily Campaign Budget","conversios"); ?> (<?php echo $currency; ?>):</span> <p style="text-align:left;font-size: 11px;"><?php esc_html_e("Only pay if someone clicks your ad. Recommended minimum budget of","conversios"); ?> <?php echo esc_attr($currency); ?>5 per day.</p></label>
219
  <input type="number" class="form-group col-md-6" name="campaign_budget" id="campaign-budget" value="<?php echo (isset($campaign_details) && $campaign_details != '')?esc_attr($campaign_details->dailyBudget):""; ?>" style="height: 35px;" required>
220
  </div>
221
  <input type="hidden" name="campaign_id" value="<?php echo (isset($campaign_details) && $campaign_details != '')?esc_attr($campaign_details->compaignId):""; ?>" />
@@ -292,7 +283,7 @@ class AddCampaign {
292
  }
293
  /*function selectCountry() {
294
  var sales_country = document.getElementById('sales_country').value;
295
- var customer_id = "<?php echo $this->currentCustomerId; ?>";
296
  jQuery('#feed-spinner').css('display', 'block');
297
  jQuery.post(
298
  tvc_ajax_url,
@@ -324,24 +315,17 @@ class AddCampaign {
324
  }
325
  public function success_message($customerId) {
326
  $class = 'notice notice-success';
327
- $message = esc_html__($customerId . ' Set as default Ads Account ID.', 'sample-text-domain');
328
  printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr($class), esc_html($message));
329
  }
330
 
331
  public function success_messageV2($campaign_name, $status) {
332
  $active = ($status == true) ? 'active' : 'inactive';
333
- $class = 'notice notice-success';
334
- //$message = esc_html__($campaign_name . ' Campaign Set as '.$active.'.', 'sample-text-domain');
335
- // return '<div class='.$class.'><p>'.$campaign_name.' Campaign Set as '.$active.'</p></div>';
336
  $message = $campaign_name . ' set as ' . $active;
337
  return $message;
338
  }
339
 
340
  public function success_deleteMessage($campaign_name) {
341
- //$active = ($status == true) ? 'active' : 'inactive';
342
- $class = 'notice notice-success';
343
- //$message = esc_html__($campaign_name . ' Campaign Set as '.$active.'.', 'sample-text-domain');
344
- // return '<div class='.$class.'><p>'.$campaign_name.' Campaign Set as '.$active.'</p></div>';
345
  $message = $campaign_name . ' is deleted successfully';
346
  return $message;
347
  }
61
  }
62
 
63
  $defaultCountry = $this->TVC_Admin_Helper->get_woo_country();
 
 
 
 
 
 
 
 
 
64
 
65
  if (isset($_POST['create_campaign'])) {
66
+ $campaign_name = isset($_POST['campaign_name'])?sanitize_text_field($_POST['campaign_name']):"";
67
+ $campaign_budget = isset($_POST['campaign_budget'])?sanitize_text_field($_POST['campaign_budget']):"";
68
+ $sales_country = isset($_POST['sales_country'])?sanitize_text_field($_POST['sales_country']):"";
69
+ $all_products = isset($_POST['all_products'])?sanitize_text_field($_POST['all_products']):"";
70
+ $category_id = isset($_POST['dimension'])?sanitize_text_field($_POST['dimension']):"";
71
+ $category_level = isset($_POST['category_level'])?sanitize_text_field($_POST['category_level']):"";
72
 
73
  $campaign = $api_obj->createCampaign($campaign_name, $campaign_budget, $sales_country, $all_products, $category_id, $category_level);
74
  if(isset($campaign->errors) && !empty($campaign->errors)){
80
  $message = esc_html__('Smart Shopping Campaign Created Successfully '.$campaign_neme, 'conversios');
81
  }
82
  }else if (isset($_POST['update_campaign'])) {
83
+ $campaign_name = isset($_POST['campaign_name'])?sanitize_text_field($_POST['campaign_name']):"";
84
+ $campaign_budget = isset($_POST['campaign_budget'])?sanitize_text_field($_POST['campaign_budget']):"";
85
+ $campaign_id = isset($_POST['campaign_id'])?sanitize_text_field($_POST['campaign_id']):"";
86
+ $budget_id = isset($_POST['budget_id'])?sanitize_text_field($_POST['budget_id']):"";
87
+ $sales_country = isset($_POST['sales_country'])?sanitize_text_field($_POST['sales_country']):"";
88
+ $all_products = isset($_POST['all_products'])?sanitize_text_field($_POST['all_products']):"";
89
+ $ad_group_id = isset($_POST['ad_group_id'])?sanitize_text_field($_POST['ad_group_id']):"";
90
+ $ad_group_resource_name = isset($_POST['ad_group_resource_name'])?sanitize_text_field($_POST['ad_group_resource_name']):"";
91
+ $category_id = isset($_POST['dimension']) ? sanitize_text_field($_POST['dimension']):"";
92
+ $category_level = isset($_POST['category_level'])?sanitize_text_field($_POST['category_level']):"";
93
 
94
  $campaign = $api_obj->updateCampaign($campaign_name, $campaign_budget, $campaign_id, $budget_id, $sales_country, $all_products, $category_id, $category_level, $ad_group_id, $ad_group_resource_name);
95
  if (isset($campaign->errors) && !empty($campaign->errors)) {
206
  <input type="text" class="form-group col-md-6" name="campaign_name" value="<?php echo (isset($campaign_details) && $campaign_details != '')?esc_attr($campaign_details->compaignName):""; ?>" id="campaign-name" required>
207
  </div>
208
  <div class="col-md-12 row">
209
+ <label for="campaign-budget" class="form-group col-md-4 mt-2 mb-0 text-left"><span class="font-weight-bold"><?php esc_html_e("Daily Campaign Budget","conversios"); ?> (<?php echo esc_attr($currency); ?>):</span> <p style="text-align:left;font-size: 11px;"><?php esc_html_e("Only pay if someone clicks your ad. Recommended minimum budget of","conversios"); ?> <?php echo esc_attr($currency); ?>5 per day.</p></label>
210
  <input type="number" class="form-group col-md-6" name="campaign_budget" id="campaign-budget" value="<?php echo (isset($campaign_details) && $campaign_details != '')?esc_attr($campaign_details->dailyBudget):""; ?>" style="height: 35px;" required>
211
  </div>
212
  <input type="hidden" name="campaign_id" value="<?php echo (isset($campaign_details) && $campaign_details != '')?esc_attr($campaign_details->compaignId):""; ?>" />
283
  }
284
  /*function selectCountry() {
285
  var sales_country = document.getElementById('sales_country').value;
286
+ var customer_id = "<?php //echo esc_attr($this->currentCustomerId); ?>";
287
  jQuery('#feed-spinner').css('display', 'block');
288
  jQuery.post(
289
  tvc_ajax_url,
315
  }
316
  public function success_message($customerId) {
317
  $class = 'notice notice-success';
318
+ $message = esc_html__($customerId . ' Set as default Ads Account ID.', 'conversios');
319
  printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr($class), esc_html($message));
320
  }
321
 
322
  public function success_messageV2($campaign_name, $status) {
323
  $active = ($status == true) ? 'active' : 'inactive';
 
 
 
324
  $message = $campaign_name . ' set as ' . $active;
325
  return $message;
326
  }
327
 
328
  public function success_deleteMessage($campaign_name) {
 
 
 
 
329
  $message = $campaign_name . ' is deleted successfully';
330
  return $message;
331
  }
includes/setup/class-conversios-dashboard.php CHANGED
@@ -32,7 +32,7 @@ if ( ! class_exists( 'Conversios_Dashboard' ) ) {
32
 
33
  $this->TVC_Admin_Helper = new TVC_Admin_Helper();
34
  $this->CustomApi = new CustomApi();
35
- $this->connect_url = esc_url_raw($this->TVC_Admin_Helper->get_custom_connect_url(admin_url().'admin.php?page=conversios'));
36
  $this->subscription_id = $this->TVC_Admin_Helper->get_subscriptionId();
37
  // update API data to DB while expired token
38
 
@@ -54,14 +54,14 @@ if ( ! class_exists( 'Conversios_Dashboard' ) ) {
54
  }
55
 
56
  if( $this->subscription_id != "" ){
57
- $this->g_mail = get_option('ee_customer_gmail');
58
- $this->ga_traking_type = esc_attr($this->subscription_data->tracking_option); // UA,GA4,BOTH
59
- $this->ga3_property_id = esc_attr($this->subscription_data->property_id); // GA3
60
- $this->ga3_ua_analytic_account_id = esc_attr($this->subscription_data->ua_analytic_account_id);
61
  if($this->is_refresh_token_expire == false){
62
  $this->set_ga3_view_id_and_ga3_currency();
63
  }
64
- $this->ga4_measurement_id = esc_attr($this->subscription_data->measurement_id); //GA4 ID
65
  }else{
66
  wp_redirect("admin.php?page=conversios_onboarding");
67
  exit;
@@ -84,24 +84,23 @@ if ( ! class_exists( 'Conversios_Dashboard' ) ) {
84
  }
85
 
86
  public function set_ga3_view_id_and_ga3_currency(){
87
- //$this->view_id = get_option('ee_ga_view_id');
88
  if(isset($this->subscription_data->view_id) && isset($this->subscription_data->analytics_currency) && $this->subscription_data->view_id!="" && $this->subscription_data->analytics_currency!=""){
89
- $this->ga3_view_id = esc_attr($this->subscription_data->view_id);
90
- $this->ga_currency = esc_attr($this->subscription_data->analytics_currency);
91
  $this->ga_currency_symbols = $this->TVC_Admin_Helper->get_currency_symbols($this->ga_currency);
92
 
93
  }else{
94
  $data = array(
95
- "subscription_id"=>esc_attr($this->subscription_id),
96
- "property_id"=>esc_attr($this->ga3_property_id),
97
- "ua_analytic_account_id"=>esc_attr($this->ga3_ua_analytic_account_id)
98
  );
99
  $api_rs = $this->CustomApi->get_analytics_viewid_currency($data);
100
  if (isset($api_rs->error) && $api_rs->error == '') {
101
  if(isset($api_rs->data) && $api_rs->data != ""){
102
  $data = json_decode($api_rs->data);
103
- $this->ga3_view_id = esc_attr($data->view_id);
104
- $this->ga_currency = esc_attr($data->analytics_currency);
105
  $this->ga_currency_symbols = $this->TVC_Admin_Helper->get_currency_symbols($this->ga_currency);
106
  $this->is_need_to_update_api_data_wp_db = true;
107
  }
@@ -156,7 +155,7 @@ if ( ! class_exists( 'Conversios_Dashboard' ) ) {
156
  view_id :'<?php echo esc_attr($this->ga3_view_id); ?>',
157
  ga4_property_id:'<?php echo esc_attr($this->ga4_property_id); ?>',
158
  ga_currency :'<?php echo esc_attr($this->ga_currency); ?>',
159
- plugin_url:'<?php echo ENHANCAD_PLUGIN_URL; ?>',
160
  start_date :$.trim(start_date.replace(/\//g,"-")),
161
  end_date :$.trim(end_date.replace(/\//g,"-")),
162
  g_mail:g_mail,
@@ -251,7 +250,7 @@ if ( ! class_exists( 'Conversios_Dashboard' ) ) {
251
  const systemZoom = width / window.screen.availWidth;
252
  const left = (width - w) / 2 / systemZoom + dualScreenLeft;
253
  const top = (height - h) / 2 / systemZoom + dualScreenTop;
254
- var url ='<?php echo esc_attr($this->connect_url); ?>';
255
  url = url.replace(/&amp;/g, '&');
256
  const newWindow = window.open(url, "newwindow", config= `scrollbars=yes,
257
  width=${w / systemZoom},
@@ -309,7 +308,7 @@ if ( ! class_exists( 'Conversios_Dashboard' ) ) {
309
  <div class="careticn"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/caret-down.png'); ?>" alt="" /></div>
310
  </div>
311
  <?php } else{ ?>
312
- <div class="dshtpdaterange <?php echo $this->add_upgrdsbrs_btn_calss('download_pdf'); ?>">
313
  <div class="dateclndicn">
314
  <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/claendar-icon.png'); ?>" alt="" />
315
  </div>
@@ -562,7 +561,7 @@ if ( ! class_exists( 'Conversios_Dashboard' ) ) {
562
  <div class="row dsh-reprttop">
563
  <div class="dshrprttp-left">
564
  <h4><?php esc_html_e("Product Performance Report","conversios"); ?></h4>
565
- <a href="#" class="viewallbtn <?php echo $this->add_upgrdsbrs_btn_calss('download_pdf'); ?>"><?php esc_html_e("View all","conversios"); ?> <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-right-arrow.png'); ?>" alt="" /></a>
566
  </div>
567
  </div>
568
  <div class="dashtablewrp product_performance_report" id="product_performance_report">
@@ -574,9 +573,9 @@ if ( ! class_exists( 'Conversios_Dashboard' ) ) {
574
  <th><?php esc_html_e("Added to Cart","conversios"); ?></th>
575
  <th><?php esc_html_e("Orders","conversios"); ?></th>
576
  <th><?php esc_html_e("Qty","conversios"); ?></th>
577
- <th><?php esc_html_e("Revenue","conversios"); ?> (<?php echo $this->ga_currency_symbols; ?>)</th>
578
- <th><?php esc_html_e("Avg Price","conversios"); ?> (<?php echo $this->ga_currency_symbols; ?>)</th>
579
- <th><?php esc_html_e("Refund Amount","conversios"); ?> (<?php echo $this->ga_currency_symbols; ?>)</th>
580
  <th><?php esc_html_e("Cart to details (%)","conversios"); ?></th>
581
  <th><?php esc_html_e("Buy to details (%)","conversios"); ?></th>
582
  </tr>
@@ -621,7 +620,7 @@ if ( ! class_exists( 'Conversios_Dashboard' ) ) {
621
  <div class="row dsh-reprttop">
622
  <div class="dshrprttp-left">
623
  <h4><?php esc_html_e("Source/Medium Performance Report","conversios"); ?></h4>
624
- <a href="" class="viewallbtn <?php echo $this->add_upgrdsbrs_btn_calss('download_pdf'); ?>"><?php esc_html_e("View all","conversios"); ?> <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-right-arrow.png'); ?>" alt="" /></a>
625
  </div>
626
  </div>
627
  <div class="dashtablewrp medium_performance_report" id="medium_performance_report">
@@ -630,9 +629,9 @@ if ( ! class_exists( 'Conversios_Dashboard' ) ) {
630
  <tr>
631
  <th class="prdnm-cell"><?php esc_html_e("Source/Medium","conversios"); ?></th>
632
  <th><?php esc_html_e("Conversion (%)","conversios"); ?></th>
633
- <th><?php esc_html_e("Revenue","conversios"); ?> (<?php echo $this->ga_currency_symbols; ?>)</th>
634
  <th><?php esc_html_e("Total transactions","conversios"); ?></th>
635
- <th><?php esc_html_e("Avg Order value","conversios"); ?> (<?php echo $this->ga_currency_symbols; ?>)</th>
636
  <th><?php esc_html_e("Added to carts","conversios"); ?></th>
637
  <th><?php esc_html_e("removed from cart","conversios"); ?></th>
638
  <th><?php esc_html_e("Product views","conversios"); ?></th>
32
 
33
  $this->TVC_Admin_Helper = new TVC_Admin_Helper();
34
  $this->CustomApi = new CustomApi();
35
+ $this->connect_url = $this->TVC_Admin_Helper->get_custom_connect_url(admin_url().'admin.php?page=conversios');
36
  $this->subscription_id = $this->TVC_Admin_Helper->get_subscriptionId();
37
  // update API data to DB while expired token
38
 
54
  }
55
 
56
  if( $this->subscription_id != "" ){
57
+ $this->g_mail = sanitize_email(get_option('ee_customer_gmail'));
58
+ $this->ga_traking_type = $this->subscription_data->tracking_option; // UA,GA4,BOTH
59
+ $this->ga3_property_id = $this->subscription_data->property_id; // GA3
60
+ $this->ga3_ua_analytic_account_id = $this->subscription_data->ua_analytic_account_id;
61
  if($this->is_refresh_token_expire == false){
62
  $this->set_ga3_view_id_and_ga3_currency();
63
  }
64
+ $this->ga4_measurement_id = $this->subscription_data->measurement_id; //GA4 ID
65
  }else{
66
  wp_redirect("admin.php?page=conversios_onboarding");
67
  exit;
84
  }
85
 
86
  public function set_ga3_view_id_and_ga3_currency(){
 
87
  if(isset($this->subscription_data->view_id) && isset($this->subscription_data->analytics_currency) && $this->subscription_data->view_id!="" && $this->subscription_data->analytics_currency!=""){
88
+ $this->ga3_view_id = $this->subscription_data->view_id;
89
+ $this->ga_currency = $this->subscription_data->analytics_currency;
90
  $this->ga_currency_symbols = $this->TVC_Admin_Helper->get_currency_symbols($this->ga_currency);
91
 
92
  }else{
93
  $data = array(
94
+ "subscription_id" => sanitize_text_field($this->subscription_id),
95
+ "property_id" => sanitize_text_field($this->ga3_property_id),
96
+ "ua_analytic_account_id" => sanitize_text_field($this->ga3_ua_analytic_account_id)
97
  );
98
  $api_rs = $this->CustomApi->get_analytics_viewid_currency($data);
99
  if (isset($api_rs->error) && $api_rs->error == '') {
100
  if(isset($api_rs->data) && $api_rs->data != ""){
101
  $data = json_decode($api_rs->data);
102
+ $this->ga3_view_id = $data->view_id;
103
+ $this->ga_currency = $data->analytics_currency;
104
  $this->ga_currency_symbols = $this->TVC_Admin_Helper->get_currency_symbols($this->ga_currency);
105
  $this->is_need_to_update_api_data_wp_db = true;
106
  }
155
  view_id :'<?php echo esc_attr($this->ga3_view_id); ?>',
156
  ga4_property_id:'<?php echo esc_attr($this->ga4_property_id); ?>',
157
  ga_currency :'<?php echo esc_attr($this->ga_currency); ?>',
158
+ plugin_url:'<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL); ?>',
159
  start_date :$.trim(start_date.replace(/\//g,"-")),
160
  end_date :$.trim(end_date.replace(/\//g,"-")),
161
  g_mail:g_mail,
250
  const systemZoom = width / window.screen.availWidth;
251
  const left = (width - w) / 2 / systemZoom + dualScreenLeft;
252
  const top = (height - h) / 2 / systemZoom + dualScreenTop;
253
+ var url ='<?php echo esc_url_raw($this->connect_url); ?>';
254
  url = url.replace(/&amp;/g, '&');
255
  const newWindow = window.open(url, "newwindow", config= `scrollbars=yes,
256
  width=${w / systemZoom},
308
  <div class="careticn"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/caret-down.png'); ?>" alt="" /></div>
309
  </div>
310
  <?php } else{ ?>
311
+ <div class="dshtpdaterange <?php echo esc_attr($this->add_upgrdsbrs_btn_calss('download_pdf')); ?>">
312
  <div class="dateclndicn">
313
  <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/claendar-icon.png'); ?>" alt="" />
314
  </div>
561
  <div class="row dsh-reprttop">
562
  <div class="dshrprttp-left">
563
  <h4><?php esc_html_e("Product Performance Report","conversios"); ?></h4>
564
+ <a href="#" class="viewallbtn <?php echo esc_attr($this->add_upgrdsbrs_btn_calss('download_pdf')); ?>"><?php esc_html_e("View all","conversios"); ?> <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-right-arrow.png'); ?>" alt="" /></a>
565
  </div>
566
  </div>
567
  <div class="dashtablewrp product_performance_report" id="product_performance_report">
573
  <th><?php esc_html_e("Added to Cart","conversios"); ?></th>
574
  <th><?php esc_html_e("Orders","conversios"); ?></th>
575
  <th><?php esc_html_e("Qty","conversios"); ?></th>
576
+ <th><?php esc_html_e("Revenue","conversios"); ?> (<?php echo esc_attr($this->ga_currency_symbols); ?>)</th>
577
+ <th><?php esc_html_e("Avg Price","conversios"); ?> (<?php echo esc_attr($this->ga_currency_symbols); ?>)</th>
578
+ <th><?php esc_html_e("Refund Amount","conversios"); ?> (<?php echo esc_attr($this->ga_currency_symbols); ?>)</th>
579
  <th><?php esc_html_e("Cart to details (%)","conversios"); ?></th>
580
  <th><?php esc_html_e("Buy to details (%)","conversios"); ?></th>
581
  </tr>
620
  <div class="row dsh-reprttop">
621
  <div class="dshrprttp-left">
622
  <h4><?php esc_html_e("Source/Medium Performance Report","conversios"); ?></h4>
623
+ <a href="" class="viewallbtn <?php echo esc_attr($this->add_upgrdsbrs_btn_calss('download_pdf')); ?>"><?php esc_html_e("View all","conversios"); ?> <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-right-arrow.png'); ?>" alt="" /></a>
624
  </div>
625
  </div>
626
  <div class="dashtablewrp medium_performance_report" id="medium_performance_report">
629
  <tr>
630
  <th class="prdnm-cell"><?php esc_html_e("Source/Medium","conversios"); ?></th>
631
  <th><?php esc_html_e("Conversion (%)","conversios"); ?></th>
632
+ <th><?php esc_html_e("Revenue","conversios"); ?> (<?php echo esc_attr($this->ga_currency_symbols); ?>)</th>
633
  <th><?php esc_html_e("Total transactions","conversios"); ?></th>
634
+ <th><?php esc_html_e("Avg Order value","conversios"); ?> (<?php echo esc_attr($this->ga_currency_symbols); ?>)</th>
635
  <th><?php esc_html_e("Added to carts","conversios"); ?></th>
636
  <th><?php esc_html_e("removed from cart","conversios"); ?></th>
637
  <th><?php esc_html_e("Product views","conversios"); ?></th>
includes/setup/class-tvc-product-sync-helper.php CHANGED
@@ -104,10 +104,10 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
104
  $postObj = (object) array_merge((array) get_post($postvalue->w_product_id), (array) $postmeta);
105
 
106
  $product = array(
107
- 'offer_id'=>esc_attr($postvalue->w_product_id),
108
  'channel'=>'online',
109
- 'link'=>get_permalink($postvalue->w_product_id),
110
- 'google_product_category'=>esc_attr($postvalue->g_cat_id)
111
  );
112
 
113
  $temp_product=array();
@@ -125,14 +125,14 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
125
  foreach ($fixed_att_select_list as $fixed_key) {
126
  if(isset($formArray[$fixed_key]) && $formArray[$fixed_key] != "" ){
127
  if($fixed_key == "shipping" && $formArray[$fixed_key] != ""){
128
- $temp_product[$fixed_key]['price']['value'] = $formArray[$fixed_key];
129
- $temp_product[$fixed_key]['price']['currency'] = $tvc_currency;
130
- $temp_product[$fixed_key]['country'] = $formArray['target_country'];
131
  }else if($fixed_key == "tax" && $formArray[$fixed_key] != ""){
132
- $temp_product['taxes']['rate'] = $formArray[$fixed_key];
133
- $temp_product['taxes']['country'] = $formArray['target_country'];
134
  }else if( $formArray[$fixed_key] != ""){
135
- $temp_product[$fixed_key] = $formArray[$fixed_key];
136
  }
137
  }
138
  unset($formArray[$fixed_key]);
@@ -154,9 +154,9 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
154
  unset($product['customAttributes']);
155
  $postmeta_var = (object)$this->TVC_Admin_Helper->tvc_get_post_meta($variation_id);
156
  $formArray_val = $formArray['title'];
157
- $product['title'] = (isset($postObj->$formArray_val))?$postObj->$formArray_val:get_the_title($postvalue->w_product_id);
158
  $tvc_temp_desc_key = $formArray['description'];
159
- $product['description'] = ( $variation_description != "")?sanitize_text_field($variation_description):$postObj->$tvc_temp_desc_key;
160
  $product['offer_id'] = $variation_id;
161
  $product['id'] = $variation_id;
162
  $product['item_group_id'] = $postvalue->w_product_id;
@@ -165,7 +165,7 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
165
  $product['productTypes'] = $productTypes;
166
  }
167
  $image_id = $variation->get_image_id();
168
- $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
169
  $variation_attributes = $variation->get_variation_attributes();
170
 
171
  if(!empty($variation_attributes) ){
@@ -177,7 +177,7 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
177
  $product['sizes'] = $va_value;
178
  }else{
179
  $va_key = str_replace("attribute", "", $va_key);
180
- $product['customAttributes'][] = array("name"=>$va_key, "value"=>$va_value);
181
  }
182
  }
183
  }
@@ -196,7 +196,7 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
196
  unset($product[$key]);
197
  }
198
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
199
- $product[$key]['currency'] = $tvc_currency;
200
  }else{
201
  $skipProducts[$postmeta_var->ID] = $postmeta_var;
202
  }
@@ -209,7 +209,7 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
209
  unset($product[$key]);
210
  }
211
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
212
- $product[$key]['currency'] = $tvc_currency;
213
  }
214
  }else if($key == 'availability'){
215
  $tvc_find = array("instock","outofstock","onbackorder");
@@ -217,24 +217,24 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
217
  if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
218
  $stock_status = $postmeta_var->$value;
219
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
220
- $product[$key] = $stock_status;
221
  }else{
222
  $stock_status = $postmeta_var->_stock_status;
223
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
224
- $product[$key] = $stock_status;
225
  }
226
  }else if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
227
- $product[$key] = $postmeta_var->$value;
228
  }else if(in_array($key, array("brand")) ){ //list of cutom option added
229
  $yith_product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
230
  if($yith_product_brand != ""){
231
- $product[$key] = $yith_product_brand;
232
  }
233
  }
234
  }
235
  $item = [
236
- 'merchant_id' => esc_attr($merchantId),
237
- 'batch_id' => ++$batchId,
238
  'method' => 'insert',
239
  'product' => $product
240
  ];
@@ -245,8 +245,7 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
245
  }else{
246
  //simpleproduct:
247
  $image_id = $prd->get_image_id();
248
- $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
249
- //echo $postvalue->w_product_id;
250
  $productTypes = $this->get_product_category($postvalue->w_product_id);
251
  if(!empty($productTypes)){
252
  $product['productTypes'] = $productTypes;
@@ -264,7 +263,7 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
264
  $product[$key]['value'] = $postObj->_sale_price;
265
  }
266
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
267
- $product[$key]['currency'] = $tvc_currency;
268
  }else{
269
  $skipProducts[$postObj->ID] = $postObj;
270
  }
@@ -275,7 +274,7 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
275
  $product[$key]['value'] = $postObj->_sale_price;
276
  }
277
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
278
- $product[$key]['currency'] = $tvc_currency;
279
  }
280
  }else if($key == 'availability'){
281
  $tvc_find = array("instock","outofstock","onbackorder");
@@ -283,25 +282,24 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
283
  if(isset($postObj->$value) && $postObj->$value != ""){
284
  $stock_status = $postObj->$value;
285
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
286
- $product[$key] = $stock_status;
287
  }else{
288
  $stock_status = $postObj->_stock_status;
289
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
290
- $product[$key] = $stock_status;
291
  }
292
  }else if(isset($postObj->$value) && $postObj->$value != ""){
293
- //echo $key."==".$postObj->$value."<br>";
294
  $product[$key] = $postObj->$value;
295
  }else if(in_array($key, array("brand")) ){ //list of cutom option added
296
  $yith_product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
297
  if($yith_product_brand != ""){
298
- $product[$key] = $yith_product_brand;
299
  }
300
  }
301
  }
302
  $item = [
303
- 'merchant_id' => esc_attr($merchantId),
304
- 'batch_id' => ++$batchId,
305
  'method' => 'insert',
306
  'product' => $product
307
  ];
@@ -323,15 +321,15 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
323
  //$count = 0;
324
  $pre_last_sync_product_id = sanitize_text_field($last_sync_product_id);
325
  if( $product_count > 0 ){
326
- $tvc_currency = esc_attr($this->TVC_Admin_Helper->get_woo_currency());
327
- $merchantId = esc_attr($this->merchantId);
328
- $customerId = esc_attr($this->currentCustomerId);
329
- $accountId = esc_attr($this->accountId);
330
- $subscriptionId = esc_attr($this->subscriptionId);
331
- $last_sync_product_id =esc_attr(( $last_sync_product_id > 0)?$last_sync_product_id:0);
332
  global $wpdb;
333
  $tablename = $wpdb->prefix .'ee_prouct_pre_sync_data';
334
- $sql = "select * from ".esc_sql($tablename)." where id > ".esc_sql($last_sync_product_id)." LIMIT ".$product_batch_size;
335
  $products = $wpdb->get_results($sql, OBJECT);
336
  $entries = [];
337
  if(!empty($products)){
@@ -339,9 +337,9 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
339
  if(!empty($p_map_attribute) && isset($p_map_attribute['items']) && !empty($p_map_attribute['items'])){
340
  // call product sync API
341
  $data = [
342
- 'merchant_id' => esc_attr($accountId),
343
- 'account_id' => esc_attr($merchantId),
344
- 'subscription_id' => esc_attr($subscriptionId),
345
  'entries' => $p_map_attribute['items']
346
  ];
347
  $response = $CustomApi->products_sync($data);
@@ -350,14 +348,14 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
350
  if($response->error== false){
351
  //"data"=> $p_map_attribute['items']
352
  $products_sync =count($products);
353
- return array('error'=> false, 'products_sync' => $products_sync, 'skip_products' => $p_map_attribute['skip_products'], 'last_sync_product_id'=>$last_sync_product_id);
354
  }else{
355
- return array('error'=> true, 'message' => $response->message );
356
  }
357
  // End call product sync API
358
  $sync_product_ids = (isset($p_map_attribute['product_ids']))?$p_map_attribute['product_ids']:"";
359
  }else if(!empty($p_map_attribute['message'])){
360
- return array('error'=> true, 'message' => $p_map_attribute['message'] );
361
  }
362
  }
363
  }
@@ -375,7 +373,7 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
375
 
376
  ob_start();
377
  ?>
378
- <div class="modal fade popup-modal create-campa overlay" id="syncProduct" data-backdrop="false">
379
  <div class="modal-dialog modal-dialog-centered">
380
  <div class="modal-content">
381
  <div class="modal-body">
@@ -499,10 +497,16 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
499
  public function add_product_sync_script(){
500
  $shop_categories_list = $this->TVC_Admin_Helper->get_tvc_product_cat_list();
501
  ?>
502
- <script>
503
- $(document).ready(function() {
504
- $(".select2").select2();
505
- });
 
 
 
 
 
 
506
  $(".tab-wizard").steps({
507
  headerTag: "h5",
508
  bodyTag: "section",
@@ -537,7 +541,7 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
537
  jQuery(".field-required").each(function() {
538
  if($(this).val()==0 && valid){
539
  valid=false;
540
- $(this).select2('focus');
541
  }
542
  });
543
  if(!valid){
@@ -623,7 +627,7 @@ if ( ! class_exists( 'TVCProductSyncHelper' ) ) {
623
  message = message + "\n Because of pricing issues, " + response.sync_progressive_data.skip_products.length + " products did not sync.";
624
  }
625
  tvc_helper.tvc_alert("success","",message);
626
- window.location.replace("<?php echo $this->site_url.'sync_product_page'; ?>");
627
  }else {
628
  tvc_helper.tvc_alert("error","",response.api_rs.message);
629
  }
104
  $postObj = (object) array_merge((array) get_post($postvalue->w_product_id), (array) $postmeta);
105
 
106
  $product = array(
107
+ 'offer_id'=>sanitize_text_field($postvalue->w_product_id),
108
  'channel'=>'online',
109
+ 'link'=> esc_url_raw(get_permalink($postvalue->w_product_id)),
110
+ 'google_product_category'=>sanitize_text_field($postvalue->g_cat_id)
111
  );
112
 
113
  $temp_product=array();
125
  foreach ($fixed_att_select_list as $fixed_key) {
126
  if(isset($formArray[$fixed_key]) && $formArray[$fixed_key] != "" ){
127
  if($fixed_key == "shipping" && $formArray[$fixed_key] != ""){
128
+ $temp_product[$fixed_key]['price']['value'] = sanitize_text_field($formArray[$fixed_key]);
129
+ $temp_product[$fixed_key]['price']['currency'] = sanitize_text_field($tvc_currency);
130
+ $temp_product[$fixed_key]['country'] = sanitize_text_field($formArray['target_country']);
131
  }else if($fixed_key == "tax" && $formArray[$fixed_key] != ""){
132
+ $temp_product['taxes']['rate'] = sanitize_text_field($formArray[$fixed_key]);
133
+ $temp_product['taxes']['country'] = sanitize_text_field($formArray['target_country']);
134
  }else if( $formArray[$fixed_key] != ""){
135
+ $temp_product[$fixed_key] = sanitize_text_field($formArray[$fixed_key]);
136
  }
137
  }
138
  unset($formArray[$fixed_key]);
154
  unset($product['customAttributes']);
155
  $postmeta_var = (object)$this->TVC_Admin_Helper->tvc_get_post_meta($variation_id);
156
  $formArray_val = $formArray['title'];
157
+ $product['title'] = (isset($postObj->$formArray_val))?sanitize_text_field($postObj->$formArray_val):get_the_title($postvalue->w_product_id);
158
  $tvc_temp_desc_key = $formArray['description'];
159
+ $product['description'] = ( $variation_description != "")?sanitize_text_field($variation_description):sanitize_text_field($postObj->$tvc_temp_desc_key);
160
  $product['offer_id'] = $variation_id;
161
  $product['id'] = $variation_id;
162
  $product['item_group_id'] = $postvalue->w_product_id;
165
  $product['productTypes'] = $productTypes;
166
  }
167
  $image_id = $variation->get_image_id();
168
+ $product['image_link'] = esc_url_raw(wp_get_attachment_image_url($image_id, 'full'));
169
  $variation_attributes = $variation->get_variation_attributes();
170
 
171
  if(!empty($variation_attributes) ){
177
  $product['sizes'] = $va_value;
178
  }else{
179
  $va_key = str_replace("attribute", "", $va_key);
180
+ $product['customAttributes'][] = array("name"=>$va_key, "value" => $va_value);
181
  }
182
  }
183
  }
196
  unset($product[$key]);
197
  }
198
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
199
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
200
  }else{
201
  $skipProducts[$postmeta_var->ID] = $postmeta_var;
202
  }
209
  unset($product[$key]);
210
  }
211
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
212
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
213
  }
214
  }else if($key == 'availability'){
215
  $tvc_find = array("instock","outofstock","onbackorder");
217
  if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
218
  $stock_status = $postmeta_var->$value;
219
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
220
+ $product[$key] = sanitize_text_field($stock_status);
221
  }else{
222
  $stock_status = $postmeta_var->_stock_status;
223
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
224
+ $product[$key] = sanitize_text_field($stock_status);
225
  }
226
  }else if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
227
+ $product[$key] = sanitize_text_field($postmeta_var->$value);
228
  }else if(in_array($key, array("brand")) ){ //list of cutom option added
229
  $yith_product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
230
  if($yith_product_brand != ""){
231
+ $product[$key] = sanitize_text_field($yith_product_brand);
232
  }
233
  }
234
  }
235
  $item = [
236
+ 'merchant_id' => sanitize_text_field($merchantId),
237
+ 'batch_id' => sanitize_text_field(++$batchId),
238
  'method' => 'insert',
239
  'product' => $product
240
  ];
245
  }else{
246
  //simpleproduct:
247
  $image_id = $prd->get_image_id();
248
+ $product['image_link'] = esc_url_raw(wp_get_attachment_image_url($image_id, 'full'));
 
249
  $productTypes = $this->get_product_category($postvalue->w_product_id);
250
  if(!empty($productTypes)){
251
  $product['productTypes'] = $productTypes;
263
  $product[$key]['value'] = $postObj->_sale_price;
264
  }
265
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
266
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
267
  }else{
268
  $skipProducts[$postObj->ID] = $postObj;
269
  }
274
  $product[$key]['value'] = $postObj->_sale_price;
275
  }
276
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
277
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
278
  }
279
  }else if($key == 'availability'){
280
  $tvc_find = array("instock","outofstock","onbackorder");
282
  if(isset($postObj->$value) && $postObj->$value != ""){
283
  $stock_status = $postObj->$value;
284
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
285
+ $product[$key] = sanitize_text_field($stock_status);
286
  }else{
287
  $stock_status = $postObj->_stock_status;
288
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
289
+ $product[$key] = sanitize_text_field($stock_status);
290
  }
291
  }else if(isset($postObj->$value) && $postObj->$value != ""){
 
292
  $product[$key] = $postObj->$value;
293
  }else if(in_array($key, array("brand")) ){ //list of cutom option added
294
  $yith_product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
295
  if($yith_product_brand != ""){
296
+ $product[$key] = sanitize_text_field($yith_product_brand);
297
  }
298
  }
299
  }
300
  $item = [
301
+ 'merchant_id' => sanitize_text_field($merchantId),
302
+ 'batch_id' => sanitize_text_field(++$batchId),
303
  'method' => 'insert',
304
  'product' => $product
305
  ];
321
  //$count = 0;
322
  $pre_last_sync_product_id = sanitize_text_field($last_sync_product_id);
323
  if( $product_count > 0 ){
324
+ $tvc_currency = sanitize_text_field($this->TVC_Admin_Helper->get_woo_currency());
325
+ $merchantId = sanitize_text_field($this->merchantId);
326
+ $customerId = sanitize_text_field($this->currentCustomerId);
327
+ $accountId = sanitize_text_field($this->accountId);
328
+ $subscriptionId = sanitize_text_field($this->subscriptionId);
329
+ $last_sync_product_id =sanitize_text_field(( $last_sync_product_id > 0)?$last_sync_product_id:0);
330
  global $wpdb;
331
  $tablename = $wpdb->prefix .'ee_prouct_pre_sync_data';
332
+ $sql = "select * from ".esc_sql($tablename)." where id > ".esc_sql($last_sync_product_id)." LIMIT ".esc_sql($product_batch_size);
333
  $products = $wpdb->get_results($sql, OBJECT);
334
  $entries = [];
335
  if(!empty($products)){
337
  if(!empty($p_map_attribute) && isset($p_map_attribute['items']) && !empty($p_map_attribute['items'])){
338
  // call product sync API
339
  $data = [
340
+ 'merchant_id' => sanitize_text_field($accountId),
341
+ 'account_id' => sanitize_text_field($merchantId),
342
+ 'subscription_id' => sanitize_text_field($subscriptionId),
343
  'entries' => $p_map_attribute['items']
344
  ];
345
  $response = $CustomApi->products_sync($data);
348
  if($response->error== false){
349
  //"data"=> $p_map_attribute['items']
350
  $products_sync =count($products);
351
+ return array('error'=> false, 'products_sync' => $products_sync, 'skip_products' => $p_map_attribute['skip_products'], 'last_sync_product_id' => $last_sync_product_id);
352
  }else{
353
+ return array('error'=> true, 'message' => esc_attr($response->message) );
354
  }
355
  // End call product sync API
356
  $sync_product_ids = (isset($p_map_attribute['product_ids']))?$p_map_attribute['product_ids']:"";
357
  }else if(!empty($p_map_attribute['message'])){
358
+ return array('error'=> true, 'message' => esc_attr($p_map_attribute['message']) );
359
  }
360
  }
361
  }
373
 
374
  ob_start();
375
  ?>
376
+ <div class="modal bs fade popup-modal create-campa overlay" id="syncProduct" data-backdrop="false">
377
  <div class="modal-dialog modal-dialog-centered">
378
  <div class="modal-content">
379
  <div class="modal-body">
497
  public function add_product_sync_script(){
498
  $shop_categories_list = $this->TVC_Admin_Helper->get_tvc_product_cat_list();
499
  ?>
500
+ <script>
501
+ $(document).ready(function() {
502
+ $('#syncProduct .select2').each(function() {
503
+ var $p = $(this).parent();
504
+ $(this).select2({
505
+ dropdownParent: $p
506
+ });
507
+ });
508
+ });
509
+
510
  $(".tab-wizard").steps({
511
  headerTag: "h5",
512
  bodyTag: "section",
541
  jQuery(".field-required").each(function() {
542
  if($(this).val()==0 && valid){
543
  valid=false;
544
+ //$(this).select2('focus');
545
  }
546
  });
547
  if(!valid){
627
  message = message + "\n Because of pricing issues, " + response.sync_progressive_data.skip_products.length + " products did not sync.";
628
  }
629
  tvc_helper.tvc_alert("success","",message);
630
+ window.location.replace("<?php echo esc_url_raw($this->site_url.'sync_product_page'); ?>");
631
  }else {
632
  tvc_helper.tvc_alert("error","",response.api_rs.message);
633
  }
includes/setup/google-shopping-feed-shopping-campaigns.php CHANGED
@@ -260,7 +260,7 @@ class CampaignsConfiguration
260
  <td class="text-center"><?php echo esc_attr($campaign_performance[$i]->conversions); ?></td>
261
  <td class="text-center"><?php echo esc_attr($campaign_performance[$i]->sales); ?></td>
262
  <input type="hidden" value="<?php echo esc_attr($campaign_performance[$i]->compaignName); ?>" id="campaign_name_<?php echo esc_attr($i); ?>" />
263
- <td><a href="<?php echo esc_url_raw($this->site_url.'add_campaign_page&edit='.$campaign_performance[$i]->compaignId); ?>"><?php esc_html_e("Edit","conversios"); ?></a> | <a href="#" onclick="deleteCampaign('<?php echo $this->merchantId; ?>','<?php echo esc_attr($this->currentCustomerId); ?>','<?php echo esc_attr($campaign_performance[$i]->compaignId); ?>','<?php echo $i; ?>')"><?php esc_html_e("Delete","conversios"); ?></a></td>
264
  </tr>
265
  <?php
266
  }
260
  <td class="text-center"><?php echo esc_attr($campaign_performance[$i]->conversions); ?></td>
261
  <td class="text-center"><?php echo esc_attr($campaign_performance[$i]->sales); ?></td>
262
  <input type="hidden" value="<?php echo esc_attr($campaign_performance[$i]->compaignName); ?>" id="campaign_name_<?php echo esc_attr($i); ?>" />
263
+ <td><a href="<?php echo esc_url_raw($this->site_url.'add_campaign_page&edit='.$campaign_performance[$i]->compaignId); ?>"><?php esc_html_e("Edit","conversios"); ?></a> | <a href="#" onclick="deleteCampaign('<?php echo esc_attr($this->merchantId); ?>','<?php echo esc_attr($this->currentCustomerId); ?>','<?php echo esc_attr($campaign_performance[$i]->compaignId); ?>','<?php echo esc_attr($i); ?>')"><?php esc_html_e("Delete","conversios"); ?></a></td>
264
  </tr>
265
  <?php
266
  }
includes/setup/google-shopping-feed-sync-product.php CHANGED
@@ -82,7 +82,7 @@ public function create_form(){
82
  <div class="tvc-api-sunc">
83
  <span>
84
  <?php if($last_api_sync_up){
85
- echo esc_html__("Details last synced at","conversios").$last_api_sync_up;
86
  }else{
87
  echo esc_html__("Refresh sync up","conversios");
88
  }?></span><img id="refresh_api" onclick="call_tvc_api_sync_up();" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/refresh.png'); ?>">
@@ -101,16 +101,16 @@ public function create_form(){
101
  </div>
102
  </div>
103
  <?php
104
- $sync_product_total = esc_attr((property_exists($syncProductStat,"total")) ? $syncProductStat->total : "0");
105
- $sync_product_approved = esc_attr((property_exists($syncProductStat,"approved")) ? $syncProductStat->approved : "0");
106
- $sync_product_disapproved = esc_attr((property_exists($syncProductStat,"disapproved")) ? $syncProductStat->disapproved : "0");
107
- $sync_product_pending = esc_attr((property_exists($syncProductStat,"pending")) ? $syncProductStat->pending : "0"); ?>
108
  <div class="product-card">
109
  <div class="row row-cols-5">
110
  <div class="col">
111
  <div class="card">
112
  <h3 class="pro-count"><?php
113
- echo esc_attr(($woo_product) ? esc_attr($woo_product) : "0"); ?></h3>
114
  <p class="pro-title"><?php esc_html_e("Total Products","conversios"); ?></p>
115
  </div>
116
  </div>
@@ -171,11 +171,11 @@ public function create_form(){
171
  $str = '';
172
  foreach ($p_issues as $key => $issue) {
173
  if ($key <= 2) {
174
- ($key <= 1) ? $str .= esc_attr($issue).", <br>" : "";
175
  }
176
  ($key == 3) ? $str .= "..." : "";
177
  }
178
- echo sanitize_text_field($str);
179
  } else {
180
  echo "---";
181
  }?>
@@ -207,7 +207,7 @@ public function create_form(){
207
  // add product sync popup
208
  echo $this->TVCProductSyncHelper->tvc_product_sync_popup_html();
209
  $is_need_to_domain_claim = false;
210
- if(isset($googleDetail->google_merchant_center_id) && esc_attr($googleDetail->google_merchant_center_id) && esc_attr($this->subscriptionId) != "" && isset($googleDetail->is_domain_claim) && esc_attr($googleDetail->is_domain_claim) == '0'){
211
  $is_need_to_domain_claim = true;
212
  }?>
213
  <script type="text/javascript">
82
  <div class="tvc-api-sunc">
83
  <span>
84
  <?php if($last_api_sync_up){
85
+ echo esc_html__("Details last synced at","conversios").esc_attr($last_api_sync_up);
86
  }else{
87
  echo esc_html__("Refresh sync up","conversios");
88
  }?></span><img id="refresh_api" onclick="call_tvc_api_sync_up();" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/refresh.png'); ?>">
101
  </div>
102
  </div>
103
  <?php
104
+ $sync_product_total = (property_exists($syncProductStat,"total")) ? $syncProductStat->total : "0";
105
+ $sync_product_approved = (property_exists($syncProductStat,"approved")) ? $syncProductStat->approved : "0";
106
+ $sync_product_disapproved = (property_exists($syncProductStat,"disapproved")) ? $syncProductStat->disapproved : "0";
107
+ $sync_product_pending = (property_exists($syncProductStat,"pending")) ? $syncProductStat->pending : "0"; ?>
108
  <div class="product-card">
109
  <div class="row row-cols-5">
110
  <div class="col">
111
  <div class="card">
112
  <h3 class="pro-count"><?php
113
+ echo ($woo_product) ? esc_attr($woo_product) : "0"; ?></h3>
114
  <p class="pro-title"><?php esc_html_e("Total Products","conversios"); ?></p>
115
  </div>
116
  </div>
171
  $str = '';
172
  foreach ($p_issues as $key => $issue) {
173
  if ($key <= 2) {
174
+ ($key <= 1) ? $str .= html_entity_decode(esc_html($issue)).", " : "";
175
  }
176
  ($key == 3) ? $str .= "..." : "";
177
  }
178
+ echo esc_attr($str);
179
  } else {
180
  echo "---";
181
  }?>
207
  // add product sync popup
208
  echo $this->TVCProductSyncHelper->tvc_product_sync_popup_html();
209
  $is_need_to_domain_claim = false;
210
+ if(isset($googleDetail->google_merchant_center_id) && $googleDetail->google_merchant_center_id && $this->subscriptionId != "" && isset($googleDetail->is_domain_claim) && $googleDetail->is_domain_claim == '0'){
211
  $is_need_to_domain_claim = true;
212
  }?>
213
  <script type="text/javascript">
includes/setup/google-shopping-feed.php CHANGED
@@ -140,12 +140,13 @@ class GoogleShoppingFeed {
140
  <?php } ?>
141
  <?php
142
  $last_auto_sync = $this->TVC_Admin_Helper->get_last_auto_sync_product_info();
143
- if(!empty($last_auto_sync) && isset($googleDetail->google_merchant_center_id) && esc_attr($googleDetail->google_merchant_center_id) && esc_attr($this->subscriptionId) != ""){
 
144
  $status = isset($last_auto_sync['status'])?esc_attr($last_auto_sync['status']):0;
145
  $status_text = array("0"=>"Failed","1"=>"Completed");
146
- $create_sync = (isset($last_auto_sync['create_sync']))?esc_attr($last_auto_sync['create_sync']):"";
147
  $create_sync = date($date_formate,strtotime($create_sync));
148
- $next_sync = (isset($last_auto_sync['next_sync']))?esc_attr($last_auto_sync['next_sync']):"";
149
  $next_sync = date($date_formate,strtotime($next_sync));
150
  ?>
151
  <div class="product-auto-sync-details">
@@ -172,8 +173,8 @@ class GoogleShoppingFeed {
172
  </div>
173
  <div class="card-body">
174
  <ul class="list-unstyled"><?php
175
- $is_domain_claim = esc_attr((isset($googleDetail->is_domain_claim))?esc_attr($googleDetail->is_domain_claim):"");
176
- $is_site_verified = esc_attr((isset($googleDetail->is_site_verified))?esc_attr($googleDetail->is_site_verified):"");
177
  echo $this->configuration_list_html("Google merchant center",(isset($googleDetail->google_merchant_center_id))?esc_attr($googleDetail->google_merchant_center_id):"");
178
  if($is_site_verified ==1){
179
  echo $this->configuration_list_html(esc_html__("Site Verified","conversios"), esc_attr($is_site_verified));
@@ -190,7 +191,7 @@ class GoogleShoppingFeed {
190
  </ul>
191
  </div>
192
  <div class="card-footer">
193
- <a href="<?php echo $this->site_url.'gaa_config_page'; ?>" class="btn btn-primary" id="configuration"><?php esc_html_e("Edit","conversios"); ?></a>
194
  </div>
195
  </div>
196
  </div>
@@ -202,11 +203,11 @@ class GoogleShoppingFeed {
202
  <div class="card-body">
203
  <ul class="list-unstyled">
204
  <?php
205
- echo $this->add_list_html(esc_html__("Active products in WooCommerce","conversios"),esc_attr($totalActiveWooProduct))
206
- .$this->add_list_html(esc_html__("Total synced products in Merchant center","conversios"), esc_attr($sync_product_total))
207
- .$this->add_list_html(esc_html__("Approved","conversios"), esc_attr($sync_product_approved))
208
- .$this->add_list_html(esc_html__("Disapproved","conversios"), esc_attr($sync_product_disapproved))
209
- .$this->add_list_html(esc_html__("Pending","conversios"), esc_attr($sync_product_pending));
210
  ?>
211
  </ul>
212
  </div>
@@ -226,12 +227,12 @@ class GoogleShoppingFeed {
226
  <div class="card-body">
227
  <ul class="list-unstyled">
228
  <?php
229
- echo $this->add_list_html(esc_html__("Total campaign","conversios"),esc_attr($totalCampaigns))
230
- .$this->add_list_html(esc_html__("Active campaigns","conversios"),esc_attr($campaignActive))
231
- .$this->add_list_html(esc_html__("Cost","conversios"),esc_attr($campaignCost))
232
- .$this->add_list_html(esc_html__("Click","conversios"),esc_attr($campaignClicks))
233
- .$this->add_list_html(esc_html__("Conversion%","conversios"),esc_attr($campaignConversions))
234
- .$this->add_list_html(esc_html__("Sales","conversios"),esc_attr($campaignSales)); ?>
235
  </ul>
236
  </div>
237
  <?php if (isset($googleDetail->google_ads_id) && esc_attr($googleDetail->google_ads_id) != "") { ?>
@@ -289,7 +290,7 @@ class GoogleShoppingFeed {
289
  });
290
  }
291
  $(document).ready(function() {
292
- var is_need_to_update = "<?php echo $is_need_to_update; ?>";
293
  if(is_need_to_update == 1 || is_need_to_update == true){
294
  call_tvc_api_sync_up();
295
  }
140
  <?php } ?>
141
  <?php
142
  $last_auto_sync = $this->TVC_Admin_Helper->get_last_auto_sync_product_info();
143
+ if(!empty($last_auto_sync) && isset($googleDetail->google_merchant_center_id) && $googleDetail->google_merchant_center_id && $this->subscriptionId != ""){
144
+
145
  $status = isset($last_auto_sync['status'])?esc_attr($last_auto_sync['status']):0;
146
  $status_text = array("0"=>"Failed","1"=>"Completed");
147
+ $create_sync = (isset($last_auto_sync['create_sync']))?$last_auto_sync['create_sync']:"";
148
  $create_sync = date($date_formate,strtotime($create_sync));
149
+ $next_sync = (isset($last_auto_sync['next_sync']))?$last_auto_sync['next_sync']:"";
150
  $next_sync = date($date_formate,strtotime($next_sync));
151
  ?>
152
  <div class="product-auto-sync-details">
173
  </div>
174
  <div class="card-body">
175
  <ul class="list-unstyled"><?php
176
+ $is_domain_claim = (isset($googleDetail->is_domain_claim))?esc_attr($googleDetail->is_domain_claim):"";
177
+ $is_site_verified = (isset($googleDetail->is_site_verified))?esc_attr($googleDetail->is_site_verified):"";
178
  echo $this->configuration_list_html("Google merchant center",(isset($googleDetail->google_merchant_center_id))?esc_attr($googleDetail->google_merchant_center_id):"");
179
  if($is_site_verified ==1){
180
  echo $this->configuration_list_html(esc_html__("Site Verified","conversios"), esc_attr($is_site_verified));
191
  </ul>
192
  </div>
193
  <div class="card-footer">
194
+ <a href="<?php echo esc_url_raw($this->site_url.'gaa_config_page'); ?>" class="btn btn-primary" id="configuration"><?php esc_html_e("Edit","conversios"); ?></a>
195
  </div>
196
  </div>
197
  </div>
203
  <div class="card-body">
204
  <ul class="list-unstyled">
205
  <?php
206
+ echo $this->add_list_html(esc_html__("Active products in WooCommerce","conversios"), $totalActiveWooProduct)
207
+ .$this->add_list_html(esc_html__("Total synced products in Merchant center","conversios"), $sync_product_total)
208
+ .$this->add_list_html(esc_html__("Approved","conversios"), $sync_product_approved)
209
+ .$this->add_list_html(esc_html__("Disapproved","conversios"), $sync_product_disapproved)
210
+ .$this->add_list_html(esc_html__("Pending","conversios"), $sync_product_pending);
211
  ?>
212
  </ul>
213
  </div>
227
  <div class="card-body">
228
  <ul class="list-unstyled">
229
  <?php
230
+ echo $this->add_list_html(esc_html__("Total campaign","conversios"), $totalCampaigns)
231
+ .$this->add_list_html(esc_html__("Active campaigns","conversios"), $campaignActive)
232
+ .$this->add_list_html(esc_html__("Cost","conversios"), $campaignCost)
233
+ .$this->add_list_html(esc_html__("Click","conversios"), $campaignClicks)
234
+ .$this->add_list_html(esc_html__("Conversion%","conversios"), $campaignConversions)
235
+ .$this->add_list_html(esc_html__("Sales","conversios"), $campaignSales); ?>
236
  </ul>
237
  </div>
238
  <?php if (isset($googleDetail->google_ads_id) && esc_attr($googleDetail->google_ads_id) != "") { ?>
290
  });
291
  }
292
  $(document).ready(function() {
293
+ var is_need_to_update = "<?php echo esc_attr($is_need_to_update); ?>";
294
  if(is_need_to_update == 1 || is_need_to_update == true){
295
  call_tvc_api_sync_up();
296
  }
includes/setup/help-html.php CHANGED
@@ -30,7 +30,7 @@ function info_htnml($validation){
30
  function get_google_shopping_tabs_html($site_url, $google_merchant_center_id){
31
  $site_url_p = (isset($google_merchant_center_id) && $google_merchant_center_id != '')?$site_url:"";
32
  $site_url_p_target ="";
33
- if(isset($google_merchant_center_id) && esc_attr($google_merchant_center_id) == ''){
34
  $site_url_p_target = 'data-toggle="modal" data-target="#tvc_google_connect"';
35
  }
36
  $tab = (isset($_GET['tab']) && sanitize_text_field($_GET['tab']))?sanitize_text_field($_GET['tab']):"";
@@ -38,17 +38,17 @@ function get_google_shopping_tabs_html($site_url, $google_merchant_center_id){
38
  ob_start();
39
  ?><ul class="nav nav-tabs nav-justified edit-tabs" id="myTab" role="tablist">
40
  <li class="nav-item" role="presentation">
41
- <div class="tvc-tooltip nav-link <?php echo esc_attr(($tab=="gaa_config_page")?"active":""); ?>">
42
  <a href="<?php echo esc_url_raw($site_url.'gaa_config_page'); ?>" id="smart-shopping-campaigns"><?php echo esc_html__("Configuration", "conversios" ); ?></a>
43
  </div>
44
  </li>
45
  <li class="nav-item" role="presentation">
46
- <div class="tvc-tooltip nav-link <?php echo esc_attr(($tab=="sync_product_page")?"active":""); ?>" <?php echo esc_attr($site_url_p_target); ?>>
47
  <a href="<?php echo ($site_url_p)?esc_url_raw($site_url_p.'sync_product_page'):"#"; ?>" id="smart-shopping-campaigns"><?php echo esc_html__("Product Sync", "conversios" ); ?></a>
48
  </div>
49
  </li>
50
  <li class="nav-item" role="presentation">
51
- <div class="tvc-tooltip nav-link <?php echo esc_attr(($tab=="shopping_campaigns_page")?"active":""); ?>" <?php echo esc_attr($site_url_p_target); ?>>
52
  <a href="<?php echo ($site_url_p)?esc_url_raw($site_url_p . 'shopping_campaigns_page'):"#"; ?>" id="smart-shopping-campaigns"><?php echo esc_html__("Smart Shopping Campaigns", "conversios" ); ?></a>
53
  </div>
54
  </li>
30
  function get_google_shopping_tabs_html($site_url, $google_merchant_center_id){
31
  $site_url_p = (isset($google_merchant_center_id) && $google_merchant_center_id != '')?$site_url:"";
32
  $site_url_p_target ="";
33
+ if(isset($google_merchant_center_id) && $google_merchant_center_id == ''){
34
  $site_url_p_target = 'data-toggle="modal" data-target="#tvc_google_connect"';
35
  }
36
  $tab = (isset($_GET['tab']) && sanitize_text_field($_GET['tab']))?sanitize_text_field($_GET['tab']):"";
38
  ob_start();
39
  ?><ul class="nav nav-tabs nav-justified edit-tabs" id="myTab" role="tablist">
40
  <li class="nav-item" role="presentation">
41
+ <div class="tvc-tooltip nav-link <?php echo ($tab=="gaa_config_page")?"active":""; ?>">
42
  <a href="<?php echo esc_url_raw($site_url.'gaa_config_page'); ?>" id="smart-shopping-campaigns"><?php echo esc_html__("Configuration", "conversios" ); ?></a>
43
  </div>
44
  </li>
45
  <li class="nav-item" role="presentation">
46
+ <div class="tvc-tooltip nav-link <?php echo ($tab=="sync_product_page")?"active":""; ?>" <?php echo esc_attr($site_url_p_target); ?>>
47
  <a href="<?php echo ($site_url_p)?esc_url_raw($site_url_p.'sync_product_page'):"#"; ?>" id="smart-shopping-campaigns"><?php echo esc_html__("Product Sync", "conversios" ); ?></a>
48
  </div>
49
  </li>
50
  <li class="nav-item" role="presentation">
51
+ <div class="tvc-tooltip nav-link <?php echo ($tab=="shopping_campaigns_page")?"active":""; ?>" <?php echo esc_attr($site_url_p_target); ?>>
52
  <a href="<?php echo ($site_url_p)?esc_url_raw($site_url_p . 'shopping_campaigns_page'):"#"; ?>" id="smart-shopping-campaigns"><?php echo esc_html__("Smart Shopping Campaigns", "conversios" ); ?></a>
53
  </div>
54
  </li>
includes/setup/json/gmc_attrbutes.json CHANGED
@@ -38,7 +38,7 @@
38
  },
39
  {
40
  "field": "mpn",
41
- "desc": "Your product’s Global Trade Item Number (GTIN). Required for all new products with an assigned GTIN."
42
  },
43
  {
44
  "field": "age_group",
38
  },
39
  {
40
  "field": "mpn",
41
+ "desc": "Your product’s Manufacturer Part Number (MPN). Required for all new products with an assigned MPN."
42
  },
43
  {
44
  "field": "age_group",
public/class-enhanced-ecommerce-google-analytics-public-pro.php CHANGED
@@ -123,8 +123,8 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
123
  $current_user_type = 'register_user';
124
  }
125
  $this->tvc_options = array(
126
- "feature_product_label"=>esc_js("Feature Product"),
127
- "on_sale_label"=>esc_js("On Sale"),
128
  "affiliation"=>esc_js(get_bloginfo('name')),
129
  "local_time"=>esc_js(time()),
130
  "is_admin"=>esc_attr(is_admin()),
@@ -168,7 +168,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
168
  add_action("woocommerce_after_shop_loop_item", array($this, "bind_product_metadata"));
169
  add_action("woocommerce_thankyou", array($this, "ecommerce_tracking_code"));
170
  add_action("woocommerce_after_single_product", array($this, "product_detail_view"));
171
- add_action("woocommerce_after_cart",array($this, "remove_cart_tracking"));
172
  //check out step 1,2,3
173
  add_action("woocommerce_before_checkout_form", array($this, "checkout_step_1_tracking"));
174
  add_action("woocommerce_before_checkout_form", array($this, "checkout_step_2_tracking"));
@@ -178,7 +178,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
178
  add_action("wp_footer", array($this, "add_plugin_details"));
179
  //Add Dev ID
180
  add_action("wp_head", array($this, "add_dev_id"));
181
- add_action("wp_footer",array($this, "tvc_store_meta_data"));
182
 
183
  //add_action('wp_ajax_get_variation_data', array($this,'get_variation_data') );
184
  //add_action("wp_ajax_nopriv_get_variation_data" , "get_variation_data");
@@ -203,7 +203,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
203
  if($prod_var_array){
204
  foreach ($prod_var_array as $attribute_name => $attribute) {
205
  $attr = (is_array($attribute) ? implode('|', $attribute) : $attribute);
206
- $attributes[] = $attribute_name . '=>' . $attr;
207
  }
208
  }
209
  return implode(',', $attributes);
@@ -230,10 +230,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
230
  * @access public
231
  * @return void
232
  */
233
- function add_page_type() {
234
- //identify pages
235
- //echo "tt".is_wc_endpoint_url('order-received').is_checkout();
236
- //exit;
237
 
238
  if (is_home() || is_front_page()) {
239
  $t_page_name = esc_html__("Home Page","conversios");
@@ -283,8 +280,8 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
283
  public function add_google_site_verification_tag(){
284
  $TVC_Admin_Helper = new TVC_Admin_Helper();
285
  $ee_additional_data = $TVC_Admin_Helper->get_ee_additional_data();
286
- if(isset($ee_additional_data['add_site_varification_tag']) && isset($ee_additional_data['site_varification_tag_val']) && esc_attr($ee_additional_data['add_site_varification_tag']) == 1 && $ee_additional_data['site_varification_tag_val'] !="" ){
287
- echo base64_decode(esc_html($ee_additional_data['site_varification_tag_val']));
288
  }
289
  }
290
  public function get_option($key){
@@ -307,26 +304,9 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
307
  //only on home page
308
  global $woocommerce;
309
  $google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
310
- $sub_data = array();
311
  if(isset($google_detail['setting'])){
312
- $googleDetail = $google_detail['setting'];
313
- $sub_data['sub_id'] = sanitize_text_field(isset($googleDetail->id)?esc_attr($googleDetail->id):"");
314
- $sub_data['cu_id']=sanitize_text_field(isset($googleDetail->customer_id)?esc_attr($googleDetail->customer_id):"");
315
- $sub_data['pl_id']=sanitize_text_field(isset($googleDetail->plan_id)?esc_attr($googleDetail->plan_id):"");
316
- $sub_data['ga_tra_option']=sanitize_text_field(isset($googleDetail->tracking_option)?esc_attr($googleDetail->tracking_option):"");
317
- $sub_data['ga_property_id']=sanitize_text_field(isset($googleDetail->property_id)?esc_attr($googleDetail->property_id):"");
318
- $sub_data['ga_measurement_id']=sanitize_text_field(isset($googleDetail->measurement_id)?esc_attr($googleDetail->measurement_id):"");
319
- $sub_data['ga_ads_id']=sanitize_text_field(isset($googleDetail->google_ads_id)?esc_attr($googleDetail->google_ads_id):"");
320
- $sub_data['ga_gmc_id']=sanitize_text_field(isset($googleDetail->google_merchant_center_id)?esc_attr($googleDetail->google_merchant_center_id):"");
321
- $sub_data['op_gtag_js']=sanitize_text_field(isset($googleDetail->add_gtag_snippet)?esc_attr($googleDetail->add_gtag_snippet):"");
322
- $sub_data['op_en_e_t']=sanitize_text_field(isset($googleDetail->enhanced_e_commerce_tracking)?esc_attr($googleDetail->enhanced_e_commerce_tracking):"");
323
- $sub_data['op_rm_t_t']=sanitize_text_field(isset($googleDetail->remarketing_tags)?esc_attr($googleDetail->remarketing_tags):"");
324
- $sub_data['op_dy_rm_t_t']=sanitize_text_field(isset($googleDetail->dynamic_remarketing_tags)?esc_attr($googleDetail->dynamic_remarketing_tags):"");
325
- $sub_data['op_li_ga_wi_ads']=sanitize_text_field(isset($googleDetail->link_google_analytics_with_google_ads)?esc_attr($googleDetail->link_google_analytics_with_google_ads):"");
326
- $sub_data['gmc_is_product_sync']=sanitize_text_field(isset($googleDetail->is_product_sync)?esc_attr($googleDetail->is_product_sync):"");
327
- $sub_data['gmc_is_site_verified']=sanitize_text_field(isset($googleDetail->is_site_verified)?esc_attr($googleDetail->is_site_verified):"");
328
- $sub_data['gmc_is_domain_claim']=sanitize_text_field(isset($googleDetail->is_domain_claim)?esc_attr($googleDetail->is_domain_claim):"");
329
- $sub_data['gmc_product_count']=sanitize_text_field(isset($googleDetail->product_count)?esc_attr($googleDetail->product_count):"");
330
  }
331
  $tvc_sMetaData = array(
332
  'tvc_wcv' => esc_js($woocommerce->version),
@@ -342,7 +322,25 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
342
  't_OptOut' => esc_js($this->ga_OPTOUT),
343
  't_PrivacyPolicy' => esc_js($this->ga_PrivacyPolicy)
344
  ),
345
- 'tvc_sub_data'=> $sub_data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
346
  );
347
  $this->wc_version_compare("tvc_smd=" . json_encode($tvc_sMetaData) . ";");
348
  }
@@ -353,7 +351,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
353
  * @since4.0.0
354
  */
355
  public function enqueue_scripts() {
356
- wp_enqueue_script(esc_attr($this->plugin_name), esc_url_raw(ENHANCAD_PLUGIN_URL . '/public/js/tvc-ee-google-analytics.js'), array('jquery'), $this->version, false);
357
  }
358
 
359
  /**
@@ -387,7 +385,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
387
  */
388
  private function disable_tracking($type) {
389
  if (is_admin() || "" == $type || current_user_can("manage_options")) {
390
- return true;
391
  }
392
  }
393
 
@@ -423,17 +421,18 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
423
  $ga_ip_anonymization = '"anonymize_ip":true,';
424
  } else {
425
  $ga_ip_anonymization ="";
426
- }
427
- echo '<script type="text/javascript" defer="defer">';
428
- echo 'var adsTringId = '.json_encode($this->ads_tracking_id).';';
429
- echo 'var ads_ert = '.json_encode($this->ads_ert).';';
430
- echo 'var ads_edrt = '.json_encode($this->ads_edrt).';';
431
- echo '</script>';
432
-
433
  if($this->ga_OPTOUT) {
434
- echo '<script>
 
435
  // Set to the same value as the web property used on the site
436
- var gaProperty = "'.esc_js($this->ga_id).'";
437
  // Disable tracking if the opt-out cookie exists.
438
  var disableStr = "ga-disable-" + gaProperty;
439
  if (document.cookie.indexOf(disableStr + "=true") > -1) {
@@ -445,16 +444,17 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
445
  expDate.setMonth(expDate.getMonth() + 26);
446
  document.cookie = disableStr + "=true; expires="+expDate.toGMTString()+";path=/";
447
  window[disableStr] = true;
448
- }</script>';
 
449
  }
450
  //add gtag js snippets
451
- if( $this->tracking_option == "BOTH" && $this->gm_id && $this->ga_id){
452
- echo '<script async src="https://www.googletagmanager.com/gtag/js?id='.esc_js($this->gm_id).'"></script>
453
  <script>
454
  window.dataLayer = window.dataLayer || [];
455
  function gtag(){dataLayer.push(arguments);}
456
  gtag("js", new Date());
457
- gtag("config", "'.esc_js($this->gm_id).'",{'.$ga_ip_anonymization.' "cookie_domain":"'.esc_js($this->ga_Dname).'",
458
  "custom_map": {
459
  "dimension1": "user_id",
460
  "dimension3": "user_type",
@@ -476,15 +476,16 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
476
  "metric7": "time_taken_to_make_the_purchase"
477
  }
478
  });
479
- gtag("config", "'.esc_js($this->ga_id).'");
480
- </script>';
481
- }else if($this->tracking_option == "GA4" && $this->gm_id){
482
- echo '<script async src="https://www.googletagmanager.com/gtag/js?id='.esc_js($this->gm_id).'"></script>
 
483
  <script>
484
  window.dataLayer = window.dataLayer || [];
485
  function gtag(){dataLayer.push(arguments);}
486
  gtag("js", new Date());
487
- gtag("config", "'.esc_js($this->gm_id).'",{'.$ga_ip_anonymization.' "cookie_domain":"'.esc_js($this->ga_Dname).'",
488
  "custom_map": {
489
  "dimension1": "user_id",
490
  "dimension3": "user_type",
@@ -506,14 +507,15 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
506
  "metric7": "time_taken_to_make_the_purchase"
507
  }
508
  });
509
- </script>';
510
- }else if($this->ga_id){
511
- echo '<script async src="https://www.googletagmanager.com/gtag/js?id='.esc_js($this->ga_id).'"></script>
 
512
  <script>
513
  window.dataLayer = window.dataLayer || [];
514
  function gtag(){dataLayer.push(arguments);}
515
  gtag("js", new Date());
516
- gtag("config", "'.esc_js($this->ga_id).'",{'.$ga_ip_anonymization.' "cookie_domain":"'.esc_js($this->ga_Dname).'",
517
  "custom_map": {
518
  "dimension1": "user_id",
519
  "dimension3": "user_type",
@@ -535,17 +537,18 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
535
  "metric7": "time_taken_to_make_the_purchase"
536
  }
537
  });
538
- </script>';
 
539
  }
540
  //add remarketing snippets
541
  if($this->ads_tracking_id && ($this->ads_ert || $this->ads_edrt)){
542
  if(!empty($this->remarketing_snippets) && $this->remarketing_snippets){
543
- echo $this->remarketing_snippets;
544
  }else{
545
  $google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
546
  if(isset($google_detail['setting'])){
547
  $googleDetail = $google_detail['setting'];
548
- echo esc_js($googleDetail->google_ads_snippets);
549
  }
550
  }
551
  }
@@ -623,18 +626,18 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
623
  }
624
  if (version_compare($woocommerce->version, "2.7", "<")) {
625
  $orderpage_prod_Array[get_permalink($_product->ID)]=array(
626
- "tvc_id" => esc_html($_product->ID),
627
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->ID),
628
- "tvc_n" => html_entity_decode($item["name"]),
629
  "tvc_p" => esc_js($order->get_item_total($item)),
630
  //"tvc_rp" => $_product->regular_price,
631
  //"tvc_sp" => $_product->sale_price,
632
- "tvc_pd" => $this->cal_prod_discount($_product->regular_price, $_product->sale_price),
633
- "tvc_c" => $categories,
634
- "tvc_attr" => $attributes,
635
  "tvc_q"=>esc_js($item["qty"]),
636
  //"tvc_wt" => $p_weight,
637
- "tvc_var" => $this->getAttributesVariation($_product),
638
  /*"tvc_di" => $_product->get_dimensions(), //dimensions
639
  "tvc_ss" => $_product->is_in_stock(),
640
  "tvc_st" => $_product->get_stock_quantity(),
@@ -644,18 +647,18 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
644
  );
645
  }else{
646
  $orderpage_prod_Array[get_permalink($_product->get_id())]=array(
647
- "tvc_id" => esc_html($_product->get_id()),
648
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->get_id()),
649
- "tvc_n" => $_product->get_title(),
650
  "tvc_p" => esc_js($order->get_item_total($item)),
651
  // "tvc_rp" => $_product->get_regular_price(),
652
  // "tvc_sp" => $_product->get_sale_price(),
653
- "tvc_pd" => $this->cal_prod_discount($_product->get_regular_price(), $_product->get_sale_price()),
654
- "tvc_c" => $categories,
655
- "tvc_attr" => $attributes,
656
  "tvc_q"=>esc_js($item["qty"]),
657
  //"tvc_wt" => $p_weight,
658
- "tvc_var" => $this->getAttributesVariation($_product),
659
  /*"tvc_di" => $_product->get_dimensions(), //dimensions
660
  "tvc_ss" => $_product->is_in_stock(),
661
  "tvc_st" => $_product->get_stock_quantity(),
@@ -693,30 +696,25 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
693
  "revenue"=>esc_js($order->get_total()), // Grand Total
694
  "tax"=> esc_js($order->get_total_tax()), // Tax
695
  "shipping"=> esc_js($tvc_sc), // Shipping
696
- "coupon"=>$coupons_list,
697
  "total_discount"=>esc_js($order->get_total_discount()),
698
- "user_bill_addr"=>$user_bill_addr,
699
- "user_ship_addr"=>$user_ship_addr,
700
  "user_type"=>esc_js($this->tvc_options["user_type"]),
701
- "payment_method"=>$order->get_payment_method()
702
  );
703
  $this->wc_version_compare("tvc_td=" . json_encode($orderpage_trans_Array) . ";");
704
- /*let script = document.createElement('script');
705
- script.addEventListener('load', (event) => {
706
- let tvc_js = new TVC_Enhanced(<?php echo json_encode($tvc_options); ?>);
707
- });
708
- script.src = "<?php echo ENHANCAD_PLUGIN_URL.'/public/js/tvc-ee-google-analytics.js'; ?>";
709
- document.getElementsByTagName('head')[0].appendChild(script);*/
710
  ?>
711
  <script>
712
  window.addEventListener('load', call_thnkyou_page,true);
713
  function call_thnkyou_page(){
714
  tvc_js = new TVC_Enhanced(<?php echo json_encode($this->tvc_options); ?>);
715
- tvc_js.thnkyou_page(<?php echo json_encode($orderpage_prod_Array); ?>, <?php echo json_encode($orderpage_trans_Array); ?>, "+<?php echo $order->get_status(); ?>+", <?php echo time(); ?>);
716
  }
717
  </script>
718
  <?php
719
- update_post_meta($order_id, "_tracked", sanitize_option("_tracked",1));
720
  }
721
 
722
  /**
@@ -780,33 +778,33 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
780
 
781
  if(version_compare($woocommerce->version, "2.7", "<")){
782
  $prodpage_detail_json = array(
783
- "tvc_id" => esc_html($product->id),
784
- "tvc_i" => $product->get_sku() ? $product->get_sku() : $product->id,
785
- "tvc_n" => $product->get_title(),
786
- "tvc_c" => $categories,
787
- "tvc_p" => $product->get_price(),
788
- "tvc_pd" => $this->cal_prod_discount($product->regular_price, $product->sale_price),
789
- "tvc_ps" => $product->get_stock_status(),
790
- "tvc_tst" => $product->get_total_stock(),
791
- "tvc_q" => esc_html($product->get_stock_quantity()),
792
- "tvc_var" => $this->getAttributesVariation($product),
793
- "is_featured" => $product->is_featured(),
794
- "is_onSale" => $product->is_on_sale()
795
  );
796
  }else{
797
  $prodpage_detail_json = array(
798
- "tvc_id" => esc_html($product->get_id()),
799
- "tvc_i" => $product->get_sku() ? $product->get_sku() : $product->get_id(),
800
- "tvc_n" => $product->get_title(),
801
- "tvc_c" => $categories,
802
- "tvc_p" => $product->get_price(),
803
- "tvc_pd" => $this->cal_prod_discount($product->get_regular_price(), $product->get_sale_price()),
804
- "tvc_ps" => $product->get_stock_status(),
805
- "tvc_tst" => $product->get_stock_quantity(),
806
- "tvc_q" => esc_html($product->get_stock_quantity()),
807
- "tvc_var" => $this->getAttributesVariation($product),
808
- "is_featured" => $product->is_featured(),
809
- "is_onSale" => $product->is_on_sale()
810
  );
811
  }
812
  //prod page detail view json
@@ -862,9 +860,15 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
862
 
863
  // ATC link Array
864
  if(version_compare($woocommerce->version, "2.7", "<")){
865
- $homepage_json_ATC_link[$product->add_to_cart_url()]=array("ATC-link"=>get_permalink($product->id));
 
 
 
866
  }else{
867
- $homepage_json_ATC_link[$product->add_to_cart_url()]=array("ATC-link"=>get_permalink($product->get_id()));
 
 
 
868
  }
869
  //check if product is featured product or not
870
  if ($product->is_featured()) {
@@ -872,41 +876,41 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
872
  if(version_compare($woocommerce->version, "2.7", "<")){
873
  if(!array_key_exists(get_permalink($product->id),$homepage_json_fp)){
874
  $homepage_json_fp[get_permalink($product->id)] = array(
875
- "tvc_id" => esc_html($product->id),
876
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->id),
877
- "tvc_n" => esc_html($product->get_title()),
878
- "tvc_p" => esc_html($product->get_price()),
879
- "tvc_c" => esc_html($categories),
880
- "ATC-link"=>$product->add_to_cart_url()
881
  );
882
  //else add product in homepage recent product json
883
  }else {
884
  $homepage_json_rp[get_permalink($product->get_id())] =array(
885
- "tvc_id" => esc_html($product->get_id()),
886
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->get_id()),
887
- "tvc_n" => esc_html($product->get_title()),
888
- "tvc_p" => esc_html($product->get_price()),
889
- "tvc_c" => esc_html($categories)
890
  );
891
  }
892
  }else{
893
  if(!array_key_exists(get_permalink($product->get_id()),$homepage_json_fp)){
894
  $homepage_json_fp[get_permalink($product->get_id())] = array(
895
- "tvc_id" => esc_html($product->get_id()),
896
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->get_id()),
897
- "tvc_n" => esc_html($product->get_title()),
898
- "tvc_p" => esc_html($product->get_price()),
899
- "tvc_c" => esc_html($categories),
900
- "ATC-link"=>$product->add_to_cart_url()
901
  );
902
  //else add product in homepage recent product json
903
  }else {
904
  $homepage_json_rp[get_permalink($product->get_id())] =array(
905
- "tvc_id" => esc_html($product->get_id()),
906
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->get_id()),
907
- "tvc_n" => esc_html($product->get_title()),
908
- "tvc_p" => esc_html($product->get_price()),
909
- "tvc_c" => esc_html($categories)
910
  );
911
  }
912
  }
@@ -915,19 +919,19 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
915
  //else prod add in homepage recent json
916
  if(version_compare($woocommerce->version, "2.7", "<")){
917
  $homepage_json_rp[get_permalink($product->id)] =array(
918
- "tvc_id" => esc_html($product->id),
919
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->id),
920
- "tvc_n" => esc_html($product->get_title()),
921
- "tvc_p" => esc_html($product->get_price()),
922
- "tvc_c" => esc_html($categories)
923
  );
924
  }else{
925
  $homepage_json_rp[get_permalink($product->get_id())] =array(
926
- "tvc_id" => esc_html($product->get_id()),
927
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->get_id()),
928
- "tvc_n" => esc_html($product->get_title()),
929
- "tvc_p" => esc_html($product->get_price()),
930
- "tvc_c" => esc_html($categories)
931
  );
932
  }
933
 
@@ -941,24 +945,30 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
941
  }
942
  // ATC link Array
943
  if(version_compare($woocommerce->version, "2.7", "<")){
944
- $prodpage_json_ATC_link[$product->add_to_cart_url()]=array("ATC-link"=>get_permalink($product->id));
 
 
 
945
 
946
  $prodpage_json_relProd[get_permalink($product->id)] = array(
947
- "tvc_id" => esc_html($product->id),
948
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->id),
949
- "tvc_n" => esc_html($product->get_title()),
950
- "tvc_p" => esc_html($product->get_price()),
951
- "tvc_c" => esc_html($categories),
952
  );
953
  }else{
954
- $prodpage_json_ATC_link[$product->add_to_cart_url()]=array("ATC-link"=>get_permalink($product->get_id()));
 
 
 
955
 
956
  $prodpage_json_relProd[get_permalink($product->get_id())] = array(
957
- "tvc_id" => esc_html($product->get_id()),
958
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->get_id()),
959
- "tvc_n" => esc_html($product->get_title()),
960
- "tvc_p" => esc_html($product->get_price()),
961
- "tvc_c" => esc_html($categories)
962
 
963
  );
964
  }
@@ -971,24 +981,30 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
971
  }
972
  //cat page ATC array
973
  if(version_compare($woocommerce->version, "2.7", "<")){
974
- $catpage_json_ATC_link[$product->add_to_cart_url()]=array("ATC-link"=>get_permalink($product->id));
 
 
 
975
 
976
  $catpage_json[get_permalink($product->id)] =array(
977
- "tvc_id" => esc_html($product->id),
978
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->id),
979
- "tvc_n" => esc_html($product->get_title()),
980
- "tvc_p" => esc_html($product->get_price()),
981
- "tvc_c" => esc_html($categories),
982
  );
983
  }else{
984
- $catpage_json_ATC_link[$product->add_to_cart_url()]=array("ATC-link"=>get_permalink($product->get_id()));
 
 
 
985
 
986
  $catpage_json[get_permalink($product->get_id())] =array(
987
- "tvc_id" => esc_html($product->get_id()),
988
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->get_id()),
989
- "tvc_n" => esc_html($product->get_title()),
990
- "tvc_p" => esc_html($product->get_price()),
991
- "tvc_c" => esc_html($categories)
992
 
993
  );
994
  }
@@ -1354,6 +1370,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
1354
  //Prod ATC link click in related product section
1355
  jQuery("a[href*=add-to-cart]").on("click",function(){
1356
  t_url=jQuery(this).attr("href");
 
1357
  t_qty=$(this).parent().find("input[name=quantity]").val();
1358
  //default quantity 1 if quantity box is not there
1359
  if(t_qty=="" || t_qty===undefined){
@@ -1448,21 +1465,21 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
1448
  $categories = rtrim($categories, ",");
1449
  if(version_compare($woocommerce->version, "2.7", "<")){
1450
  $cartpage_prod_array_main[$cart_remove_link] =array(
1451
- "tvc_id" => esc_html($prod_meta->ID),
1452
- "tvc_i" => esc_html($prod_meta->get_sku() ? $prod_meta->get_sku() : $prod_meta->ID),
1453
- "tvc_n" => html_entity_decode($prod_meta->get_title()),
1454
- "tvc_p" => esc_html($prod_meta->get_price()),
1455
- "tvc_c" => esc_html($categories),
1456
- "tvc_q"=>$woocommerce->cart->cart_contents[$key]["quantity"]
1457
  );
1458
  }else{
1459
  $cartpage_prod_array_main[$cart_remove_link] =array(
1460
- "tvc_id" => esc_html($prod_meta->get_id()),
1461
- "tvc_i" => esc_html($prod_meta->get_sku() ? $prod_meta->get_sku() : $prod_meta->get_id()),
1462
- "tvc_n" => html_entity_decode($prod_meta->get_title()),
1463
- "tvc_p" => esc_html($prod_meta->get_price()),
1464
- "tvc_c" => esc_html($categories),
1465
- "tvc_q"=>$woocommerce->cart->cart_contents[$key]["quantity"]
1466
  );
1467
  }
1468
  }
@@ -1693,23 +1710,23 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
1693
  $categories = rtrim($categories, ",");
1694
  if(version_compare($woocommerce->version, "2.7", "<")){
1695
  $chkout_json[get_permalink($p->ID)] = array(
1696
- "tvc_id" => esc_html($p->ID),
1697
  "tvc_i" => esc_js($p->get_sku() ? $p->get_sku() : $p->ID),
1698
- "tvc_n" => html_entity_decode($p->get_title()),
1699
  "tvc_p" => esc_js($p->get_price()),
1700
- "tvc_c" => $categories,
1701
  "tvc_q" => esc_js($item["quantity"]),
1702
- "isfeatured"=>$p->is_featured()
1703
  );
1704
  }else{
1705
  $chkout_json[get_permalink($p->get_id())] = array(
1706
- "tvc_id" => esc_html($p->get_id()),
1707
  "tvc_i" => esc_js($p->get_sku() ? $p->get_sku() : $p->get_id()),
1708
- "tvc_n" => html_entity_decode($p->get_title()),
1709
  "tvc_p" => esc_js($p->get_price()),
1710
- "tvc_c" => $categories,
1711
  "tvc_q" => esc_js($item["quantity"]),
1712
- "isfeatured"=>$p->is_featured()
1713
  );
1714
  }
1715
  }
123
  $current_user_type = 'register_user';
124
  }
125
  $this->tvc_options = array(
126
+ "feature_product_label"=>esc_html__("Feature Product"),
127
+ "on_sale_label"=>esc_html__("On Sale"),
128
  "affiliation"=>esc_js(get_bloginfo('name')),
129
  "local_time"=>esc_js(time()),
130
  "is_admin"=>esc_attr(is_admin()),
168
  add_action("woocommerce_after_shop_loop_item", array($this, "bind_product_metadata"));
169
  add_action("woocommerce_thankyou", array($this, "ecommerce_tracking_code"));
170
  add_action("woocommerce_after_single_product", array($this, "product_detail_view"));
171
+ add_action("woocommerce_after_cart", array($this, "remove_cart_tracking"));
172
  //check out step 1,2,3
173
  add_action("woocommerce_before_checkout_form", array($this, "checkout_step_1_tracking"));
174
  add_action("woocommerce_before_checkout_form", array($this, "checkout_step_2_tracking"));
178
  add_action("wp_footer", array($this, "add_plugin_details"));
179
  //Add Dev ID
180
  add_action("wp_head", array($this, "add_dev_id"));
181
+ add_action("wp_footer", array($this, "tvc_store_meta_data"));
182
 
183
  //add_action('wp_ajax_get_variation_data', array($this,'get_variation_data') );
184
  //add_action("wp_ajax_nopriv_get_variation_data" , "get_variation_data");
203
  if($prod_var_array){
204
  foreach ($prod_var_array as $attribute_name => $attribute) {
205
  $attr = (is_array($attribute) ? implode('|', $attribute) : $attribute);
206
+ $attributes[] = $attribute_name . ':' . $attr;
207
  }
208
  }
209
  return implode(',', $attributes);
230
  * @access public
231
  * @return void
232
  */
233
+ function add_page_type() {
 
 
 
234
 
235
  if (is_home() || is_front_page()) {
236
  $t_page_name = esc_html__("Home Page","conversios");
280
  public function add_google_site_verification_tag(){
281
  $TVC_Admin_Helper = new TVC_Admin_Helper();
282
  $ee_additional_data = $TVC_Admin_Helper->get_ee_additional_data();
283
+ if(isset($ee_additional_data['add_site_varification_tag']) && isset($ee_additional_data['site_varification_tag_val']) && $ee_additional_data['add_site_varification_tag'] == 1 && $ee_additional_data['site_varification_tag_val'] !="" ){
284
+ echo html_entity_decode(esc_html(base64_decode($ee_additional_data['site_varification_tag_val'])));
285
  }
286
  }
287
  public function get_option($key){
304
  //only on home page
305
  global $woocommerce;
306
  $google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
307
+ $googleDetail = array();
308
  if(isset($google_detail['setting'])){
309
+ $googleDetail = $google_detail['setting'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  }
311
  $tvc_sMetaData = array(
312
  'tvc_wcv' => esc_js($woocommerce->version),
322
  't_OptOut' => esc_js($this->ga_OPTOUT),
323
  't_PrivacyPolicy' => esc_js($this->ga_PrivacyPolicy)
324
  ),
325
+ 'tvc_sub_data'=> array(
326
+ 'sub_id' =>esc_js(isset($googleDetail->id)?sanitize_text_field($googleDetail->id):""),
327
+ 'cu_id' => esc_js(isset($googleDetail->customer_id)?sanitize_text_field($googleDetail->customer_id):""),
328
+ 'pl_id' => esc_js(isset($googleDetail->plan_id)?sanitize_text_field($googleDetail->plan_id):""),
329
+ 'ga_tra_option' => esc_js(isset($googleDetail->tracking_option)?sanitize_text_field($googleDetail->tracking_option):""),
330
+ 'ga_property_id' => esc_js(isset($googleDetail->property_id)?sanitize_text_field($googleDetail->property_id):""),
331
+ 'ga_measurement_id' => esc_js(isset($googleDetail->measurement_id)?sanitize_text_field($googleDetail->measurement_id):""),
332
+ 'ga_ads_id' => esc_js(isset($googleDetail->google_ads_id)?sanitize_text_field($googleDetail->google_ads_id):""),
333
+ 'ga_gmc_id' => esc_js(isset($googleDetail->google_merchant_center_id)?sanitize_text_field($googleDetail->google_merchant_center_id):""),
334
+ 'op_gtag_js' => esc_js(isset($googleDetail->add_gtag_snippet)?sanitize_text_field($googleDetail->add_gtag_snippet):""),
335
+ 'op_en_e_t' => esc_js(isset($googleDetail->enhanced_e_commerce_tracking)?sanitize_text_field($googleDetail->enhanced_e_commerce_tracking):""),
336
+ 'op_rm_t_t' => esc_js(isset($googleDetail->remarketing_tags)?sanitize_text_field($googleDetail->remarketing_tags):""),
337
+ 'op_dy_rm_t_t' => esc_js(isset($googleDetail->dynamic_remarketing_tags)?esc_attr($googleDetail->dynamic_remarketing_tags):""),
338
+ 'op_li_ga_wi_ads' => esc_js(isset($googleDetail->link_google_analytics_with_google_ads)?sanitize_text_field($googleDetail->link_google_analytics_with_google_ads):""),
339
+ 'gmc_is_product_sync' => esc_js(isset($googleDetail->is_product_sync)?sanitize_text_field($googleDetail->is_product_sync):""),
340
+ 'gmc_is_site_verified' => esc_js(isset($googleDetail->is_site_verified)?sanitize_text_field($googleDetail->is_site_verified):""),
341
+ 'gmc_is_domain_claim' => esc_js(isset($googleDetail->is_domain_claim)?sanitize_text_field($googleDetail->is_domain_claim):""),
342
+ 'gmc_product_count' => esc_js(isset($googleDetail->product_count)?sanitize_text_field($googleDetail->product_count):"")
343
+ )
344
  );
345
  $this->wc_version_compare("tvc_smd=" . json_encode($tvc_sMetaData) . ";");
346
  }
351
  * @since4.0.0
352
  */
353
  public function enqueue_scripts() {
354
+ wp_enqueue_script(esc_js($this->plugin_name), esc_url_raw(ENHANCAD_PLUGIN_URL . '/public/js/tvc-ee-google-analytics.js'), array('jquery'), esc_js($this->version), false);
355
  }
356
 
357
  /**
385
  */
386
  private function disable_tracking($type) {
387
  if (is_admin() || "" == $type || current_user_can("manage_options")) {
388
+ return true;
389
  }
390
  }
391
 
421
  $ga_ip_anonymization = '"anonymize_ip":true,';
422
  } else {
423
  $ga_ip_anonymization ="";
424
+ }?>
425
+ <script type="text/javascript" defer="defer">
426
+ var adsTringId = '<?php echo esc_js($this->ads_tracking_id); ?>';
427
+ var ads_ert = '<?php echo esc_js($this->ads_ert); ?>';
428
+ var ads_edrt = '<?php echo esc_js($this->ads_edrt)?>';
429
+ </script>
430
+ <?php
431
  if($this->ga_OPTOUT) {
432
+ ?>
433
+ <script>
434
  // Set to the same value as the web property used on the site
435
+ var gaProperty = '<?php echo esc_js($this->ga_id); ?>';
436
  // Disable tracking if the opt-out cookie exists.
437
  var disableStr = "ga-disable-" + gaProperty;
438
  if (document.cookie.indexOf(disableStr + "=true") > -1) {
444
  expDate.setMonth(expDate.getMonth() + 26);
445
  document.cookie = disableStr + "=true; expires="+expDate.toGMTString()+";path=/";
446
  window[disableStr] = true;
447
+ }</script>
448
+ <?php
449
  }
450
  //add gtag js snippets
451
+ if( $this->tracking_option == "BOTH" && $this->gm_id && $this->ga_id){ ?>
452
+ <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo esc_js($this->gm_id); ?>"></script>
453
  <script>
454
  window.dataLayer = window.dataLayer || [];
455
  function gtag(){dataLayer.push(arguments);}
456
  gtag("js", new Date());
457
+ gtag("config", "<?php echo esc_js($this->gm_id); ?>",{<?php echo $ga_ip_anonymization; ?> "cookie_domain":"<?php echo esc_js($this->ga_Dname); ?>",
458
  "custom_map": {
459
  "dimension1": "user_id",
460
  "dimension3": "user_type",
476
  "metric7": "time_taken_to_make_the_purchase"
477
  }
478
  });
479
+ gtag("config", "<?php echo esc_js($this->ga_id); ?>");
480
+ </script>
481
+ <?php
482
+ }else if($this->tracking_option == "GA4" && $this->gm_id){ ?>
483
+ <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo esc_js($this->gm_id); ?>"></script>
484
  <script>
485
  window.dataLayer = window.dataLayer || [];
486
  function gtag(){dataLayer.push(arguments);}
487
  gtag("js", new Date());
488
+ gtag("config", "<?php echo esc_js($this->gm_id); ?>",{<?php echo $ga_ip_anonymization; ?> "cookie_domain":"<?php echo esc_js($this->ga_Dname); ?>",
489
  "custom_map": {
490
  "dimension1": "user_id",
491
  "dimension3": "user_type",
507
  "metric7": "time_taken_to_make_the_purchase"
508
  }
509
  });
510
+ </script>
511
+ <?php
512
+ }else if($this->ga_id){ ?>
513
+ <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo esc_js($this->ga_id); ?>"></script>
514
  <script>
515
  window.dataLayer = window.dataLayer || [];
516
  function gtag(){dataLayer.push(arguments);}
517
  gtag("js", new Date());
518
+ gtag("config", "<?php echo esc_js($this->ga_id); ?>",{<?php echo $ga_ip_anonymization; ?> "cookie_domain":"<?php echo esc_js($this->ga_Dname); ?>",
519
  "custom_map": {
520
  "dimension1": "user_id",
521
  "dimension3": "user_type",
537
  "metric7": "time_taken_to_make_the_purchase"
538
  }
539
  });
540
+ </script>
541
+ <?php
542
  }
543
  //add remarketing snippets
544
  if($this->ads_tracking_id && ($this->ads_ert || $this->ads_edrt)){
545
  if(!empty($this->remarketing_snippets) && $this->remarketing_snippets){
546
+ echo html_entity_decode(str_replace("&#039;", "'", esc_html($this->remarketing_snippets)) );
547
  }else{
548
  $google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
549
  if(isset($google_detail['setting'])){
550
  $googleDetail = $google_detail['setting'];
551
+ echo html_entity_decode(str_replace("&#039;", "'",esc_html($googleDetail->google_ads_snippets)) );
552
  }
553
  }
554
  }
626
  }
627
  if (version_compare($woocommerce->version, "2.7", "<")) {
628
  $orderpage_prod_Array[get_permalink($_product->ID)]=array(
629
+ "tvc_id" => esc_js($_product->ID),
630
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->ID),
631
+ "tvc_n" => html_entity_decode(esc_js($item["name"])),
632
  "tvc_p" => esc_js($order->get_item_total($item)),
633
  //"tvc_rp" => $_product->regular_price,
634
  //"tvc_sp" => $_product->sale_price,
635
+ "tvc_pd" => esc_js($this->cal_prod_discount($_product->regular_price, $_product->sale_price)),
636
+ "tvc_c" => esc_js($categories),
637
+ "tvc_attr" => esc_js($attributes),
638
  "tvc_q"=>esc_js($item["qty"]),
639
  //"tvc_wt" => $p_weight,
640
+ "tvc_var" => esc_js($this->getAttributesVariation($_product)),
641
  /*"tvc_di" => $_product->get_dimensions(), //dimensions
642
  "tvc_ss" => $_product->is_in_stock(),
643
  "tvc_st" => $_product->get_stock_quantity(),
647
  );
648
  }else{
649
  $orderpage_prod_Array[get_permalink($_product->get_id())]=array(
650
+ "tvc_id" => esc_js($_product->get_id()),
651
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->get_id()),
652
+ "tvc_n" => esc_js($_product->get_title()),
653
  "tvc_p" => esc_js($order->get_item_total($item)),
654
  // "tvc_rp" => $_product->get_regular_price(),
655
  // "tvc_sp" => $_product->get_sale_price(),
656
+ "tvc_pd" => esc_js($this->cal_prod_discount($_product->get_regular_price(), $_product->get_sale_price())),
657
+ "tvc_c" => esc_js($categories),
658
+ "tvc_attr" => esc_js($attributes),
659
  "tvc_q"=>esc_js($item["qty"]),
660
  //"tvc_wt" => $p_weight,
661
+ "tvc_var" => esc_js($this->getAttributesVariation($_product)),
662
  /*"tvc_di" => $_product->get_dimensions(), //dimensions
663
  "tvc_ss" => $_product->is_in_stock(),
664
  "tvc_st" => $_product->get_stock_quantity(),
696
  "revenue"=>esc_js($order->get_total()), // Grand Total
697
  "tax"=> esc_js($order->get_total_tax()), // Tax
698
  "shipping"=> esc_js($tvc_sc), // Shipping
699
+ "coupon"=>esc_js($coupons_list),
700
  "total_discount"=>esc_js($order->get_total_discount()),
701
+ "user_bill_addr"=>esc_js($user_bill_addr),
702
+ "user_ship_addr"=>esc_js($user_ship_addr),
703
  "user_type"=>esc_js($this->tvc_options["user_type"]),
704
+ "payment_method"=> esc_js($order->get_payment_method())
705
  );
706
  $this->wc_version_compare("tvc_td=" . json_encode($orderpage_trans_Array) . ";");
707
+
 
 
 
 
 
708
  ?>
709
  <script>
710
  window.addEventListener('load', call_thnkyou_page,true);
711
  function call_thnkyou_page(){
712
  tvc_js = new TVC_Enhanced(<?php echo json_encode($this->tvc_options); ?>);
713
+ tvc_js.thnkyou_page(<?php echo json_encode($orderpage_prod_Array); ?>, <?php echo json_encode($orderpage_trans_Array); ?>, "+<?php echo esc_js($order->get_status()); ?>+", <?php echo esc_js(time()); ?>);
714
  }
715
  </script>
716
  <?php
717
+ update_post_meta($order_id, "_tracked", 1);
718
  }
719
 
720
  /**
778
 
779
  if(version_compare($woocommerce->version, "2.7", "<")){
780
  $prodpage_detail_json = array(
781
+ "tvc_id" => esc_js($product->id),
782
+ "tvc_i" => $product->get_sku() ? esc_js($product->get_sku()) : esc_js($product->id),
783
+ "tvc_n" => esc_js($product->get_title()),
784
+ "tvc_c" => esc_js($categories),
785
+ "tvc_p" => esc_js($product->get_price()),
786
+ "tvc_pd" => esc_js($this->cal_prod_discount($product->regular_price, $product->sale_price)),
787
+ "tvc_ps" => esc_js($product->get_stock_status()),
788
+ "tvc_tst" => esc_js($product->get_total_stock()),
789
+ "tvc_q" => esc_js($product->get_stock_quantity()),
790
+ "tvc_var" => esc_js($this->getAttributesVariation($product)),
791
+ "is_featured" => esc_js($product->is_featured()),
792
+ "is_onSale" => esc_js($product->is_on_sale())
793
  );
794
  }else{
795
  $prodpage_detail_json = array(
796
+ "tvc_id" => esc_js($product->get_id()),
797
+ "tvc_i" => $product->get_sku() ? esc_js($product->get_sku()) : esc_js($product->get_id()),
798
+ "tvc_n" => esc_js($product->get_title()),
799
+ "tvc_c" => esc_js($categories),
800
+ "tvc_p" => esc_js($product->get_price()),
801
+ "tvc_pd" => esc_js($this->cal_prod_discount($product->get_regular_price(), $product->get_sale_price())),
802
+ "tvc_ps" => esc_js($product->get_stock_status()),
803
+ "tvc_tst" => esc_js($product->get_stock_quantity()),
804
+ "tvc_q" => esc_js($product->get_stock_quantity()),
805
+ "tvc_var" => esc_js($this->getAttributesVariation($product)),
806
+ "is_featured" => esc_js($product->is_featured()),
807
+ "is_onSale" => esc_js($product->is_on_sale())
808
  );
809
  }
810
  //prod page detail view json
860
 
861
  // ATC link Array
862
  if(version_compare($woocommerce->version, "2.7", "<")){
863
+ $homepage_json_ATC_link[$product->add_to_cart_url()]=
864
+ array(
865
+ "ATC-link"=>esc_url_raw(get_permalink($product->id))
866
+ );
867
  }else{
868
+ $homepage_json_ATC_link[$product->add_to_cart_url()]=
869
+ array(
870
+ "ATC-link"=>esc_url_raw(get_permalink($product->get_id()))
871
+ );
872
  }
873
  //check if product is featured product or not
874
  if ($product->is_featured()) {
876
  if(version_compare($woocommerce->version, "2.7", "<")){
877
  if(!array_key_exists(get_permalink($product->id),$homepage_json_fp)){
878
  $homepage_json_fp[get_permalink($product->id)] = array(
879
+ "tvc_id" => esc_js($product->id),
880
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
881
+ "tvc_n" => esc_js($product->get_title()),
882
+ "tvc_p" => esc_js($product->get_price()),
883
+ "tvc_c" => esc_js($categories),
884
+ "ATC-link"=> esc_url_raw($product->add_to_cart_url())
885
  );
886
  //else add product in homepage recent product json
887
  }else {
888
  $homepage_json_rp[get_permalink($product->get_id())] =array(
889
+ "tvc_id" => esc_js($product->get_id()),
890
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
891
+ "tvc_n" => esc_js($product->get_title()),
892
+ "tvc_p" => esc_js($product->get_price()),
893
+ "tvc_c" => esc_js($categories)
894
  );
895
  }
896
  }else{
897
  if(!array_key_exists(get_permalink($product->get_id()),$homepage_json_fp)){
898
  $homepage_json_fp[get_permalink($product->get_id())] = array(
899
+ "tvc_id" => esc_js($product->get_id()),
900
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
901
+ "tvc_n" => esc_js($product->get_title()),
902
+ "tvc_p" => esc_js($product->get_price()),
903
+ "tvc_c" => esc_js($categories),
904
+ "ATC-link"=> esc_url_raw($product->add_to_cart_url())
905
  );
906
  //else add product in homepage recent product json
907
  }else {
908
  $homepage_json_rp[get_permalink($product->get_id())] =array(
909
+ "tvc_id" => esc_js($product->get_id()),
910
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
911
+ "tvc_n" => esc_js($product->get_title()),
912
+ "tvc_p" => esc_js($product->get_price()),
913
+ "tvc_c" => esc_js($categories)
914
  );
915
  }
916
  }
919
  //else prod add in homepage recent json
920
  if(version_compare($woocommerce->version, "2.7", "<")){
921
  $homepage_json_rp[get_permalink($product->id)] =array(
922
+ "tvc_id" => esc_js($product->id),
923
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
924
+ "tvc_n" => esc_js($product->get_title()),
925
+ "tvc_p" => esc_js($product->get_price()),
926
+ "tvc_c" => esc_js($categories)
927
  );
928
  }else{
929
  $homepage_json_rp[get_permalink($product->get_id())] =array(
930
+ "tvc_id" => esc_js($product->get_id()),
931
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
932
+ "tvc_n" => esc_js($product->get_title()),
933
+ "tvc_p" => esc_js($product->get_price()),
934
+ "tvc_c" => esc_js($categories)
935
  );
936
  }
937
 
945
  }
946
  // ATC link Array
947
  if(version_compare($woocommerce->version, "2.7", "<")){
948
+ $prodpage_json_ATC_link[$product->add_to_cart_url()]=
949
+ array(
950
+ "ATC-link"=> esc_url_raw(get_permalink($product->id))
951
+ );
952
 
953
  $prodpage_json_relProd[get_permalink($product->id)] = array(
954
+ "tvc_id" => esc_js($product->id),
955
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
956
+ "tvc_n" => esc_js($product->get_title()),
957
+ "tvc_p" => esc_js($product->get_price()),
958
+ "tvc_c" => esc_js($categories),
959
  );
960
  }else{
961
+ $prodpage_json_ATC_link[$product->add_to_cart_url()]=
962
+ array(
963
+ "ATC-link"=> esc_url_raw(get_permalink($product->get_id()))
964
+ );
965
 
966
  $prodpage_json_relProd[get_permalink($product->get_id())] = array(
967
+ "tvc_id" => esc_js($product->get_id()),
968
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
969
+ "tvc_n" => esc_js($product->get_title()),
970
+ "tvc_p" => esc_js($product->get_price()),
971
+ "tvc_c" => esc_js($categories)
972
 
973
  );
974
  }
981
  }
982
  //cat page ATC array
983
  if(version_compare($woocommerce->version, "2.7", "<")){
984
+ $catpage_json_ATC_link[$product->add_to_cart_url()]=
985
+ array(
986
+ "ATC-link"=>esc_url_raw(get_permalink($product->id))
987
+ );
988
 
989
  $catpage_json[get_permalink($product->id)] =array(
990
+ "tvc_id" => esc_js($product->id),
991
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
992
+ "tvc_n" => esc_js($product->get_title()),
993
+ "tvc_p" => esc_js($product->get_price()),
994
+ "tvc_c" => esc_js($categories),
995
  );
996
  }else{
997
+ $catpage_json_ATC_link[$product->add_to_cart_url()]=
998
+ array(
999
+ "ATC-link"=>esc_url_raw(get_permalink($product->get_id()))
1000
+ );
1001
 
1002
  $catpage_json[get_permalink($product->get_id())] =array(
1003
+ "tvc_id" => esc_js($product->get_id()),
1004
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
1005
+ "tvc_n" => esc_js($product->get_title()),
1006
+ "tvc_p" => esc_js($product->get_price()),
1007
+ "tvc_c" => esc_js($categories)
1008
 
1009
  );
1010
  }
1370
  //Prod ATC link click in related product section
1371
  jQuery("a[href*=add-to-cart]").on("click",function(){
1372
  t_url=jQuery(this).attr("href");
1373
+
1374
  t_qty=$(this).parent().find("input[name=quantity]").val();
1375
  //default quantity 1 if quantity box is not there
1376
  if(t_qty=="" || t_qty===undefined){
1465
  $categories = rtrim($categories, ",");
1466
  if(version_compare($woocommerce->version, "2.7", "<")){
1467
  $cartpage_prod_array_main[$cart_remove_link] =array(
1468
+ "tvc_id" => esc_js($prod_meta->ID),
1469
+ "tvc_i" => esc_js($prod_meta->get_sku() ? $prod_meta->get_sku() : $prod_meta->ID),
1470
+ "tvc_n" => html_entity_decode(esc_js($prod_meta->get_title())),
1471
+ "tvc_p" => esc_js($prod_meta->get_price()),
1472
+ "tvc_c" => esc_js($categories),
1473
+ "tvc_q"=> esc_js($woocommerce->cart->cart_contents[$key]["quantity"])
1474
  );
1475
  }else{
1476
  $cartpage_prod_array_main[$cart_remove_link] =array(
1477
+ "tvc_id" => esc_js($prod_meta->get_id()),
1478
+ "tvc_i" => esc_js($prod_meta->get_sku() ? $prod_meta->get_sku() : $prod_meta->get_id()),
1479
+ "tvc_n" => html_entity_decode(esc_js($prod_meta->get_title())),
1480
+ "tvc_p" => esc_js($prod_meta->get_price()),
1481
+ "tvc_c" => esc_js($categories),
1482
+ "tvc_q"=>esc_js($woocommerce->cart->cart_contents[$key]["quantity"])
1483
  );
1484
  }
1485
  }
1710
  $categories = rtrim($categories, ",");
1711
  if(version_compare($woocommerce->version, "2.7", "<")){
1712
  $chkout_json[get_permalink($p->ID)] = array(
1713
+ "tvc_id" => esc_js($p->ID),
1714
  "tvc_i" => esc_js($p->get_sku() ? $p->get_sku() : $p->ID),
1715
+ "tvc_n" => html_entity_decode(esc_js($p->get_title())),
1716
  "tvc_p" => esc_js($p->get_price()),
1717
+ "tvc_c" => esc_js($categories),
1718
  "tvc_q" => esc_js($item["quantity"]),
1719
+ "isfeatured"=>esc_js($p->is_featured())
1720
  );
1721
  }else{
1722
  $chkout_json[get_permalink($p->get_id())] = array(
1723
+ "tvc_id" => esc_js($p->get_id()),
1724
  "tvc_i" => esc_js($p->get_sku() ? $p->get_sku() : $p->get_id()),
1725
+ "tvc_n" => html_entity_decode(esc_js($p->get_title())),
1726
  "tvc_p" => esc_js($p->get_price()),
1727
+ "tvc_c" => esc_js($categories),
1728
  "tvc_q" => esc_js($item["quantity"]),
1729
+ "isfeatured"=>esc_js($p->is_featured())
1730
  );
1731
  }
1732
  }
public/class-enhanced-ecommerce-google-analytics-public.php CHANGED
@@ -167,8 +167,8 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
167
  public function add_google_site_verification_tag(){
168
  $TVC_Admin_Helper = new TVC_Admin_Helper();
169
  $ee_additional_data = $TVC_Admin_Helper->get_ee_additional_data();
170
- if(isset($ee_additional_data['add_site_varification_tag']) && isset($ee_additional_data['site_varification_tag_val']) && esc_attr($ee_additional_data['add_site_varification_tag']) == 1 && esc_html($ee_additional_data['site_varification_tag_val']) !="" ){
171
- echo base64_decode(esc_html($ee_additional_data['site_varification_tag_val']));
172
  }
173
 
174
  }
@@ -194,24 +194,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
194
  $google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
195
  $sub_data = array();
196
  if(isset($google_detail['setting'])){
197
- $googleDetail = $google_detail['setting'];
198
- $sub_data['sub_id'] = sanitize_text_field(isset($googleDetail->id)?esc_attr($googleDetail->id):"");
199
- $sub_data['cu_id']=sanitize_text_field(isset($googleDetail->customer_id)?esc_attr($googleDetail->customer_id):"");
200
- $sub_data['pl_id']=sanitize_text_field(isset($googleDetail->plan_id)?esc_attr($googleDetail->plan_id):"");
201
- $sub_data['ga_tra_option']=sanitize_text_field(isset($googleDetail->tracking_option)?esc_attr($googleDetail->tracking_option):"");
202
- $sub_data['ga_property_id']=sanitize_text_field(isset($googleDetail->property_id)?esc_attr($googleDetail->property_id):"");
203
- $sub_data['ga_measurement_id']=sanitize_text_field(isset($googleDetail->measurement_id)?esc_attr($googleDetail->measurement_id):"");
204
- $sub_data['ga_ads_id']=sanitize_text_field(isset($googleDetail->google_ads_id)?esc_attr($googleDetail->google_ads_id):"");
205
- $sub_data['ga_gmc_id']= sanitize_text_field(isset($googleDetail->google_merchant_center_id)?esc_attr($googleDetail->google_merchant_center_id):"");
206
- $sub_data['op_gtag_js']=sanitize_text_field(isset($googleDetail->add_gtag_snippet)?esc_attr($googleDetail->add_gtag_snippet):"");
207
- $sub_data['op_en_e_t']=sanitize_text_field(isset($googleDetail->enhanced_e_commerce_tracking)?esc_attr($googleDetail->enhanced_e_commerce_tracking):"");
208
- $sub_data['op_rm_t_t']=sanitize_text_field(isset($googleDetail->remarketing_tags)?esc_attr($googleDetail->remarketing_tags):"");
209
- $sub_data['op_dy_rm_t_t']=sanitize_text_field(isset($googleDetail->dynamic_remarketing_tags)?esc_attr($googleDetail->dynamic_remarketing_tags):"");
210
- $sub_data['op_li_ga_wi_ads']=sanitize_text_field(isset($googleDetail->link_google_analytics_with_google_ads)?esc_attr($googleDetail->link_google_analytics_with_google_ads):"");
211
- $sub_data['gmc_is_product_sync']=sanitize_text_field(isset($googleDetail->is_product_sync)?$googleDetail->is_product_sync:"");
212
- $sub_data['gmc_is_site_verified']=sanitize_text_field(isset($googleDetail->is_site_verified)?esc_attr($googleDetail->is_site_verified):"");
213
- $sub_data['gmc_is_domain_claim']=sanitize_text_field(isset($googleDetail->is_domain_claim)?esc_attr($googleDetail->is_domain_claim):"");
214
- $sub_data['gmc_product_count']=sanitize_text_field(isset($googleDetail->product_count)?esc_attr($googleDetail->product_count):"");
215
  }
216
  $tvc_sMetaData = array(
217
  'tvc_wcv' => esc_js($woocommerce->version),
@@ -227,7 +210,25 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
227
  't_OptOut' => esc_js($this->ga_OPTOUT),
228
  't_PrivacyPolicy' => esc_js($this->ga_PrivacyPolicy)
229
  ),
230
- 'tvc_sub_data'=> $sub_data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  );
232
  $this->wc_version_compare("tvc_smd=" . json_encode($tvc_sMetaData) . ";");
233
  }
@@ -237,7 +238,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
237
  * @since4.0.0
238
  */
239
  public function enqueue_scripts() {
240
- //wp_enqueue_script($this->plugin_name, ENHANCAD_PLUGIN_URL . '/public/js/tvc-ee-google-analytics.js', array('jquery'), $this->version, false);
241
  }
242
 
243
  /**
@@ -300,7 +301,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
300
  global $woocommerce;
301
 
302
  //common validation----start
303
- if (is_admin() || esc_attr($this->ga_ST) == "" || current_user_can("manage_options")) {
304
  return;
305
  }
306
 
@@ -320,83 +321,78 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
320
  $ga_ip_anonymization = '"anonymize_ip":true,';
321
  } else {
322
  $ga_ip_anonymization ="";
323
- }
324
-
325
-
326
- echo '<script type="text/javascript" defer="defer">';
327
- echo 'var track_option = '.json_encode(esc_js($tracking_opt)).';';
328
- echo 'var ua_track_id = '.json_encode(esc_js($tracking_id)).';';
329
- echo 'var ga4_measure_id = '.json_encode(esc_js($measurment_id)).';';
330
- echo 'var adsTringId = '.json_encode(esc_js($this->ads_tracking_id)).';';
331
- echo 'var ads_ert = '.json_encode(esc_js($this->ads_ert)).';';
332
- echo 'var ads_edrt = '.json_encode(esc_js($this->ads_edrt)).';';
333
- echo 'var remarketing_snippet_id = '.json_encode(esc_js($this->remarketing_snippet_id)).';';
334
- echo '</script>';
335
-
336
  if($this->ga_OPTOUT) {
337
- echo '<script>
338
- // Set to the same value as the web property used on the site
339
- var gaProperty = "'.esc_js($tracking_id).'";
340
-
341
- // Disable tracking if the opt-out cookie exists.
342
- var disableStr = "ga-disable-" + gaProperty;
343
- if (document.cookie.indexOf(disableStr + "=true") > -1) {
344
- window[disableStr] = true;
345
- }
346
-
347
- // Opt-out function
348
- function gaOptout() {
349
- var expDate = new Date;
350
- expDate.setMonth(expDate.getMonth() + 26);
351
- document.cookie = disableStr + "=true; expires="+expDate.toGMTString()+";path=/";
352
- window[disableStr] = true;
353
- }
354
- </script>';
355
  }
356
 
357
- if(($tracking_opt == "UA" || $tracking_id || $tracking_opt == "") && $tracking_opt != "BOTH"){
358
- //$id = esc_js($tracking_id);
359
- echo '<script async src="https://www.googletagmanager.com/gtag/js?id='.esc_js($tracking_id).'"></script>
360
- <script>
361
- window.dataLayer = window.dataLayer || [];
362
- function gtag(){dataLayer.push(arguments);}
363
- gtag("js", new Date());
364
- gtag("config", "'.esc_js($tracking_id).'",{'.$ga_ip_anonymization.' "cookie_domain":"'.esc_js($set_domain_name).'"});
365
- </script>
366
- ';
367
- //echo $code;
368
  }
369
 
370
- if($tracking_opt == "GA4"){
371
- echo '<script async src="https://www.googletagmanager.com/gtag/js?id='.esc_js($measurment_id).'"></script>
372
- <script>
373
- window.dataLayer = window.dataLayer || [];
374
- function gtag(){dataLayer.push(arguments);}
375
- gtag("js", new Date());
376
- gtag("config", "'.esc_js($measurment_id).'",{'.$ga_ip_anonymization.' "cookie_domain":"'.esc_js($set_domain_name).'"});
377
- </script>
378
- ';
379
-
380
  }
381
- if($tracking_opt == "BOTH"){
382
- echo '<script async src="https://www.googletagmanager.com/gtag/js?id='.esc_js($measurment_id).'"></script>
383
- <script>
384
- window.dataLayer = window.dataLayer || [];
385
- function gtag(){dataLayer.push(arguments);}
386
- gtag("js", new Date());
387
- gtag("config", "'.esc_js($measurment_id).'",{'.$ga_ip_anonymization.' "cookie_domain":"'.esc_js($set_domain_name).'"});
388
- gtag("config", "'.esc_js($tracking_id).'");
389
- </script>
390
- ';
391
  }
392
  if($this->ads_ert || $this->ads_edrt){
393
  if(!empty($this->remarketing_snippets) && $this->remarketing_snippets){
394
- echo $this->remarketing_snippets;
395
  }else{
396
  $google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
397
  if(isset($google_detail['setting'])){
398
  $googleDetail = $google_detail['setting'];
399
- echo esc_js($googleDetail->google_ads_snippets);
400
  }
401
  }
402
  }
@@ -430,8 +426,9 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
430
  $i = 1;
431
  foreach ($order->get_coupon_codes() as $coupon) {
432
  $coupons_list .= $coupon;
433
- if ($i < $coupons_count)
434
  $coupons_list .= ', ';
 
435
  $i++;
436
  }
437
  }
@@ -441,8 +438,9 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
441
  $i = 1;
442
  foreach ($order->get_used_coupons() as $coupon) {
443
  $coupons_list .= $coupon;
444
- if ($i < $coupons_count)
445
  $coupons_list .= ', ';
 
446
  $i++;
447
  }
448
  }
@@ -491,42 +489,42 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
491
  if (isset($_product->variation_data)) {
492
  if(version_compare($woocommerce->version, "2.7", "<")){
493
  $orderpage_prod_Array[get_permalink($_product->ID)]=array(
494
- "tvc_id" => esc_html($_product->ID),
495
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->ID),
496
- "tvc_n" => html_entity_decode($item["name"]),
497
  "tvc_p" => esc_js($order->get_item_total($item)),
498
- "tvc_c" => $categories,
499
- "tvc_attr" => $attributes,
500
  "tvc_q"=>esc_js($item["qty"])
501
  );
502
  }else{
503
  $orderpage_prod_Array[get_permalink($_product->get_id())]=array(
504
- "tvc_id" => esc_html($_product->get_id()),
505
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->get_id()),
506
- "tvc_n" => html_entity_decode($item["name"]),
507
  "tvc_p" => esc_js($order->get_item_total($item)),
508
- "tvc_c" => $categories,
509
- "tvc_attr" => $attributes,
510
  "tvc_q"=>esc_js($item["qty"])
511
  );
512
  }
513
  } else {
514
  if(version_compare($woocommerce->version, "2.7", "<")){
515
  $orderpage_prod_Array[get_permalink($_product->ID)]=array(
516
- "tvc_id" => esc_html($_product->ID),
517
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->ID),
518
- "tvc_n" => html_entity_decode($item["name"]),
519
  "tvc_p" => esc_js($order->get_item_total($item)),
520
- "tvc_c" => $categories,
521
  "tvc_q"=>esc_js($item["qty"])
522
  );
523
  }else{
524
  $orderpage_prod_Array[get_permalink($_product->get_id())]=array(
525
- "tvc_id" => esc_html($_product->get_id()),
526
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->get_id()),
527
- "tvc_n" => html_entity_decode($_product->get_title()),
528
  "tvc_p" => esc_js($order->get_item_total($item)),
529
- "tvc_c" => $categories,
530
  "tvc_q"=>esc_js($item["qty"])
531
  );
532
  }
@@ -550,7 +548,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
550
  "revenue"=>esc_js($order->get_total()), // Grand Total
551
  "tax"=> esc_js($order->get_total_tax()), // Tax
552
  "shipping"=> esc_js($tvc_sc), // Shipping
553
- "coupon"=>$coupons_list
554
  );
555
  //make json for trans data on order page
556
  $this->wc_version_compare("tvc_td=" . json_encode($orderpage_trans_Array) . ";");
@@ -603,7 +601,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
603
 
604
  //check woocommerce version
605
  $this->wc_version_compare($code);
606
- update_post_meta($order_id, "_tracked", sanitize_option("_tracked",1));
607
  }
608
  // start GA4 or Both
609
  if( $this->gm_id && $this->tracking_option == "GA4") {
@@ -792,19 +790,19 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
792
  //product detail view json
793
  if(version_compare($woocommerce->version, "2.7", "<")){
794
  $prodpage_detail_json = array(
795
- "tvc_id" => esc_html($product->id),
796
- "tvc_i" => $product->get_sku() ? $product->get_sku() : $product->id,
797
- "tvc_n" => $product->get_title(),
798
- "tvc_c" => $categories,
799
- "tvc_p" => $product->get_price()
800
  );
801
  }else{
802
  $prodpage_detail_json = array(
803
- "tvc_id" => esc_html($product->get_id()),
804
- "tvc_i" => $product->get_sku() ? $product->get_sku() : $product->get_id(),
805
- "tvc_n" => $product->get_title(),
806
- "tvc_c" => $categories,
807
- "tvc_p" => $product->get_price()
808
  );
809
  }
810
 
@@ -924,9 +922,15 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
924
 
925
  // ATC link Array
926
  if(version_compare($woocommerce->version, "2.7", "<")){
927
- $homepage_json_ATC_link[$product->add_to_cart_url()]=array("ATC-link"=>get_permalink($product->id));
 
 
 
928
  }else{
929
- $homepage_json_ATC_link[$product->add_to_cart_url()]=array("ATC-link"=>get_permalink($product->get_id()));
 
 
 
930
  }
931
  //check if product is featured product or not
932
  if ($product->is_featured()) {
@@ -934,41 +938,41 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
934
  if(version_compare($woocommerce->version, "2.7", "<")){
935
  if(!array_key_exists(get_permalink($product->id),$homepage_json_fp)){
936
  $homepage_json_fp[get_permalink($product->id)] = array(
937
- "tvc_id" => esc_html($product->id),
938
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->id),
939
- "tvc_n" => esc_html($product->get_title()),
940
- "tvc_p" => esc_html($product->get_price()),
941
- "tvc_c" => esc_html($categories),
942
- "ATC-link"=>$product->add_to_cart_url()
943
  );
944
  //else add product in homepage recent product json
945
  }else {
946
  $homepage_json_rp[get_permalink($product->get_id())] =array(
947
- "tvc_id" => esc_html($product->get_id()),
948
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->id),
949
- "tvc_n" => esc_html($product->get_title()),
950
- "tvc_p" => esc_html($product->get_price()),
951
- "tvc_c" => esc_html($categories)
952
  );
953
  }
954
  }else{
955
  if(!array_key_exists(get_permalink($product->get_id()),$homepage_json_fp)){
956
  $homepage_json_fp[get_permalink($product->get_id())] = array(
957
- "tvc_id" => esc_html($product->get_id()),
958
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->get_id()),
959
- "tvc_n" => esc_html($product->get_title()),
960
- "tvc_p" => esc_html($product->get_price()),
961
- "tvc_c" => esc_html($categories),
962
- "ATC-link"=>$product->add_to_cart_url()
963
  );
964
  //else add product in homepage recent product json
965
  }else {
966
  $homepage_json_rp[get_permalink($product->get_id())] =array(
967
- "tvc_id" => esc_html($product->get_id()),
968
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->get_id()),
969
- "tvc_n" => esc_html($product->get_title()),
970
- "tvc_p" => esc_html($product->get_price()),
971
- "tvc_c" => esc_html($categories)
972
  );
973
  }
974
  }
@@ -977,19 +981,19 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
977
  //else prod add in homepage recent json
978
  if(version_compare($woocommerce->version, "2.7", "<")){
979
  $homepage_json_rp[get_permalink($product->id)] =array(
980
- "tvc_id" => esc_html($product->id),
981
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->id),
982
- "tvc_n" => esc_html($product->get_title()),
983
- "tvc_p" => esc_html($product->get_price()),
984
- "tvc_c" => esc_html($categories)
985
  );
986
  }else{
987
  $homepage_json_rp[get_permalink($product->get_id())] =array(
988
- "tvc_id" => esc_html($product->get_id()),
989
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->get_id()),
990
- "tvc_n" => esc_html($product->get_title()),
991
- "tvc_p" => esc_html($product->get_price()),
992
- "tvc_c" => esc_html($categories)
993
  );
994
  }
995
 
@@ -1003,24 +1007,30 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
1003
  }
1004
  // ATC link Array
1005
  if(version_compare($woocommerce->version, "2.7", "<")){
1006
- $prodpage_json_ATC_link[$product->add_to_cart_url()]=array("ATC-link"=>get_permalink($product->id));
 
 
 
1007
 
1008
  $prodpage_json_relProd[get_permalink($product->id)] = array(
1009
- "tvc_id" => esc_html($product->id),
1010
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->id),
1011
- "tvc_n" => esc_html($product->get_title()),
1012
- "tvc_p" => esc_html($product->get_price()),
1013
- "tvc_c" => esc_html($categories),
1014
  );
1015
  }else{
1016
- $prodpage_json_ATC_link[$product->add_to_cart_url()]=array("ATC-link"=>get_permalink($product->get_id()));
 
 
 
1017
 
1018
  $prodpage_json_relProd[get_permalink($product->get_id())] = array(
1019
- "tvc_id" => esc_html($product->get_id()),
1020
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->get_id()),
1021
- "tvc_n" => esc_html($product->get_title()),
1022
- "tvc_p" => esc_html($product->get_price()),
1023
- "tvc_c" => esc_html($categories)
1024
 
1025
  );
1026
  }
@@ -1033,24 +1043,29 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
1033
  }
1034
  //cat page ATC array
1035
  if(version_compare($woocommerce->version, "2.7", "<")){
1036
- $catpage_json_ATC_link[$product->add_to_cart_url()]=array("ATC-link"=>get_permalink($product->id));
 
 
 
1037
 
1038
  $catpage_json[get_permalink($product->id)] =array(
1039
- "tvc_id" => esc_html($product->id),
1040
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->id),
1041
- "tvc_n" => esc_html($product->get_title()),
1042
- "tvc_p" => esc_html($product->get_price()),
1043
- "tvc_c" => esc_html($categories),
1044
  );
1045
  }else{
1046
- $catpage_json_ATC_link[$product->add_to_cart_url()]=array("ATC-link"=>get_permalink($product->get_id()));
 
 
1047
 
1048
  $catpage_json[get_permalink($product->get_id())] =array(
1049
- "tvc_id" => esc_html($product->get_id()),
1050
- "tvc_i" => esc_html($product->get_sku() ? $product->get_sku() : $product->get_id()),
1051
- "tvc_n" => esc_html($product->get_title()),
1052
- "tvc_p" => esc_html($product->get_price()),
1053
- "tvc_c" => esc_html($categories)
1054
 
1055
  );
1056
  }
@@ -1516,21 +1531,21 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
1516
  $categories = rtrim($categories, ",");
1517
  if(version_compare($woocommerce->version, "2.7", "<")){
1518
  $cartpage_prod_array_main[$cart_remove_link] =array(
1519
- "tvc_id" => esc_html($prod_meta->ID),
1520
- "tvc_i" => esc_html($prod_meta->get_sku() ? $prod_meta->get_sku() : $prod_meta->ID),
1521
- "tvc_n" => html_entity_decode($prod_meta->get_title()),
1522
- "tvc_p" => esc_html($prod_meta->get_price()),
1523
- "tvc_c" => esc_html($categories),
1524
- "tvc_q"=>$woocommerce->cart->cart_contents[$key]["quantity"]
1525
  );
1526
  }else{
1527
  $cartpage_prod_array_main[$cart_remove_link] =array(
1528
- "tvc_id" => esc_html($prod_meta->get_id()),
1529
- "tvc_i" => esc_html($prod_meta->get_sku() ? $prod_meta->get_sku() : $prod_meta->get_id()),
1530
- "tvc_n" => html_entity_decode($prod_meta->get_title()),
1531
- "tvc_p" => esc_html($prod_meta->get_price()),
1532
- "tvc_c" => esc_html($categories),
1533
- "tvc_q"=>$woocommerce->cart->cart_contents[$key]["quantity"]
1534
  );
1535
  }
1536
  }
@@ -1761,23 +1776,23 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
1761
  $categories = rtrim($categories, ",");
1762
  if(version_compare($woocommerce->version, "2.7", "<")){
1763
  $chkout_json[get_permalink($p->ID)] = array(
1764
- "tvc_id" => esc_html($p->ID),
1765
  "tvc_i" => esc_js($p->get_sku() ? $p->get_sku() : $p->ID),
1766
- "tvc_n" => html_entity_decode($p->get_title()),
1767
  "tvc_p" => esc_js($p->get_price()),
1768
- "tvc_c" => $categories,
1769
  "tvc_q" => esc_js($item["quantity"]),
1770
- "isfeatured"=>$p->is_featured()
1771
  );
1772
  }else{
1773
  $chkout_json[get_permalink($p->get_id())] = array(
1774
- "tvc_id" => esc_html($p->get_id()),
1775
  "tvc_i" => esc_js($p->get_sku() ? $p->get_sku() : $p->get_id()),
1776
- "tvc_n" => html_entity_decode($p->get_title()),
1777
  "tvc_p" => esc_js($p->get_price()),
1778
- "tvc_c" => $categories,
1779
  "tvc_q" => esc_js($item["quantity"]),
1780
- "isfeatured"=>$p->is_featured()
1781
  );
1782
  }
1783
  }
167
  public function add_google_site_verification_tag(){
168
  $TVC_Admin_Helper = new TVC_Admin_Helper();
169
  $ee_additional_data = $TVC_Admin_Helper->get_ee_additional_data();
170
+ if(isset($ee_additional_data['add_site_varification_tag']) && isset($ee_additional_data['site_varification_tag_val']) && $ee_additional_data['add_site_varification_tag'] == 1 && $ee_additional_data['site_varification_tag_val'] !="" ){
171
+ echo html_entity_decode(esc_html(base64_decode($ee_additional_data['site_varification_tag_val'])));
172
  }
173
 
174
  }
194
  $google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
195
  $sub_data = array();
196
  if(isset($google_detail['setting'])){
197
+ $googleDetail = $google_detail['setting'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  }
199
  $tvc_sMetaData = array(
200
  'tvc_wcv' => esc_js($woocommerce->version),
210
  't_OptOut' => esc_js($this->ga_OPTOUT),
211
  't_PrivacyPolicy' => esc_js($this->ga_PrivacyPolicy)
212
  ),
213
+ 'tvc_sub_data'=> array(
214
+ 'sub_id' =>esc_js(isset($googleDetail->id)?sanitize_text_field($googleDetail->id):""),
215
+ 'cu_id' => esc_js(isset($googleDetail->customer_id)?sanitize_text_field($googleDetail->customer_id):""),
216
+ 'pl_id' => esc_js(isset($googleDetail->plan_id)?sanitize_text_field($googleDetail->plan_id):""),
217
+ 'ga_tra_option' => esc_js(isset($googleDetail->tracking_option)?sanitize_text_field($googleDetail->tracking_option):""),
218
+ 'ga_property_id' => esc_js(isset($googleDetail->property_id)?sanitize_text_field($googleDetail->property_id):""),
219
+ 'ga_measurement_id' => esc_js(isset($googleDetail->measurement_id)?sanitize_text_field($googleDetail->measurement_id):""),
220
+ 'ga_ads_id' => esc_js(isset($googleDetail->google_ads_id)?sanitize_text_field($googleDetail->google_ads_id):""),
221
+ 'ga_gmc_id' => esc_js(isset($googleDetail->google_merchant_center_id)?sanitize_text_field($googleDetail->google_merchant_center_id):""),
222
+ 'op_gtag_js' => esc_js(isset($googleDetail->add_gtag_snippet)?sanitize_text_field($googleDetail->add_gtag_snippet):""),
223
+ 'op_en_e_t' => esc_js(isset($googleDetail->enhanced_e_commerce_tracking)?sanitize_text_field($googleDetail->enhanced_e_commerce_tracking):""),
224
+ 'op_rm_t_t' => esc_js(isset($googleDetail->remarketing_tags)?sanitize_text_field($googleDetail->remarketing_tags):""),
225
+ 'op_dy_rm_t_t' => esc_js(isset($googleDetail->dynamic_remarketing_tags)?esc_attr($googleDetail->dynamic_remarketing_tags):""),
226
+ 'op_li_ga_wi_ads' => esc_js(isset($googleDetail->link_google_analytics_with_google_ads)?sanitize_text_field($googleDetail->link_google_analytics_with_google_ads):""),
227
+ 'gmc_is_product_sync' => esc_js(isset($googleDetail->is_product_sync)?sanitize_text_field($googleDetail->is_product_sync):""),
228
+ 'gmc_is_site_verified' => esc_js(isset($googleDetail->is_site_verified)?sanitize_text_field($googleDetail->is_site_verified):""),
229
+ 'gmc_is_domain_claim' => esc_js(isset($googleDetail->is_domain_claim)?sanitize_text_field($googleDetail->is_domain_claim):""),
230
+ 'gmc_product_count' => esc_js(isset($googleDetail->product_count)?sanitize_text_field($googleDetail->product_count):"")
231
+ )
232
  );
233
  $this->wc_version_compare("tvc_smd=" . json_encode($tvc_sMetaData) . ";");
234
  }
238
  * @since4.0.0
239
  */
240
  public function enqueue_scripts() {
241
+
242
  }
243
 
244
  /**
301
  global $woocommerce;
302
 
303
  //common validation----start
304
+ if (is_admin() || $this->ga_ST == "" || current_user_can("manage_options")) {
305
  return;
306
  }
307
 
321
  $ga_ip_anonymization = '"anonymize_ip":true,';
322
  } else {
323
  $ga_ip_anonymization ="";
324
+ } ?>
325
+ <script type="text/javascript" defer="defer">
326
+ var track_option = '<?php echo esc_js($tracking_opt); ?>';
327
+ var ua_track_id = '<?php echo esc_js($tracking_id); ?>';
328
+ var ga4_measure_id = '<?php echo esc_js($measurment_id); ?>';
329
+ var adsTringId = '<?php echo esc_js($this->ads_tracking_id); ?>';
330
+ var ads_ert = '<?php echo esc_js($this->ads_ert); ?>';
331
+ var ads_edrt = '<?php echo esc_js($this->ads_edrt); ?>';
332
+ var remarketing_snippet_id = '<?php echo esc_js($this->remarketing_snippet_id); ?>';
333
+ </script>
334
+ <?php
 
 
335
  if($this->ga_OPTOUT) {
336
+ ?>
337
+ <script>
338
+ // Set to the same value as the web property used on the site
339
+ var gaProperty = '<?php echo esc_js($tracking_id); ?>';
340
+ // Disable tracking if the opt-out cookie exists.
341
+ var disableStr = "ga-disable-" + gaProperty;
342
+ if (document.cookie.indexOf(disableStr + "=true") > -1) {
343
+ window[disableStr] = true;
344
+ }
345
+ // Opt-out function
346
+ function gaOptout() {
347
+ var expDate = new Date;
348
+ expDate.setMonth(expDate.getMonth() + 26);
349
+ document.cookie = disableStr + "=true; expires="+expDate.toGMTString()+";path=/";
350
+ window[disableStr] = true;
351
+ }
352
+ </script>
353
+ <?php
354
  }
355
 
356
+ if(($tracking_opt == "UA" || $tracking_id || $tracking_opt == "") && $tracking_opt != "BOTH"){?>
357
+ <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo esc_js($tracking_id); ?>"></script>
358
+ <script>
359
+ window.dataLayer = window.dataLayer || [];
360
+ function gtag(){dataLayer.push(arguments);}
361
+ gtag("js", new Date());
362
+ gtag("config", "<?php echo esc_js($tracking_id); ?>",{<?php echo $ga_ip_anonymization; ?> "cookie_domain":"<?php echo esc_js($set_domain_name); ?>"});
363
+ </script>
364
+ <?php
 
 
365
  }
366
 
367
+ if($tracking_opt == "GA4"){ ?>
368
+ <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo esc_js($measurment_id); ?>"></script>
369
+ <script>
370
+ window.dataLayer = window.dataLayer || [];
371
+ function gtag(){dataLayer.push(arguments);}
372
+ gtag("js", new Date());
373
+ gtag("config", "<?php echo esc_js($measurment_id); ?>",{<?php echo $ga_ip_anonymization; ?> "cookie_domain":"<?php echo esc_js($set_domain_name); ?>"});
374
+ </script>
375
+ <?php
 
376
  }
377
+ if($tracking_opt == "BOTH"){ ?>
378
+ <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo esc_js($measurment_id); ?>"></script>
379
+ <script>
380
+ window.dataLayer = window.dataLayer || [];
381
+ function gtag(){dataLayer.push(arguments);}
382
+ gtag("js", new Date());
383
+ gtag("config", "<?php echo esc_js($measurment_id); ?>",{ <?php echo $ga_ip_anonymization; ?> "cookie_domain":"<?php echo esc_js($set_domain_name); ?>"});
384
+ gtag("config", "<?php echo esc_js($tracking_id); ?>");
385
+ </script>
386
+ <?php
387
  }
388
  if($this->ads_ert || $this->ads_edrt){
389
  if(!empty($this->remarketing_snippets) && $this->remarketing_snippets){
390
+ echo html_entity_decode(str_replace("&#039;", "'", esc_html($this->remarketing_snippets)) );
391
  }else{
392
  $google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
393
  if(isset($google_detail['setting'])){
394
  $googleDetail = $google_detail['setting'];
395
+ echo html_entity_decode(str_replace("&#039;", "'", esc_html($googleDetail->google_ads_snippets)) );
396
  }
397
  }
398
  }
426
  $i = 1;
427
  foreach ($order->get_coupon_codes() as $coupon) {
428
  $coupons_list .= $coupon;
429
+ if ($i < $coupons_count){
430
  $coupons_list .= ', ';
431
+ }
432
  $i++;
433
  }
434
  }
438
  $i = 1;
439
  foreach ($order->get_used_coupons() as $coupon) {
440
  $coupons_list .= $coupon;
441
+ if ($i < $coupons_count){
442
  $coupons_list .= ', ';
443
+ }
444
  $i++;
445
  }
446
  }
489
  if (isset($_product->variation_data)) {
490
  if(version_compare($woocommerce->version, "2.7", "<")){
491
  $orderpage_prod_Array[get_permalink($_product->ID)]=array(
492
+ "tvc_id" => esc_js($_product->ID),
493
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->ID),
494
+ "tvc_n" => html_entity_decode(esc_js($item["name"])),
495
  "tvc_p" => esc_js($order->get_item_total($item)),
496
+ "tvc_c" => esc_js($categories),
497
+ "tvc_attr" => esc_js($attributes),
498
  "tvc_q"=>esc_js($item["qty"])
499
  );
500
  }else{
501
  $orderpage_prod_Array[get_permalink($_product->get_id())]=array(
502
+ "tvc_id" => esc_js($_product->get_id()),
503
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->get_id()),
504
+ "tvc_n" => html_entity_decode(esc_js($item["name"])),
505
  "tvc_p" => esc_js($order->get_item_total($item)),
506
+ "tvc_c" => esc_js($categories),
507
+ "tvc_attr" => esc_js($attributes),
508
  "tvc_q"=>esc_js($item["qty"])
509
  );
510
  }
511
  } else {
512
  if(version_compare($woocommerce->version, "2.7", "<")){
513
  $orderpage_prod_Array[get_permalink($_product->ID)]=array(
514
+ "tvc_id" => esc_js($_product->ID),
515
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->ID),
516
+ "tvc_n" => html_entity_decode(esc_js($item["name"])),
517
  "tvc_p" => esc_js($order->get_item_total($item)),
518
+ "tvc_c" => esc_js($categories),
519
  "tvc_q"=>esc_js($item["qty"])
520
  );
521
  }else{
522
  $orderpage_prod_Array[get_permalink($_product->get_id())]=array(
523
+ "tvc_id" => esc_js($_product->get_id()),
524
  "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->get_id()),
525
+ "tvc_n" => esc_js($_product->get_title()),
526
  "tvc_p" => esc_js($order->get_item_total($item)),
527
+ "tvc_c" => esc_js($categories),
528
  "tvc_q"=>esc_js($item["qty"])
529
  );
530
  }
548
  "revenue"=>esc_js($order->get_total()), // Grand Total
549
  "tax"=> esc_js($order->get_total_tax()), // Tax
550
  "shipping"=> esc_js($tvc_sc), // Shipping
551
+ "coupon"=>esc_js($coupons_list)
552
  );
553
  //make json for trans data on order page
554
  $this->wc_version_compare("tvc_td=" . json_encode($orderpage_trans_Array) . ";");
601
 
602
  //check woocommerce version
603
  $this->wc_version_compare($code);
604
+ update_post_meta($order_id, "_tracked", 1);
605
  }
606
  // start GA4 or Both
607
  if( $this->gm_id && $this->tracking_option == "GA4") {
790
  //product detail view json
791
  if(version_compare($woocommerce->version, "2.7", "<")){
792
  $prodpage_detail_json = array(
793
+ "tvc_id" => esc_js($product->id),
794
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
795
+ "tvc_n" => esc_js($product->get_title()),
796
+ "tvc_c" => esc_js($categories),
797
+ "tvc_p" => esc_js($product->get_price())
798
  );
799
  }else{
800
  $prodpage_detail_json = array(
801
+ "tvc_id" => esc_js($product->get_id()),
802
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
803
+ "tvc_n" => esc_js($product->get_title()),
804
+ "tvc_c" => esc_js($categories),
805
+ "tvc_p" => esc_js($product->get_price())
806
  );
807
  }
808
 
922
 
923
  // ATC link Array
924
  if(version_compare($woocommerce->version, "2.7", "<")){
925
+ $homepage_json_ATC_link[$product->add_to_cart_url()]=
926
+ array(
927
+ "ATC-link"=> esc_url_raw(get_permalink($product->id))
928
+ );
929
  }else{
930
+ $homepage_json_ATC_link[$product->add_to_cart_url()]=
931
+ array(
932
+ "ATC-link"=> esc_url_raw(get_permalink($product->get_id()))
933
+ );
934
  }
935
  //check if product is featured product or not
936
  if ($product->is_featured()) {
938
  if(version_compare($woocommerce->version, "2.7", "<")){
939
  if(!array_key_exists(get_permalink($product->id),$homepage_json_fp)){
940
  $homepage_json_fp[get_permalink($product->id)] = array(
941
+ "tvc_id" => esc_js($product->id),
942
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
943
+ "tvc_n" => esc_js($product->get_title()),
944
+ "tvc_p" => esc_js($product->get_price()),
945
+ "tvc_c" => esc_js($categories),
946
+ "ATC-link" => esc_url_raw($product->add_to_cart_url())
947
  );
948
  //else add product in homepage recent product json
949
  }else {
950
  $homepage_json_rp[get_permalink($product->get_id())] =array(
951
+ "tvc_id" => esc_js($product->get_id()),
952
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
953
+ "tvc_n" => esc_js($product->get_title()),
954
+ "tvc_p" => esc_js($product->get_price()),
955
+ "tvc_c" => esc_js($categories)
956
  );
957
  }
958
  }else{
959
  if(!array_key_exists(get_permalink($product->get_id()),$homepage_json_fp)){
960
  $homepage_json_fp[get_permalink($product->get_id())] = array(
961
+ "tvc_id" => esc_js($product->get_id()),
962
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
963
+ "tvc_n" => esc_js($product->get_title()),
964
+ "tvc_p" => esc_js($product->get_price()),
965
+ "tvc_c" => esc_js($categories),
966
+ "ATC-link"=> esc_url_raw($product->add_to_cart_url())
967
  );
968
  //else add product in homepage recent product json
969
  }else {
970
  $homepage_json_rp[get_permalink($product->get_id())] =array(
971
+ "tvc_id" => esc_js($product->get_id()),
972
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
973
+ "tvc_n" => esc_js($product->get_title()),
974
+ "tvc_p" => esc_js($product->get_price()),
975
+ "tvc_c" => esc_js($categories)
976
  );
977
  }
978
  }
981
  //else prod add in homepage recent json
982
  if(version_compare($woocommerce->version, "2.7", "<")){
983
  $homepage_json_rp[get_permalink($product->id)] =array(
984
+ "tvc_id" => esc_js($product->id),
985
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
986
+ "tvc_n" => esc_js($product->get_title()),
987
+ "tvc_p" => esc_js($product->get_price()),
988
+ "tvc_c" => esc_js($categories)
989
  );
990
  }else{
991
  $homepage_json_rp[get_permalink($product->get_id())] =array(
992
+ "tvc_id" => esc_js($product->get_id()),
993
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
994
+ "tvc_n" => esc_js($product->get_title()),
995
+ "tvc_p" => esc_js($product->get_price()),
996
+ "tvc_c" => esc_js($categories)
997
  );
998
  }
999
 
1007
  }
1008
  // ATC link Array
1009
  if(version_compare($woocommerce->version, "2.7", "<")){
1010
+ $prodpage_json_ATC_link[$product->add_to_cart_url()]=
1011
+ array(
1012
+ "ATC-link"=>esc_url_raw(get_permalink($product->id))
1013
+ );
1014
 
1015
  $prodpage_json_relProd[get_permalink($product->id)] = array(
1016
+ "tvc_id" => esc_js($product->id),
1017
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
1018
+ "tvc_n" => esc_js($product->get_title()),
1019
+ "tvc_p" => esc_js($product->get_price()),
1020
+ "tvc_c" => esc_js($categories),
1021
  );
1022
  }else{
1023
+ $prodpage_json_ATC_link[$product->add_to_cart_url()]=
1024
+ array(
1025
+ "ATC-link"=> esc_url_raw(get_permalink($product->get_id()))
1026
+ );
1027
 
1028
  $prodpage_json_relProd[get_permalink($product->get_id())] = array(
1029
+ "tvc_id" => esc_js($product->get_id()),
1030
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
1031
+ "tvc_n" => esc_js($product->get_title()),
1032
+ "tvc_p" => esc_js($product->get_price()),
1033
+ "tvc_c" => esc_js($categories)
1034
 
1035
  );
1036
  }
1043
  }
1044
  //cat page ATC array
1045
  if(version_compare($woocommerce->version, "2.7", "<")){
1046
+ $catpage_json_ATC_link[$product->add_to_cart_url()]=
1047
+ array(
1048
+ "ATC-link"=>esc_url_raw(get_permalink($product->id))
1049
+ );
1050
 
1051
  $catpage_json[get_permalink($product->id)] =array(
1052
+ "tvc_id" => esc_js($product->id),
1053
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->id),
1054
+ "tvc_n" => esc_js($product->get_title()),
1055
+ "tvc_p" => esc_js($product->get_price()),
1056
+ "tvc_c" => esc_js($categories),
1057
  );
1058
  }else{
1059
+ $catpage_json_ATC_link[$product->add_to_cart_url()]=array(
1060
+ "ATC-link"=> esc_url_raw(get_permalink($product->get_id()))
1061
+ );
1062
 
1063
  $catpage_json[get_permalink($product->get_id())] =array(
1064
+ "tvc_id" => esc_js($product->get_id()),
1065
+ "tvc_i" => esc_js($product->get_sku() ? $product->get_sku() : $product->get_id()),
1066
+ "tvc_n" => esc_js($product->get_title()),
1067
+ "tvc_p" => esc_js($product->get_price()),
1068
+ "tvc_c" => esc_js($categories)
1069
 
1070
  );
1071
  }
1531
  $categories = rtrim($categories, ",");
1532
  if(version_compare($woocommerce->version, "2.7", "<")){
1533
  $cartpage_prod_array_main[$cart_remove_link] =array(
1534
+ "tvc_id" => esc_js($prod_meta->ID),
1535
+ "tvc_i" => esc_js($prod_meta->get_sku() ? $prod_meta->get_sku() : $prod_meta->ID),
1536
+ "tvc_n" => html_entity_decode(esc_js($prod_meta->get_title())),
1537
+ "tvc_p" => esc_js($prod_meta->get_price()),
1538
+ "tvc_c" => esc_js($categories),
1539
+ "tvc_q"=> esc_js($woocommerce->cart->cart_contents[$key]["quantity"])
1540
  );
1541
  }else{
1542
  $cartpage_prod_array_main[$cart_remove_link] =array(
1543
+ "tvc_id" => esc_js($prod_meta->get_id()),
1544
+ "tvc_i" => esc_js($prod_meta->get_sku() ? $prod_meta->get_sku() : $prod_meta->get_id()),
1545
+ "tvc_n" => html_entity_decode(esc_js($prod_meta->get_title())),
1546
+ "tvc_p" => esc_js($prod_meta->get_price()),
1547
+ "tvc_c" => esc_js($categories),
1548
+ "tvc_q"=> esc_js($woocommerce->cart->cart_contents[$key]["quantity"])
1549
  );
1550
  }
1551
  }
1776
  $categories = rtrim($categories, ",");
1777
  if(version_compare($woocommerce->version, "2.7", "<")){
1778
  $chkout_json[get_permalink($p->ID)] = array(
1779
+ "tvc_id" => esc_js($p->ID),
1780
  "tvc_i" => esc_js($p->get_sku() ? $p->get_sku() : $p->ID),
1781
+ "tvc_n" => html_entity_decode(esc_js($p->get_title())),
1782
  "tvc_p" => esc_js($p->get_price()),
1783
+ "tvc_c" => esc_js($categories),
1784
  "tvc_q" => esc_js($item["quantity"]),
1785
+ "isfeatured" => esc_js($p->is_featured())
1786
  );
1787
  }else{
1788
  $chkout_json[get_permalink($p->get_id())] = array(
1789
+ "tvc_id" => esc_js($p->get_id()),
1790
  "tvc_i" => esc_js($p->get_sku() ? $p->get_sku() : $p->get_id()),
1791
+ "tvc_n" => html_entity_decode(esc_js($p->get_title())),
1792
  "tvc_p" => esc_js($p->get_price()),
1793
+ "tvc_c" => esc_js($categories),
1794
  "tvc_q" => esc_js($item["quantity"]),
1795
+ "isfeatured" => esc_js($p->is_featured())
1796
  );
1797
  }
1798
  }
readme.txt CHANGED
@@ -5,11 +5,11 @@ Plugin URI: https://wordpress.org/plugins/enhanced-e-commerce-for-woocommerce-st
5
  Tags: Google Analytics tracking, Dynamic Remarketing, Google Shopping automation,Google Shopping, Universal Analytics tracking,Google Analytics integration,Google Analytics integration for WooCommerce,Ecommerce tracking, google analytics 4 tracking, google shopping feed, Web Analytics, Web Analytics For WooCommerce, WooCommerce Enhanced Ecommerce, WooCommerce Google Analytics, Google Analytics Plugin, Enhanced Ecommerce Plugin
6
  Author URI: https://conversios.io/
7
  Author: Tatvic
8
- Requires at least: 3.0.0
9
  Tested up to: 5.8.2
10
  Requires PHP: 5.6 or Higher
11
- Stable tag: 4.5.7
12
- Version: 4.5.7
13
  License: GPLv3
14
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
 
@@ -380,6 +380,10 @@ You can resolve the duplication of data by removing the manually implemented GA
380
 
381
  == Changelog ==
382
 
 
 
 
 
383
  = 4.5.7 - 29/12/2021 =
384
 
385
  * In this release, we have optimize the code.
5
  Tags: Google Analytics tracking, Dynamic Remarketing, Google Shopping automation,Google Shopping, Universal Analytics tracking,Google Analytics integration,Google Analytics integration for WooCommerce,Ecommerce tracking, google analytics 4 tracking, google shopping feed, Web Analytics, Web Analytics For WooCommerce, WooCommerce Enhanced Ecommerce, WooCommerce Google Analytics, Google Analytics Plugin, Enhanced Ecommerce Plugin
6
  Author URI: https://conversios.io/
7
  Author: Tatvic
8
+ Requires at least: 3.5.0
9
  Tested up to: 5.8.2
10
  Requires PHP: 5.6 or Higher
11
+ Stable tag: 4.5.8
12
+ Version: 4.5.8
13
  License: GPLv3
14
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
 
380
 
381
  == Changelog ==
382
 
383
+ = 4.5.8 - 10/01/2022 =
384
+
385
+ * In this release, we have optimise the code and upgrade the plugin security.
386
+
387
  = 4.5.7 - 29/12/2021 =
388
 
389
  * In this release, we have optimize the code.