Enhanced Ecommerce Google Analytics Plugin for WooCommerce - Version 4.5.9

Version Description

  • 17/01/2022 =

  • In this release we updated the Google Ads reports like Campaign performance, Smart Shopping and Product Performance & Product Partition.

Download this release

Release Info

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

Code changes from version 4.5.8 to 4.5.9

admin/css/custom-style.css CHANGED
@@ -690,6 +690,10 @@ section {
690
  background-color: #66BB6A;
691
  padding-left: 30px;
692
  }
 
 
 
 
693
  .alert-message.tvc-alert-success .alert:after {
694
  content: '\2713';
695
  position: absolute;
690
  background-color: #66BB6A;
691
  padding-left: 30px;
692
  }
693
+ .alert-message.tvc-alert-error .alert{
694
+ background-color: #fff3cd;
695
+ color: #856404;
696
+ }
697
  .alert-message.tvc-alert-success .alert:after {
698
  content: '\2713';
699
  position: absolute;
admin/helper/class-dashboard-helper.php CHANGED
@@ -68,7 +68,7 @@ if(!class_exists('Conversios_Dashboard_Helper')){
68
  }
69
  }else{
70
  $errormsg= isset($api_rs->errors[0])?$api_rs->errors[0]:"";
71
- $return = array('error'=>true,'errors'=>$errormsg);
72
  }
73
 
74
  }else{
@@ -95,13 +95,14 @@ if(!class_exists('Conversios_Dashboard_Helper')){
95
  $end_date == (false !==strtotime( $end_date ))?date('Y-m-d', strtotime($end_date)):date( 'Y-m-d', strtotime( 'now' ));
96
  $start_date = sanitize_text_field($start_date);
97
  $end_date = sanitize_text_field($end_date);
98
- $api_rs = $this->ShoppingApi->accountPerformance_for_dashboard(2, 7, $start_date, $end_date);
99
  if (isset($api_rs->error) && $api_rs->error == '') {
100
  if(isset($api_rs->data) && $api_rs->data != ""){
101
  $return = array('error'=>false, 'data'=>$api_rs->data);
102
  }
103
  }else{
104
- $return = array('error'=>true,'errors'=>$api_rs->error);
 
105
  }
106
  }else{
107
  $return = array('error'=>true,'errors'=>esc_html__("Admin security nonce is not verified.","conversios"));
68
  }
69
  }else{
70
  $errormsg= isset($api_rs->errors[0])?$api_rs->errors[0]:"";
71
+ $return = array('error'=>true,'errors'=>$errormsg, 'status' => $api_rs->status);
72
  }
73
 
74
  }else{
95
  $end_date == (false !==strtotime( $end_date ))?date('Y-m-d', strtotime($end_date)):date( 'Y-m-d', strtotime( 'now' ));
96
  $start_date = sanitize_text_field($start_date);
97
  $end_date = sanitize_text_field($end_date);
98
+ $api_rs = $this->ShoppingApi->accountPerformance_for_dashboard( $start_date, $end_date );
99
  if (isset($api_rs->error) && $api_rs->error == '') {
100
  if(isset($api_rs->data) && $api_rs->data != ""){
101
  $return = array('error'=>false, 'data'=>$api_rs->data);
102
  }
103
  }else{
104
+ $errormsg= isset($api_rs->errors[0])?$api_rs->errors[0]:"";
105
+ $return = array('error'=>true,'errors'=>$errormsg, 'status' => $api_rs->status);
106
  }
107
  }else{
108
  $return = array('error'=>true,'errors'=>esc_html__("Admin security nonce is not verified.","conversios"));
admin/helper/class-onboarding-helper.php CHANGED
@@ -663,6 +663,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
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)
663
  'access_token' => sanitize_text_field(base64_decode($this->access_token)),
664
  ];
665
  $args = array(
666
+ 'timeout' => 10000,
667
  'headers' =>$header,
668
  'method' => 'POST',
669
  'body' => wp_json_encode($data)
admin/js/tvc-ee-custom.js CHANGED
@@ -73,7 +73,7 @@ var tvc_helper = {
73
  },
74
  google_ads_reports_call_api:function(post_data){
75
  // Shopping and Google Ads Performance
76
- /*post_data['action']='get_google_ads_reports_chart';
77
  var v_this = this;
78
  $.ajax({
79
  type: "POST",
@@ -87,11 +87,15 @@ var tvc_helper = {
87
  v_this.set_google_ads_reports_chart_value(response.data, post_data);
88
  }
89
  }else{
90
- v_this.tvc_alert("error","",response.error);
 
 
 
 
91
  }
92
  v_this.remove_loader_for_analytics_reports();
93
  }
94
- });*/
95
  //Compaign Performance
96
  post_data['action']='get_google_ads_campaign_performance';
97
  var v_this = this;
@@ -120,25 +124,37 @@ var tvc_helper = {
120
  //var p_p_r = data.product_performance_report.products;
121
  //console.log(p_p_r);
122
  var table_row = '';
 
123
  var product_revenue_per = 0;
124
  var status = "";
125
  if(data != undefined && Object.keys(data).length > 0){
126
  var i=0;
127
  $.each(data, function (propKey, propValue) {
128
  if(i<5){
129
- table_row = '';
130
  status = (propValue['active'] == 1)?'active':'deactivate';
131
- table_row += '<tr><td class="prdnm-cell">'+propValue['compaignName']+'</td>';
132
- table_row += '<td>'+propValue['dailyBudget']+'</td>';
133
- table_row += '<td>'+status+'</td>';
134
- table_row += '<td>'+propValue['clicks']+'</td>';
135
- table_row += '<td>'+propValue['cost']+'</td>';
136
- table_row += '<td>'+propValue['conversions']+'</td>';
137
- table_row += '<td>'+propValue['sales']+'</td></tr>';
138
- $("#campaign_performance_report table tbody").append(table_row);
 
 
 
 
 
 
 
 
 
139
  i = i+1;
140
  }
141
- })
 
 
142
  }else{
143
  $("#campaign_performance_report table tbody").append("<tr><td colspan='7'>Data not available</td></tr>");
144
  }
73
  },
74
  google_ads_reports_call_api:function(post_data){
75
  // Shopping and Google Ads Performance
76
+ post_data['action']='get_google_ads_reports_chart';
77
  var v_this = this;
78
  $.ajax({
79
  type: "POST",
87
  v_this.set_google_ads_reports_chart_value(response.data, post_data);
88
  }
89
  }else{
90
+ if(response.status == "423" || response.status == "400"){
91
+ v_this.tvc_alert("error","", "If Google Ads Performance Data is not generated please make sure your Google Ads account should link with our MCC account");
92
+ }else{
93
+ v_this.tvc_alert("error", "", response?.errors);
94
+ }
95
  }
96
  v_this.remove_loader_for_analytics_reports();
97
  }
98
+ });
99
  //Compaign Performance
100
  post_data['action']='get_google_ads_campaign_performance';
101
  var v_this = this;
124
  //var p_p_r = data.product_performance_report.products;
125
  //console.log(p_p_r);
126
  var table_row = '';
127
+ var table_row_last = '';
128
  var product_revenue_per = 0;
129
  var status = "";
130
  if(data != undefined && Object.keys(data).length > 0){
131
  var i=0;
132
  $.each(data, function (propKey, propValue) {
133
  if(i<5){
134
+ //table_row = ''; table_row_last = '';
135
  status = (propValue['active'] == 1)?'active':'deactivate';
136
+ if(status == 'active'){
137
+ table_row += '<tr><td class="prdnm-cell">'+propValue['compaignName']+'</td>';
138
+ table_row += '<td>'+propValue['dailyBudget']+'</td>';
139
+ table_row += '<td>'+status+'</td>';
140
+ table_row += '<td>'+propValue['clicks']+'</td>';
141
+ table_row += '<td>'+propValue['cost']+'</td>';
142
+ table_row += '<td>'+propValue['conversions']+'</td>';
143
+ table_row += '<td>'+propValue['sales']+'</td></tr>';
144
+ }else{
145
+ table_row_last += '<tr><td class="prdnm-cell">'+propValue['compaignName']+'</td>';
146
+ table_row_last += '<td>'+propValue['dailyBudget']+'</td>';
147
+ table_row_last += '<td>'+status+'</td>';
148
+ table_row_last += '<td>'+propValue['clicks']+'</td>';
149
+ table_row_last += '<td>'+propValue['cost']+'</td>';
150
+ table_row_last += '<td>'+propValue['conversions']+'</td>';
151
+ table_row_last += '<td>'+propValue['sales']+'</td></tr>';
152
+ }
153
  i = i+1;
154
  }
155
+ });
156
+ $("#campaign_performance_report table tbody").append(table_row);
157
+ $("#campaign_performance_report table tbody").append(table_row_last);
158
  }else{
159
  $("#campaign_performance_report table tbody").append("<tr><td colspan='7'>Data not available</td></tr>");
160
  }
enhanced-ecommerce-google-analytics.php CHANGED
@@ -15,7 +15,7 @@
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+
@@ -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.8' );
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.9
19
  * Author: Tatvic
20
  * Author URI: www.tatvic.com
21
  * License: GPL-2.0+
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.9' );
41
  $fullName = plugin_basename( __FILE__ );
42
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
43
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
includes/setup/CustomApi.php CHANGED
@@ -295,9 +295,8 @@ class CustomApi{
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;
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
  $return = new \stdClass();
299
+ if ((isset($result->error) && $result->error == '')) {
300
  $return->status = $response_code;
301
  $return->data = $result->data;
302
  $return->error = false;
includes/setup/ShoppingApi.php CHANGED
@@ -100,20 +100,20 @@ class ShoppingApi {
100
  }
101
  }
102
 
103
- public function accountPerformance($date_range_type, $days = 0, $from_date = '', $to_date = '') {
104
  try {
105
- $days_diff = 0;
106
  if ($date_range_type == 2) {
107
  $days_diff = strtotime($to_date) - strtotime($from_date);
108
  $days_diff = abs(round($days_diff / 86400));
109
- }
110
 
111
  $url = $this->apiDomain . '/reports/account-performance';
112
  $data = [
113
  'customer_id' => sanitize_text_field($this->customerId),
114
- 'graph_type' => sanitize_text_field(($date_range_type == 2 && $days_diff > 31) ? 'month' : 'day'),
115
  'date_range_type' => sanitize_text_field($date_range_type),
116
- 'days' => sanitize_text_field($days),
117
  'from_date' => sanitize_text_field($from_date),
118
  'to_date' => sanitize_text_field($to_date)
119
  ];
@@ -150,19 +150,19 @@ class ShoppingApi {
150
  }
151
  }
152
 
153
- public function accountPerformance_for_dashboard($date_range_type, $days = 0, $from_date = '', $to_date = '') {
154
  try {
155
- $days_diff = 0;
156
  if ($date_range_type == 2) {
157
  $days_diff = strtotime($to_date) - strtotime($from_date);
158
  $days_diff = abs(round($days_diff / 86400));
159
- }
160
  $url = $this->apiDomain . '/reports/account-performance';
161
  $data = [
162
  'customer_id' => sanitize_text_field($this->customerId),
163
- 'graph_type' => sanitize_text_field(($date_range_type == 2 && $days_diff > 61) ? 'month' : 'day'),
164
  'date_range_type' => sanitize_text_field($date_range_type),
165
- 'days' => sanitize_text_field($days),
166
  'from_date' => sanitize_text_field($from_date),
167
  'to_date' => sanitize_text_field($to_date)
168
  ];
@@ -186,13 +186,13 @@ class ShoppingApi {
186
  $return = new \stdClass();
187
  if ((isset($result->error) && $result->error == '')) {
188
  $return->data = $result->data;
189
- $return->data->graph_type = $data['graph_type'];
190
  $return->error = false;
191
  return $return;
192
  }else{
193
  $return->error = true;
194
- $return->data = $result->data;
195
- $return->status = $result->status;
196
  return $return;
197
  }
198
 
@@ -241,7 +241,8 @@ class ShoppingApi {
241
  }else{
242
  $return->error = true;
243
  $return->data = $result->data;
244
- $return->status = $result->status;
 
245
  return $return;
246
  }
247
 
@@ -282,8 +283,17 @@ class ShoppingApi {
282
  $response_code = wp_remote_retrieve_response_code($request);
283
  $response_message = wp_remote_retrieve_response_message($request);
284
  $response_body = json_decode(wp_remote_retrieve_body($request));
285
-
286
  if (!is_wp_error($request) && (isset($response_body->error) && $response_body->error == '')) {
 
 
 
 
 
 
 
 
 
 
287
  return new WP_REST_Response(
288
  array(
289
  'status' => $response_code,
@@ -299,11 +309,11 @@ class ShoppingApi {
299
  }
300
  }
301
 
302
- public function productPerformance($campaign_id = '', $date_range_type='', $days = 0, $from_date = '', $to_date = '') {
303
  try {
304
  $url = $this->apiDomain . '/reports/product-performance';
305
 
306
- $data = [
307
  'merchant_id' => sanitize_text_field($this->merchantId),
308
  'customer_id' => sanitize_text_field($this->customerId),
309
  'campaign_id' => sanitize_text_field($campaign_id),
@@ -311,16 +321,26 @@ class ShoppingApi {
311
  'days' => sanitize_text_field($days),
312
  'from_date' => sanitize_text_field($from_date),
313
  'to_date' => sanitize_text_field($to_date)
 
 
 
 
 
 
 
 
 
314
  ];
315
 
316
  $args = array(
 
317
  'headers' => array(
318
  'Authorization' => "Bearer $this->token",
319
  'Content-Type' => 'application/json'
320
  ),
321
  'body' => wp_json_encode($data)
322
  );
323
-
324
  // Send remote request
325
  $request = wp_remote_post(esc_url_raw($url), $args);
326
 
@@ -328,7 +348,7 @@ class ShoppingApi {
328
  $response_code = wp_remote_retrieve_response_code($request);
329
  $response_message = wp_remote_retrieve_response_message($request);
330
  $response_body = json_decode(wp_remote_retrieve_body($request));
331
-
332
  if (!is_wp_error($request) && (isset($response_body->error) && $response_body->error == '')) {
333
  return new WP_REST_Response(
334
  array(
@@ -345,14 +365,15 @@ class ShoppingApi {
345
  }
346
  }
347
 
348
- public function productPartitionPerformance($campaign_id = '', $date_range_type='', $days = 0, $from_date = '', $to_date = '') {
349
  try {
350
  $url = $this->apiDomain . '/reports/product-partition-performance';
351
 
352
  $data = [
353
- 'merchant_id' => sanitize_text_field($this->merchantId),
354
  'customer_id' => sanitize_text_field($this->customerId),
355
  'campaign_id' => sanitize_text_field($campaign_id),
 
356
  'date_range_type' => sanitize_text_field($date_range_type),
357
  'days' => sanitize_text_field($days),
358
  'from_date' => sanitize_text_field($from_date),
@@ -360,6 +381,7 @@ class ShoppingApi {
360
  ];
361
 
362
  $args = array(
 
363
  'headers' => array(
364
  'Authorization' => "Bearer $this->token",
365
  'Content-Type' => 'application/json'
100
  }
101
  }
102
 
103
+ public function accountPerformance( $from_date = '', $to_date = '') {
104
  try {
105
+ /* $days_diff = 0;
106
  if ($date_range_type == 2) {
107
  $days_diff = strtotime($to_date) - strtotime($from_date);
108
  $days_diff = abs(round($days_diff / 86400));
109
+ }*/
110
 
111
  $url = $this->apiDomain . '/reports/account-performance';
112
  $data = [
113
  'customer_id' => sanitize_text_field($this->customerId),
114
+ /*'graph_type' => sanitize_text_field(($date_range_type == 2 && $days_diff > 31) ? 'month' : 'day'),
115
  'date_range_type' => sanitize_text_field($date_range_type),
116
+ 'days' => sanitize_text_field($days),*/
117
  'from_date' => sanitize_text_field($from_date),
118
  'to_date' => sanitize_text_field($to_date)
119
  ];
150
  }
151
  }
152
 
153
+ public function accountPerformance_for_dashboard( $from_date = '', $to_date = '') {
154
  try {
155
+ /*$days_diff = 0;
156
  if ($date_range_type == 2) {
157
  $days_diff = strtotime($to_date) - strtotime($from_date);
158
  $days_diff = abs(round($days_diff / 86400));
159
+ }*/
160
  $url = $this->apiDomain . '/reports/account-performance';
161
  $data = [
162
  'customer_id' => sanitize_text_field($this->customerId),
163
+ /*'graph_type' => sanitize_text_field(($date_range_type == 2 && $days_diff > 61) ? 'month' : 'day'),
164
  'date_range_type' => sanitize_text_field($date_range_type),
165
+ 'days' => sanitize_text_field($days),*/
166
  'from_date' => sanitize_text_field($from_date),
167
  'to_date' => sanitize_text_field($to_date)
168
  ];
186
  $return = new \stdClass();
187
  if ((isset($result->error) && $result->error == '')) {
188
  $return->data = $result->data;
189
+ $return->data->graph_type = "day";
190
  $return->error = false;
191
  return $return;
192
  }else{
193
  $return->error = true;
194
+ $return->errors = $result->errors;
195
+ $return->status = $response_code;
196
  return $return;
197
  }
198
 
241
  }else{
242
  $return->error = true;
243
  $return->data = $result->data;
244
+ $return->errors = $result->errors;
245
+ $return->status = $response_code;
246
  return $return;
247
  }
248
 
283
  $response_code = wp_remote_retrieve_response_code($request);
284
  $response_message = wp_remote_retrieve_response_message($request);
285
  $response_body = json_decode(wp_remote_retrieve_body($request));
 
286
  if (!is_wp_error($request) && (isset($response_body->error) && $response_body->error == '')) {
287
+ // Change ordring base on status
288
+ $active_list = array(); $deactive_list = array();
289
+ foreach ($response_body->data as $key => $value) {
290
+ if(isset($value->active) && $value->active == 1){
291
+ $active_list[] = $value;
292
+ }else{
293
+ $deactive_list[] = $value;
294
+ }
295
+ }
296
+ $response_body->data = array_merge($active_list, $deactive_list);
297
  return new WP_REST_Response(
298
  array(
299
  'status' => $response_code,
309
  }
310
  }
311
 
312
+ public function productPerformance($campaign_id = '', $date_range_type='', $days = 30, $from_date = '', $to_date = '', $adGroupId = '') {
313
  try {
314
  $url = $this->apiDomain . '/reports/product-performance';
315
 
316
+ /*$data = [
317
  'merchant_id' => sanitize_text_field($this->merchantId),
318
  'customer_id' => sanitize_text_field($this->customerId),
319
  'campaign_id' => sanitize_text_field($campaign_id),
321
  'days' => sanitize_text_field($days),
322
  'from_date' => sanitize_text_field($from_date),
323
  'to_date' => sanitize_text_field($to_date)
324
+ ];*/
325
+ $data = [
326
+ 'customer_id' => sanitize_text_field($this->customerId),
327
+ 'campaign_id' => sanitize_text_field($campaign_id),
328
+ "adgroup_id" => sanitize_text_field($adGroupId),
329
+ 'date_range_type' => sanitize_text_field($date_range_type),
330
+ 'days' => sanitize_text_field($days),
331
+ 'from_date' => sanitize_text_field($from_date),
332
+ 'to_date' => sanitize_text_field($to_date)
333
  ];
334
 
335
  $args = array(
336
+ 'timeout' => 10000,
337
  'headers' => array(
338
  'Authorization' => "Bearer $this->token",
339
  'Content-Type' => 'application/json'
340
  ),
341
  'body' => wp_json_encode($data)
342
  );
343
+
344
  // Send remote request
345
  $request = wp_remote_post(esc_url_raw($url), $args);
346
 
348
  $response_code = wp_remote_retrieve_response_code($request);
349
  $response_message = wp_remote_retrieve_response_message($request);
350
  $response_body = json_decode(wp_remote_retrieve_body($request));
351
+ //print_r($response_body);
352
  if (!is_wp_error($request) && (isset($response_body->error) && $response_body->error == '')) {
353
  return new WP_REST_Response(
354
  array(
365
  }
366
  }
367
 
368
+ public function productPartitionPerformance($campaign_id = '', $date_range_type='', $days = 0, $from_date = '', $to_date = '', $adGroupId = '') {
369
  try {
370
  $url = $this->apiDomain . '/reports/product-partition-performance';
371
 
372
  $data = [
373
+ //'merchant_id' => sanitize_text_field($this->merchantId),
374
  'customer_id' => sanitize_text_field($this->customerId),
375
  'campaign_id' => sanitize_text_field($campaign_id),
376
+ "adgroup_id" => sanitize_text_field($adGroupId),
377
  'date_range_type' => sanitize_text_field($date_range_type),
378
  'days' => sanitize_text_field($days),
379
  'from_date' => sanitize_text_field($from_date),
381
  ];
382
 
383
  $args = array(
384
+ 'timeout' => 10000,
385
  'headers' => array(
386
  'Authorization' => "Bearer $this->token",
387
  'Content-Type' => 'application/json'
includes/setup/class-conversios-dashboard.php CHANGED
@@ -676,9 +676,9 @@ if ( ! class_exists( 'Conversios_Dashboard' ) ) {
676
 
677
 
678
  <!--- Shopping and Google Ads Performance section start -->
679
- <?php /* if($this->plan_id != 1){?>
680
  <div class="mt24 whiteroundedbx ggladsperfom-sec">
681
- <h4><?php esc_html_e("Shopping and Google Ads Performance","conversios"); ?></h4>
682
  <div class="row">
683
  <div class="col50">
684
  <div class="chartbx ggladschrtbx daily-clicks-bx">
@@ -815,7 +815,7 @@ if ( ! class_exists( 'Conversios_Dashboard' ) ) {
815
  </div>
816
  </div>
817
 
818
- <?php } */ ?>
819
  <!--- Shopping and Google Ads Performance section start -->
820
 
821
  <!--- Compaign section start -->
676
 
677
 
678
  <!--- Shopping and Google Ads Performance section start -->
679
+ <?php if($this->plan_id != 1){?>
680
  <div class="mt24 whiteroundedbx ggladsperfom-sec">
681
+ <h4><?php esc_html_e("Google Ads Account Performance","conversios"); ?></h4>
682
  <div class="row">
683
  <div class="col50">
684
  <div class="chartbx ggladschrtbx daily-clicks-bx">
815
  </div>
816
  </div>
817
 
818
+ <?php } ?>
819
  <!--- Shopping and Google Ads Performance section start -->
820
 
821
  <!--- Compaign section start -->
includes/setup/google-shopping-feed-shopping-campaigns.php CHANGED
@@ -20,8 +20,8 @@ class CampaignsConfiguration
20
 
21
  $this->date_range_type = (isset($_POST['customRadio'])) ? sanitize_text_field($_POST['customRadio']) : 1;
22
  $this->days = (isset($_POST['days']) && sanitize_text_field($_POST['days']) != '') ? sanitize_text_field($_POST['days']) : 7;
23
- $this->from_date = (isset($_POST['from_date']) && sanitize_text_field($_POST['from_date']) != '') ? sanitize_text_field($_POST['from_date']) : "";
24
- $this->to_date = (isset($_POST['to_date']) && sanitize_text_field($_POST['to_date'] )!= '') ? sanitize_text_field($_POST['to_date']) : "";
25
  $this->country = $this->TVC_Admin_Helper->get_woo_country();
26
  $this->currency_symbol = $this->TVC_Admin_Helper->get_user_currency_symbol();
27
  $this->site_url = "admin.php?page=conversios-google-shopping-feed&tab=";
@@ -46,6 +46,8 @@ class CampaignsConfiguration
46
  }
47
 
48
  public function create_form(){
 
 
49
  $googleDetail = [];
50
  $google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
51
  if(isset($google_detail['setting'])){
@@ -69,11 +71,14 @@ class CampaignsConfiguration
69
  $api_old_obj = new ShoppingApi();
70
 
71
  $campaigns_list_res = $api_old_obj->getCampaigns();
72
-
73
- if (isset($campaigns_list_res->errors) && !empty($campaigns_list_res->errors)) {
74
- $class = 'error';
 
 
 
 
75
  $message = esc_html__("Not any campaigns found.","conversios");
76
- printf('<div class="alert-message"><div class="%1$s" role="alert">%2$s</div></div>', esc_attr($class), esc_html($message));
77
  } else if(isset($campaigns_list_res->data)){
78
  $campaigns_list_res = $campaigns_list_res->data;
79
  if ($campaigns_list_res['status'] == 200) {
@@ -86,8 +91,9 @@ class CampaignsConfiguration
86
  $totalClick = 0;
87
  if(count($campaigns_list) > 0) {
88
  //Account Performance
89
- $account_performance_res = $api_old_obj->accountPerformance($this->date_range_type, $this->days, $this->from_date, $this->to_date);
90
  if (isset($account_performance_res->errors) && !empty($account_performance_res->errors)) {
 
91
  } else {
92
  $account_performance_res = $account_performance_res->data;
93
  if ($account_performance_res['status'] == 200) {
@@ -126,30 +132,43 @@ class CampaignsConfiguration
126
  $campaign_performance = $campaign_performance_res['data'];
127
  }
128
  }
129
- }else if(isset($_GET['id']) && sanitize_text_field($_GET['id']) != '') {
130
- //Product Performance
131
- $product_performance_res = $api_old_obj->productPerformance(sanitize_text_field($_GET['id']), $this->date_range_type, $this->days, $this->from_date, $this->to_date);
 
 
 
 
 
 
 
132
 
133
- if (isset($product_performance_res->errors) && !empty($product_performance_res->errors)) {
134
 
135
- } else if(isset($product_performance_res->data)){
136
- $product_performance_res = $product_performance_res->data;
137
- if ($product_performance_res['status'] == 200) {
138
- $product_performance = $product_performance_res['data'];
139
- }
140
- }
141
 
142
- //Product Partition Performance
143
- $product_partition_performance_res = $api_old_obj->productPartitionPerformance(sanitize_text_field($_GET['id']), $this->date_range_type, $this->days, $this->from_date, $this->to_date);
 
 
 
 
 
 
144
 
145
- if (isset($product_partition_performance_res->errors) && !empty($product_partition_performance_res->errors)) {
146
 
147
- } else if(isset($product_partition_performance_res->data)){
148
- $product_partition_performance_res = $product_partition_performance_res->data;
149
- if ($product_partition_performance_res['status'] == 200) {
150
- $product_partition_performance = $product_partition_performance_res['data'];
151
- }
152
- }
 
 
 
 
 
 
153
  }
154
  $plan_id = 1;
155
  if(isset($googleDetail->plan_id) && !in_array($googleDetail->plan_id, array("1"))){
@@ -157,6 +176,9 @@ class CampaignsConfiguration
157
  }
158
  ?>
159
  <div class="tab-content">
 
 
 
160
  <div class="tab-pane show active" id="googleShoppingFeed">
161
  <div class="tab-card">
162
  <div class="row">
@@ -224,7 +246,7 @@ class CampaignsConfiguration
224
  </div>
225
  <div class="account-performance">
226
  <div class="row">
227
- <div class="col-lg-8">
228
  <h3 class="title"><?php esc_html_e("Campaign Performance","conversios"); ?></h3>
229
  <div class="table-section">
230
  <table id="campaingPerformance" class="table dt-responsive nowrap" style="width:100%">
@@ -255,10 +277,10 @@ class CampaignsConfiguration
255
  <label class="form-check-label" for="customSwitch<?php echo esc_attr($i); ?>"></label>
256
  </div>
257
  </td>
258
- <td class="text-center"><?php echo esc_attr($campaign_performance[$i]->clicks); ?></td>
259
- <td class="text-center"><?php echo esc_attr($campaign_performance[$i]->cost); ?></td>
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>
@@ -295,7 +317,7 @@ class CampaignsConfiguration
295
  if(isset($_GET['id']) && sanitize_text_field($_GET['id']) != '') { ?>
296
  <div class="account-performance">
297
  <div class="row">
298
- <div class="col-lg-6">
299
  <h3 class="title"><?php esc_html_e("Product Performance :","conversios"); ?></h3>
300
  <div class="table-section">
301
  <table id="productPerformance" class="table dt-responsive nowrap" style="width:100%">
@@ -312,12 +334,12 @@ class CampaignsConfiguration
312
  <tbody>
313
  <?php for ($i = 0; $i < count($product_performance); $i++) { ?>
314
  <tr>
315
- <td class="product-image"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon/sneaker.jpg'); ?>" alt=""/></td>
316
- <td><?php echo esc_attr($product_performance[$i]->product); ?></td>
317
- <td class="text-center"><?php echo esc_attr($product_performance[$i]->clicks); ?></td>
318
- <td class="text-center"><?php echo esc_attr($product_performance[$i]->cost); ?></td>
319
- <td class="text-center"><?php echo esc_attr($product_performance[$i]->conversions); ?></td>
320
- <td class="text-center"><?php echo esc_attr($product_performance[$i]->sales); ?></td>
321
  </tr>
322
  <?php } ?>
323
  </tbody>
@@ -328,7 +350,7 @@ class CampaignsConfiguration
328
  </div><!-- account-performance-->
329
  <div class="account-performance">
330
  <div class="row">
331
- <div class="col-lg-6">
332
  <h3 class="title"><?php esc_html_e("Product Partition Performance","conversios"); ?></h3>
333
  <div class="table-section">
334
  <table id="productPerformance" class="table dt-responsive nowrap" style="width:100%">
@@ -336,7 +358,7 @@ class CampaignsConfiguration
336
  <tr>
337
  <th><?php esc_html_e("Campaign","conversios"); ?></th>
338
  <th class="text-center"><?php esc_html_e("Product Dimension","conversios"); ?></th>
339
- <th class="text-center"><?php esc_html_e("Product Dimension Value","conversios"); ?></th>
340
  <th class="text-center"><?php esc_html_e("Clicks","conversios"); ?></th>
341
  <th class="text-center"><?php esc_html_e("Cost","conversios"); ?></th>
342
  <th class="text-center"><?php esc_html_e("Conversions","conversios"); ?></th>
@@ -348,11 +370,11 @@ class CampaignsConfiguration
348
  <tr>
349
  <td><a href="" class="text-underline"><?php echo esc_attr($product_partition_performance[$i]->compaignName); ?></a></td>
350
  <td class="text-center"><?php echo esc_attr($product_partition_performance[$i]->productDimention); ?></td>
351
- <td class="text-center"><?php echo esc_attr($product_partition_performance[$i]->productDimentionValue); ?></td>
352
- <td class="text-center"><?php echo esc_attr($product_partition_performance[$i]->clicks); ?></td>
353
- <td class="text-center"><?php echo esc_attr($product_partition_performance[$i]->cost); ?></td>
354
- <td class="text-center"><?php echo esc_attr($product_partition_performance[$i]->conversions); ?></td>
355
- <td class="text-center"><?php echo esc_attr($product_partition_performance[$i]->sales); ?></td>
356
  </tr>
357
  <?php } ?>
358
  </tbody>
20
 
21
  $this->date_range_type = (isset($_POST['customRadio'])) ? sanitize_text_field($_POST['customRadio']) : 1;
22
  $this->days = (isset($_POST['days']) && sanitize_text_field($_POST['days']) != '') ? sanitize_text_field($_POST['days']) : 7;
23
+ $this->from_date = (isset($_POST['from_date']) && sanitize_text_field($_POST['from_date']) != '') ? sanitize_text_field($_POST['from_date']) : date("Y-m-d", strtotime("-1 month"));
24
+ $this->to_date = (isset($_POST['to_date']) && sanitize_text_field($_POST['to_date'] )!= '') ? sanitize_text_field($_POST['to_date']) : date("Y-m-d");
25
  $this->country = $this->TVC_Admin_Helper->get_woo_country();
26
  $this->currency_symbol = $this->TVC_Admin_Helper->get_user_currency_symbol();
27
  $this->site_url = "admin.php?page=conversios-google-shopping-feed&tab=";
46
  }
47
 
48
  public function create_form(){
49
+ $class = "";
50
+ $message = "";
51
  $googleDetail = [];
52
  $google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
53
  if(isset($google_detail['setting'])){
71
  $api_old_obj = new ShoppingApi();
72
 
73
  $campaigns_list_res = $api_old_obj->getCampaigns();
74
+ if(isset($campaigns_list_res->errors) || isset($campaigns_list_res->errors[423])){
75
+ $class = 'tvc-alert-error';
76
+ $message = esc_html__("If Data is not generated please make sure your Google Ads account should link with our MCC account.","conversios");
77
+ }
78
+
79
+ if (isset($campaigns_list_res->errors) && !empty($campaigns_list_res->errors) && $message == "") {
80
+ $class = 'tvc-alert-error';
81
  $message = esc_html__("Not any campaigns found.","conversios");
 
82
  } else if(isset($campaigns_list_res->data)){
83
  $campaigns_list_res = $campaigns_list_res->data;
84
  if ($campaigns_list_res['status'] == 200) {
91
  $totalClick = 0;
92
  if(count($campaigns_list) > 0) {
93
  //Account Performance
94
+ $account_performance_res = $api_old_obj->accountPerformance( $this->from_date, $this->to_date );
95
  if (isset($account_performance_res->errors) && !empty($account_performance_res->errors)) {
96
+
97
  } else {
98
  $account_performance_res = $account_performance_res->data;
99
  if ($account_performance_res['status'] == 200) {
132
  $campaign_performance = $campaign_performance_res['data'];
133
  }
134
  }
135
+ }
136
+ if(isset($_GET['id']) && sanitize_text_field($_GET['id']) != '') {
137
+ $CampaignDetail = $api_old_obj->getCampaignDetails($_GET['id']);
138
+ if (isset($CampaignDetail->errors) && !empty($CampaignDetail->errors)) {
139
+
140
+ }else if(isset($CampaignDetail->data['data'])){
141
+ $adGroupId = $CampaignDetail->data['data']->adGroupId;
142
+
143
+ //Product Performance
144
+ $product_performance_res = $api_old_obj->productPerformance(sanitize_text_field($_GET['id']), 2, 30, $this->from_date, $this->to_date, $adGroupId);
145
 
 
146
 
147
+ if (isset($product_performance_res->errors) && !empty($product_performance_res->errors)) {
 
 
 
 
 
148
 
149
+ } else if(isset($product_performance_res->data)){
150
+ $product_performance_res = $product_performance_res->data;
151
+ if ($product_performance_res['status'] == 200) {
152
+ $product_performance = $product_performance_res['data'];
153
+ }
154
+ }
155
+ //Product Partition Performance
156
+ $product_partition_performance_res = $api_old_obj->productPartitionPerformance(sanitize_text_field($_GET['id']), 2, 30, $this->from_date, $this->to_date, $adGroupId);
157
 
158
+ if (isset($product_partition_performance_res->errors) && !empty($product_partition_performance_res->errors)) {
159
 
160
+ } else if(isset($product_partition_performance_res->data)){
161
+ $product_partition_performance_res = $product_partition_performance_res->data;
162
+ if ($product_partition_performance_res['status'] == 200) {
163
+ $product_partition_performance = $product_partition_performance_res['data'];
164
+ }
165
+ }
166
+
167
+ }
168
+
169
+
170
+
171
+
172
  }
173
  $plan_id = 1;
174
  if(isset($googleDetail->plan_id) && !in_array($googleDetail->plan_id, array("1"))){
176
  }
177
  ?>
178
  <div class="tab-content">
179
+ <?php if($message){
180
+ printf('<div class="alert-message %1$s"><div class="alert">%2$s</div></div>', esc_attr($class), esc_html($message));
181
+ }?>
182
  <div class="tab-pane show active" id="googleShoppingFeed">
183
  <div class="tab-card">
184
  <div class="row">
246
  </div>
247
  <div class="account-performance">
248
  <div class="row">
249
+ <div class="col-lg-10">
250
  <h3 class="title"><?php esc_html_e("Campaign Performance","conversios"); ?></h3>
251
  <div class="table-section">
252
  <table id="campaingPerformance" class="table dt-responsive nowrap" style="width:100%">
277
  <label class="form-check-label" for="customSwitch<?php echo esc_attr($i); ?>"></label>
278
  </div>
279
  </td>
280
+ <td class="text-center"><?php echo esc_attr(number_format($campaign_performance[$i]->clicks, 2) ); ?></td>
281
+ <td class="text-center"><?php echo esc_attr(number_format($campaign_performance[$i]->cost, 2)); ?></td>
282
+ <td class="text-center"><?php echo esc_attr(number_format($campaign_performance[$i]->conversions, 2)); ?></td>
283
+ <td class="text-center"><?php echo esc_attr(number_format($campaign_performance[$i]->sales, 2)); ?></td>
284
  <input type="hidden" value="<?php echo esc_attr($campaign_performance[$i]->compaignName); ?>" id="campaign_name_<?php echo esc_attr($i); ?>" />
285
  <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>
286
  </tr>
317
  if(isset($_GET['id']) && sanitize_text_field($_GET['id']) != '') { ?>
318
  <div class="account-performance">
319
  <div class="row">
320
+ <div class="col-lg-10">
321
  <h3 class="title"><?php esc_html_e("Product Performance :","conversios"); ?></h3>
322
  <div class="table-section">
323
  <table id="productPerformance" class="table dt-responsive nowrap" style="width:100%">
334
  <tbody>
335
  <?php for ($i = 0; $i < count($product_performance); $i++) { ?>
336
  <tr>
337
+ <td class="product-image"><?php echo esc_attr($i+1); ?></td>
338
+ <td><?php echo esc_attr($product_performance[$i]->productTitle); ?></td>
339
+ <td class="text-center"><?php echo esc_attr(number_format($product_performance[$i]->clicks, 2) ); ?></td>
340
+ <td class="text-center"><?php echo esc_attr(number_format($product_performance[$i]->cost, 2) ); ?></td>
341
+ <td class="text-center"><?php echo esc_attr(number_format($product_performance[$i]->conversions, 2) ); ?></td>
342
+ <td class="text-center"><?php echo esc_attr(number_format($product_performance[$i]->sales, 2) ); ?></td>
343
  </tr>
344
  <?php } ?>
345
  </tbody>
350
  </div><!-- account-performance-->
351
  <div class="account-performance">
352
  <div class="row">
353
+ <div class="col-lg-10">
354
  <h3 class="title"><?php esc_html_e("Product Partition Performance","conversios"); ?></h3>
355
  <div class="table-section">
356
  <table id="productPerformance" class="table dt-responsive nowrap" style="width:100%">
358
  <tr>
359
  <th><?php esc_html_e("Campaign","conversios"); ?></th>
360
  <th class="text-center"><?php esc_html_e("Product Dimension","conversios"); ?></th>
361
+ <?php /*<th class="text-center"><?php esc_html_e("Product Dimension Value","conversios"); ?></th> */ ?>
362
  <th class="text-center"><?php esc_html_e("Clicks","conversios"); ?></th>
363
  <th class="text-center"><?php esc_html_e("Cost","conversios"); ?></th>
364
  <th class="text-center"><?php esc_html_e("Conversions","conversios"); ?></th>
370
  <tr>
371
  <td><a href="" class="text-underline"><?php echo esc_attr($product_partition_performance[$i]->compaignName); ?></a></td>
372
  <td class="text-center"><?php echo esc_attr($product_partition_performance[$i]->productDimention); ?></td>
373
+ <?php /*<td class="text-center"><?php echo esc_attr($product_partition_performance[$i]->productDimentionValue); ?></td>*/ ?>
374
+ <td class="text-center"><?php echo esc_attr(number_format($product_partition_performance[$i]->clicks, 2) ); ?></td>
375
+ <td class="text-center"><?php echo esc_attr(number_format($product_partition_performance[$i]->cost, 2) ); ?></td>
376
+ <td class="text-center"><?php echo esc_attr(number_format($product_partition_performance[$i]->conversions, 2) ); ?></td>
377
+ <td class="text-center"><?php echo esc_attr(number_format($product_partition_performance[$i]->sales, 2) ); ?></td>
378
  </tr>
379
  <?php } ?>
380
  </tbody>
readme.txt CHANGED
@@ -8,8 +8,8 @@ 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,6 +380,10 @@ You can resolve the duplication of data by removing the manually implemented GA
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.
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.9
12
+ Version: 4.5.9
13
  License: GPLv3
14
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
 
380
 
381
  == Changelog ==
382
 
383
+ = 4.5.9 - 17/01/2022 =
384
+
385
+ * In this release we updated the Google Ads reports like Campaign performance, Smart Shopping and Product Performance & Product Partition.
386
+
387
  = 4.5.8 - 10/01/2022 =
388
 
389
  * In this release, we have optimise the code and upgrade the plugin security.