Enhanced Ecommerce Google Analytics Plugin for WooCommerce - Version 5.1.1

Version Description

  • 05/12/2022 =
  • For a quicker and better user experience, we have improved the pixel settings in this release, giving you the option to add and update your Google ads conversion label.
  • Minor bug fixes and improvements to the auto product sync feature are also included.
Download this release

Release Info

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

Code changes from version 5.1.0 to 5.1.1

admin/class-conversios-onboarding.php CHANGED
@@ -1130,11 +1130,11 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
1130
  jQuery('#ads-account').append(jQuery('<option>', { value: googleAds_value, text: googleAds_value,selected: "selected"}));
1131
  if(googleAds == 0){ //disable dropdown for google ads when we have its previous data
1132
  //$('ads-account').select2("enable", false);
1133
- $('#ads-account').prop('disabled', true);
1134
  }
1135
  if(gmc_field == 0){ //disable dropdown for gmc when we have its previous data
1136
  //$('google_merchant_center_id').select2("enable", false);
1137
- $('#google_merchant_center_id').prop('disabled', true);
1138
  }
1139
  /**
1140
  * Convesios custom script
@@ -1466,7 +1466,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
1466
  jQuery(next_this).closest('.onbordording-step').addClass('selectedactivestep');
1467
  jQuery(next_this).closest('.onbordording-step').removeClass('activestep');
1468
  jQuery( next_this ).closest('.onbordording-step').next('.onbordording-step').addClass('activestep');
1469
- $('html, body').animate({
1470
  scrollTop: jQuery( next_this ).closest('.onbordording-step').next('.onbordording-step').offset().top-80
1471
  }, 2000);
1472
  }
1130
  jQuery('#ads-account').append(jQuery('<option>', { value: googleAds_value, text: googleAds_value,selected: "selected"}));
1131
  if(googleAds == 0){ //disable dropdown for google ads when we have its previous data
1132
  //$('ads-account').select2("enable", false);
1133
+ jQuery('#ads-account').prop('disabled', true);
1134
  }
1135
  if(gmc_field == 0){ //disable dropdown for gmc when we have its previous data
1136
  //$('google_merchant_center_id').select2("enable", false);
1137
+ jQuery('#google_merchant_center_id').prop('disabled', true);
1138
  }
1139
  /**
1140
  * Convesios custom script
1466
  jQuery(next_this).closest('.onbordording-step').addClass('selectedactivestep');
1467
  jQuery(next_this).closest('.onbordording-step').removeClass('activestep');
1468
  jQuery( next_this ).closest('.onbordording-step').next('.onbordording-step').addClass('activestep');
1469
+ jQuery('html, body').animate({
1470
  scrollTop: jQuery( next_this ).closest('.onbordording-step').next('.onbordording-step').offset().top-80
1471
  }, 2000);
1472
  }
admin/class-tvc-admin-auto-product-sync-helper.php CHANGED
@@ -26,6 +26,13 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
26
  add_filter( 'cron_schedules', array($this,'tvc_add_cron_interval_for_product_sync') );
27
 
28
  //add_action('admin_init',array($this,'call_auto_sync_product_ttt'));
 
 
 
 
 
 
 
29
  }
30
 
31
  public function includes() {
@@ -214,239 +221,261 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
214
  }
215
 
216
  public function tvc_get_map_product_attribute($products, $tvc_currency, $merchantId){
217
- if(!empty($products)){
218
- global $wpdb;
219
- $tve_table_prefix = $wpdb->prefix;
220
- $plan_id = $this->TVC_Admin_Helper->get_plan_id();
221
- $items = [];
222
- $skipProducts = [];
223
- $product_ids = [];
224
- $batchId = time();
225
- foreach ($products as $postkey => $postvalue) {
226
- $product_ids[] = $postvalue->w_product_id;
227
- $postmeta = [];
228
- $postmeta = $this->TVC_Admin_Helper->tvc_get_post_meta($postvalue->w_product_id);
229
- $prd = wc_get_product($postvalue->w_product_id);
230
- $postObj = (object) array_merge((array) get_post($postvalue->w_product_id), (array) $postmeta);
231
-
232
- $product = array(
233
- 'offer_id'=>sanitize_text_field($postvalue->w_product_id),
234
- 'channel'=>'online',
235
- 'link'=> esc_url_raw(get_permalink($postvalue->w_product_id)),
236
- 'google_product_category'=>sanitize_text_field($postvalue->g_cat_id)
237
- );
 
 
 
238
 
239
- $temp_product=array();
240
- $fixed_att_select_list = array("gender", "age_group", "shipping", "tax", "content_language", "target_country", "condition");
241
- $formArray = json_decode($postvalue->g_attribute_mapping, true);
242
- foreach ($fixed_att_select_list as $fixed_key) {
243
- if(isset($formArray[$fixed_key]) && $formArray[$fixed_key] != "" ){
244
- if($fixed_key == "shipping" && $formArray[$fixed_key] != ""){
245
- $temp_product[$fixed_key]['price']['value'] = sanitize_text_field($formArray[$fixed_key]);
246
- $temp_product[$fixed_key]['price']['currency'] = sanitize_text_field($tvc_currency);
247
- $temp_product[$fixed_key]['country'] = sanitize_text_field($formArray['target_country']);
248
- }else if($fixed_key == "tax" && $formArray[$fixed_key] != ""){
249
- $temp_product['taxes']['rate'] = sanitize_text_field($formArray[$fixed_key]);
250
- $temp_product['taxes']['country'] = sanitize_text_field($formArray['target_country']);
251
- }else if( $formArray[$fixed_key] != ""){
252
- $temp_product[$fixed_key] = sanitize_text_field($formArray[$fixed_key]);
253
- }
 
 
254
  }
255
- unset($formArray[$fixed_key]);
256
- }
257
 
258
- $product = array_merge($temp_product,$product);
259
- // for variable
260
- if( !empty($prd) && $prd->get_type() == "variable" ){
261
- $p_variations = $prd->get_children();
262
- if(!empty($p_variations)){
263
- foreach ($p_variations as $v_key => $variation_id) {
264
- $variation = wc_get_product( $variation_id );
265
- if(empty($variation)){
266
- continue;
267
- }
268
- $variation_description = wc_format_content($variation->get_description());
269
- unset($product['customAttributes']);
270
- $postmeta_var = (object)$this->TVC_Admin_Helper->tvc_get_post_meta($variation_id);
271
- $formArray_val = $formArray['title'];
272
- $product['title'] = (isset($postObj->$formArray_val))?sanitize_text_field($postObj->$formArray_val):get_the_title($postvalue->w_product_id);
273
- $tvc_temp_desc_key = $formArray['description'];
274
- $product['description'] = ( $variation_description != "")?$variation_description:$postObj->$tvc_temp_desc_key;
275
- $product['offer_id'] = esc_attr($variation_id);
276
- $product['id'] = esc_attr($variation_id);
277
- $product['item_group_id'] = esc_attr($postvalue->w_product_id);
278
- $productTypes = $this->get_product_category($postvalue->w_product_id);
279
- if(!empty($productTypes)){
280
- $product['productTypes'] = $productTypes;
281
- }
282
- $image_id = $variation->get_image_id();
283
- $product['image_link'] = esc_url_raw(wp_get_attachment_image_url($image_id, 'full'));
284
- if(isset($variation_attributes) && !empty($variation_attributes) ){
285
- foreach($variation_attributes as $va_key => $va_value ){
286
- $va_key = str_replace("_", " ", $va_key);
287
- if (strpos($va_key, 'color') !== false) {
288
- $product['color'] = $va_value;
289
- }else if (strpos($va_key, 'size') !== false) {
290
- $product['sizes'] = $va_value;
291
- }else{
292
- $va_key = str_replace("attribute", "", $va_key);
293
- $product['customAttributes'][] = array("name"=>$va_key, "value"=>$va_value);
294
- }
295
  }
296
- }
297
-
298
- foreach($formArray as $key => $value){
299
- if($key == 'price'){
300
- if(isset($postmeta_var->$value) && $postmeta_var->$value > 0){
301
- $product[$key]['value'] = $postmeta_var->$value;
302
- }else if(isset($postmeta_var->_regular_price) && $postmeta_var->_regular_price && $postmeta_var->_regular_price >0 ){
303
- $product[$key]['value'] = $postmeta_var->_regular_price;
304
- }else if(isset($postmeta_var->_price) && $postmeta_var->_price && $postmeta_var->_price >0 ){
305
- $product[$key]['value'] = $postmeta_var->_price;
306
- }else if(isset($postmeta_var->_sale_price) && $postmeta_var->_sale_price && $postmeta_var->_sale_price >0 ){
307
- $product[$key]['value'] = $postmeta_var->_sale_price;
308
- }else{
309
- unset($product[$key]);
310
- }
311
- if(isset($product[$key]['value']) && $product[$key]['value'] >0){
312
- $product[$key]['currency'] = sanitize_text_field($tvc_currency);
313
- }else{
314
- $skipProducts[$postmeta_var->ID] = $postmeta_var;
315
- }
316
- }else if($key == 'sale_price'){
317
- if(isset($postmeta_var->$value) && $postmeta_var->$value > 0){
318
- $product[$key]['value'] = $postmeta_var->$value;
319
- }else if(isset($postmeta_var->_sale_price) && $postmeta_var->_sale_price && $postmeta_var->_sale_price >0 ){
320
- $product[$key]['value'] = $postmeta_var->_sale_price;
321
- }else{
322
- unset($product[$key]);
323
- }
324
- if(isset($product[$key]['value']) && $product[$key]['value'] >0){
325
- $product[$key]['currency'] = sanitize_text_field($tvc_currency);
326
- }
327
- }else if($key == 'availability'){
328
- $tvc_find = array("instock","outofstock","onbackorder");
329
- $tvc_replace = array("in stock","out of stock","preorder");
330
- if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
331
- $stock_status = $postmeta_var->$value;
332
- $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
333
- $product[$key] = sanitize_text_field($stock_status);
334
- }else{
335
- $stock_status = $postmeta_var->_stock_status;
336
- $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
337
- $product[$key] = sanitize_text_field($stock_status);
338
  }
339
- }else if(in_array($key, array("brand")) && $plan_id != 1){
340
- //list of cutom option added
341
- $product_brand = ""; $is_custom_attr_brand = false;
342
- $woo_attr_list = json_decode(json_encode($this->TVC_Admin_Helper->getTableData($tve_table_prefix.'woocommerce_attribute_taxonomies', ['attribute_name'])), true);
343
- if(!empty($woo_attr_list)){
344
- foreach ($woo_attr_list as $key_attr => $value_attr) {
345
- if(isset($value_attr['field']) && $value_attr['field'] == $value){
346
- $is_custom_attr_brand = true;
347
- $product_brand = $this->TVC_Admin_Helper->get_custom_taxonomy_name($postvalue->w_product_id, "pa_".$value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  }
349
  }
 
 
 
 
 
 
 
 
350
  }
351
- if($is_custom_attr_brand == false && $product_brand == ""){
352
- $product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
353
- }
354
- if($product_brand != ""){
355
- $product[$key] = sanitize_text_field($product_brand);
356
- }
357
- }else if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
358
- $product[$key] = sanitize_text_field($postmeta_var->$value);
359
  }
 
 
 
 
 
 
 
 
360
  }
361
- $item = [
362
- 'merchant_id' => sanitize_text_field($merchantId),
363
- 'batch_id' => sanitize_text_field(++$batchId),
364
- 'method' => 'insert',
365
- 'product' => $product
366
- ];
367
- $items[] = $item;
368
  }
369
- }
370
-
371
- }else if( !empty($prd) ){ // for simple product
372
- $image_id = $prd->get_image_id();
373
- $product['image_link'] = esc_url_raw(wp_get_attachment_image_url($image_id, 'full'));
374
- $productTypes = $this->get_product_category($postvalue->w_product_id);
375
- if(!empty($productTypes)){
376
- $product['productTypes'] = $productTypes;
377
- }
378
- foreach($formArray as $key => $value){
379
- if($key == 'price'){
380
- if(isset($postObj->$value) && $postObj->$value > 0){
381
- $product[$key]['value'] = $postObj->$value;
382
- }else if(isset($postObj->_regular_price) && $postObj->_regular_price && $postObj->_regular_price >0 ){
383
- $product[$key]['value'] = $postObj->_regular_price;
384
- }else if(isset($postObj->_price) && $postObj->_price && $postObj->_price >0 ){
385
- $product[$key]['value'] = $postObj->_price;
386
- }else if(isset($postObj->_sale_price) && $postObj->_sale_price && $postObj->_sale_price >0 ){
387
- $product[$key]['value'] = $postObj->_sale_price;
388
- }
389
- if(isset($product[$key]['value']) && $product[$key]['value'] >0){
390
- $product[$key]['currency'] = sanitize_text_field($tvc_currency);
391
- }else{
392
- $skipProducts[$postObj->ID] = $postObj;
393
- }
394
- }else if($key == 'sale_price'){
395
- if(isset($postObj->$value) && $postObj->$value > 0){
396
- $product[$key]['value'] = $postObj->$value;
397
- }else if(isset($postObj->_sale_price) && $postObj->_sale_price && $postObj->_sale_price >0 ){
398
- $product[$key]['value'] = $postObj->_sale_price;
399
- }
400
- if(isset($product[$key]['value']) && $product[$key]['value'] >0){
401
- $product[$key]['currency'] = sanitize_text_field($tvc_currency);
402
- }
403
- }else if($key == 'availability'){
404
- $tvc_find = array("instock","outofstock","onbackorder");
405
- $tvc_replace = array("in stock","out of stock","preorder");
406
- if(isset($postObj->$value) && $postObj->$value != ""){
407
- $stock_status = $postObj->$value;
408
- $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
409
- $product[$key] = sanitize_text_field($stock_status);
410
- }else{
411
- $stock_status = $postObj->_stock_status;
412
- $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
413
- $product[$key] = sanitize_text_field($stock_status);
414
- }
415
- }else if(in_array($key, array("brand")) && $plan_id != 1){
416
- //list of cutom option added
417
- $product_brand = ""; $is_custom_attr_brand = false;
418
- $woo_attr_list = json_decode(json_encode($this->TVC_Admin_Helper->getTableData($tve_table_prefix.'woocommerce_attribute_taxonomies', ['attribute_name'])), true);
419
- if(!empty($woo_attr_list)){
420
- foreach ($woo_attr_list as $key_attr => $value_attr) {
421
- if(isset($value_attr['field']) && $value_attr['field'] == $value){
422
- $is_custom_attr_brand = true;
423
- $product_brand = $this->TVC_Admin_Helper->get_custom_taxonomy_name($postvalue->w_product_id, "pa_".$value);
 
 
424
  }
425
  }
426
- }
427
- if($is_custom_attr_brand == false && $product_brand == ""){
428
- $product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
429
- }
430
- if($product_brand != ""){
431
- $product[$key] = sanitize_text_field($product_brand);
432
- }
433
- }else if(isset($postObj->$value) && $postObj->$value != ""){
434
- $product[$key] = $postObj->$value;
435
  }
 
 
 
 
 
 
 
 
436
  }
437
- $item = [
438
- 'merchant_id' => sanitize_text_field($merchantId),
439
- 'batch_id' => sanitize_text_field(++$batchId),
440
- 'method' => 'insert',
441
- 'product' => $product
442
- ];
443
- $items[] = $item;
444
  }
 
445
  }
446
- return array('items' => $items, 'skipProducts'=> $skipProducts, 'product_ids'=>$product_ids);
 
447
  }
448
  }
449
  public function call_auto_sync_product( $last_sync_product_id = array()){
 
450
  $product_count = $this->TVC_Admin_DB_Helper->tvc_row_count('ee_product_sync_data');
451
  //$count = 0;
452
  $pre_last_sync_product_id = sanitize_text_field($last_sync_product_id);
@@ -464,7 +493,12 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
464
  $products = $wpdb->get_results( $wpdb->prepare("select * from `$tablename` where `id` > %d LIMIT %d", $last_sync_product_id, $product_batch_size), OBJECT);
465
  $entries = [];
466
  if(!empty($products)){
467
- $p_map_attribute = $this->tvc_get_map_product_attribute($products, $tvc_currency, $merchantId);
 
 
 
 
 
468
  if(!empty($p_map_attribute) && isset($p_map_attribute['items']) && !empty($p_map_attribute['items'])){
469
  // call product sync API
470
  $data = [
@@ -473,27 +507,14 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
473
  'subscription_id' => sanitize_text_field($subscriptionId),
474
  'entries' => $p_map_attribute['items']
475
  ];
476
- $url = $this->apiDomain.'/products/batch';
477
- $args = array(
478
- 'timeout' => 10000,
479
- 'headers' => array(
480
- 'Authorization' => "Bearer MTIzNA==",
481
- 'Content-Type' => 'application/json',
482
- 'AccessToken' => $this->generateAccessToken($this->get_tvc_access_token(), $this->get_tvc_refresh_token())
483
- ),
484
- 'body' => wp_json_encode($data)
485
- );
486
- $request = wp_remote_post(esc_url_raw($url), $args);
487
-
488
- // Retrieve information
489
- $response_code = wp_remote_retrieve_response_code($request);
490
- $response_message = wp_remote_retrieve_response_message($request);
491
- $response_body = json_decode(wp_remote_retrieve_body($request));
492
  $sync_status = 0;
493
- if((isset($response_body->error) && $response_body->error == '')){
494
  $sync_status = 1;
495
  }
496
  // End call product sync API
 
497
  $sync_product_ids = (isset($p_map_attribute['product_ids']))?$p_map_attribute['product_ids']:"";
498
  $last_sync_product_id =end($products)->id;
499
  $total_sync_product = 0;
@@ -532,6 +553,7 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
532
  );
533
  $this->TVC_Admin_DB_Helper->tvc_add_row('ee_product_sync_call', $t_data, array("%s", "%d", "%d", "%s", "%s", "%s", "%d", "%d", "%d" ));
534
  as_enqueue_async_action('ee_auto_product_sync_check', array('last_sync_product_id' => intval($last_sync_product_id) ));
 
535
  }
536
  }
537
  }
@@ -632,6 +654,143 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
632
  'display' => esc_html__( 'Every Five Seconds' ) );
633
  return $schedules;
634
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
635
  }// end Class
636
  }
637
  new TVC_Admin_Auto_Product_sync_Helper();
26
  add_filter( 'cron_schedules', array($this,'tvc_add_cron_interval_for_product_sync') );
27
 
28
  //add_action('admin_init',array($this,'call_auto_sync_product_ttt'));
29
+ add_action('rest_api_init', function () {
30
+ register_rest_route( 'conversios-productsync/v1', 'cron-productsync', array(
31
+ 'methods' => 'GET',
32
+ 'callback' => array($this, 'cron_todo_product_sync'),
33
+ 'permission_callback' => '__return_true'
34
+ ));
35
+ });
36
  }
37
 
38
  public function includes() {
221
  }
222
 
223
  public function tvc_get_map_product_attribute($products, $tvc_currency, $merchantId){
224
+ try{
225
+ if(!empty($products)){
226
+ global $wpdb;
227
+ $tve_table_prefix = $wpdb->prefix;
228
+ $plan_id = $this->TVC_Admin_Helper->get_plan_id();
229
+ $items = [];
230
+ $validProducts = [];
231
+ $skipProducts = [];
232
+ $product_ids = [];
233
+ $deletedIds = [];
234
+ $batchId = time();
235
+ foreach ($products as $postkey => $postvalue) {
236
+ $product_ids[] = $postvalue->w_product_id;
237
+ $postmeta = [];
238
+ $postmeta = $this->TVC_Admin_Helper->tvc_get_post_meta($postvalue->w_product_id);
239
+ $prd = wc_get_product($postvalue->w_product_id);
240
+ $postObj = (object) array_merge((array) get_post($postvalue->w_product_id), (array) $postmeta);
241
+
242
+ $product = array(
243
+ //'offer_id'=>sanitize_text_field($postvalue->w_product_id),
244
+ 'channel'=>'online',
245
+ 'link'=> esc_url_raw(get_permalink($postvalue->w_product_id)),
246
+ 'google_product_category'=>sanitize_text_field($postvalue->g_cat_id)
247
+ );
248
 
249
+ $temp_product=array();
250
+ $fixed_att_select_list = array("gender", "age_group", "shipping", "tax", "content_language", "target_country", "condition");
251
+ $formArray = json_decode($postvalue->g_attribute_mapping, true);
252
+ foreach ($fixed_att_select_list as $fixed_key) {
253
+ if(isset($formArray[$fixed_key]) && $formArray[$fixed_key] != "" ){
254
+ if($fixed_key == "shipping" && $formArray[$fixed_key] != ""){
255
+ $temp_product[$fixed_key]['price']['value'] = sanitize_text_field($formArray[$fixed_key]);
256
+ $temp_product[$fixed_key]['price']['currency'] = sanitize_text_field($tvc_currency);
257
+ $temp_product[$fixed_key]['country'] = sanitize_text_field($formArray['target_country']);
258
+ }else if($fixed_key == "tax" && $formArray[$fixed_key] != ""){
259
+ $temp_product['taxes']['rate'] = sanitize_text_field($formArray[$fixed_key]);
260
+ $temp_product['taxes']['country'] = sanitize_text_field($formArray['target_country']);
261
+ }else if( $formArray[$fixed_key] != ""){
262
+ $temp_product[$fixed_key] = sanitize_text_field($formArray[$fixed_key]);
263
+ }
264
+ }
265
+ unset($formArray[$fixed_key]);
266
  }
 
 
267
 
268
+ $product = array_merge($temp_product,$product);
269
+ // for variable
270
+ if( !empty($prd) && $prd->get_type() == "variable" ){
271
+ $p_variations = $prd->get_children();
272
+ if(!empty($p_variations)){
273
+ foreach ($p_variations as $v_key => $variation_id) {
274
+ $variation = wc_get_product( $variation_id );
275
+ if(empty($variation)){
276
+ continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  }
278
+ $variation_description = wc_format_content($variation->get_description());
279
+ unset($product['customAttributes']);
280
+ $postmeta_var = (object)$this->TVC_Admin_Helper->tvc_get_post_meta($variation_id);
281
+ $formArray_val = $formArray['title'];
282
+ $product['title'] = (isset($postObj->$formArray_val))?sanitize_text_field($postObj->$formArray_val):get_the_title($postvalue->w_product_id);
283
+ $tvc_temp_desc_key = $formArray['description'];
284
+ $product['description'] = ( $variation_description != "")?sanitize_text_field($variation_description):sanitize_text_field($postObj->$tvc_temp_desc_key);
285
+ // $product['offer_id'] = esc_attr($variation_id);
286
+ // $product['id'] = esc_attr($variation_id);
287
+ $product['item_group_id'] = esc_attr($postvalue->w_product_id);
288
+ $productTypes = $this->get_product_category($postvalue->w_product_id);
289
+ if(!empty($productTypes)){
290
+ $product['productTypes'] = $productTypes;
291
+ }
292
+ $image_id = $variation->get_image_id();
293
+ $product['image_link'] = esc_url_raw(wp_get_attachment_image_url($image_id, 'full'));
294
+ $variation_attributes = $variation->get_variation_attributes();
295
+ if(isset($variation_attributes) && !empty($variation_attributes) ){
296
+ foreach($variation_attributes as $va_key => $va_value ){
297
+ $va_key = str_replace("_", " ", $va_key);
298
+ if (strpos($va_key, 'color') !== false) {
299
+ $product['color'] = $va_value;
300
+ }else if (strpos($va_key, 'size') !== false) {
301
+ $product['sizes'] = $va_value;
302
+ }else{
303
+ $va_key = str_replace("attribute", "", $va_key);
304
+ $product['customAttributes'][] = array("name"=>$va_key, "value"=>$va_value);
305
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  }
307
+ }
308
+
309
+ foreach($formArray as $key => $value){
310
+ if($key == 'id'){
311
+ $product[$key] = isset($postmeta_var->$value) ? $postmeta_var->$value : $variation_id;
312
+ $product['offer_id'] = isset($postmeta_var->$value) ? $postmeta_var->$value : $variation_id;
313
+ }elseif($key == 'gtin' && ( isset($postmeta_var->$value) || isset($postObj->$value) ) ){
314
+ $product[$key] = isset($postmeta_var->$value) ? $postmeta_var->$value : $postObj->$value;
315
+ }elseif($key == 'mpn' && ( isset($postmeta_var->$value) || isset($postObj->$value) )){
316
+ $product[$key] = isset($postmeta_var->$value) ? $postmeta_var->$value : $postObj->$value;
317
+ }elseif($key == 'price'){
318
+ if(isset($postmeta_var->$value) && $postmeta_var->$value > 0){
319
+ $product[$key]['value'] = $postmeta_var->$value;
320
+ }else if(isset($postmeta_var->_regular_price) && $postmeta_var->_regular_price && $postmeta_var->_regular_price >0 ){
321
+ $product[$key]['value'] = $postmeta_var->_regular_price;
322
+ }else if(isset($postmeta_var->_price) && $postmeta_var->_price && $postmeta_var->_price >0 ){
323
+ $product[$key]['value'] = $postmeta_var->_price;
324
+ }else if(isset($postmeta_var->_sale_price) && $postmeta_var->_sale_price && $postmeta_var->_sale_price >0 ){
325
+ $product[$key]['value'] = $postmeta_var->_sale_price;
326
+ }else{
327
+ unset($product[$key]);
328
+ }
329
+ if(isset($product[$key]['value']) && $product[$key]['value'] >0){
330
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
331
+ }else{
332
+ $skipProducts[$postmeta_var->ID] = $postmeta_var;
333
+ }
334
+ }else if($key == 'sale_price'){
335
+ if(isset($postmeta_var->$value) && $postmeta_var->$value > 0){
336
+ $product[$key]['value'] = $postmeta_var->$value;
337
+ }else if(isset($postmeta_var->_sale_price) && $postmeta_var->_sale_price && $postmeta_var->_sale_price >0 ){
338
+ $product[$key]['value'] = $postmeta_var->_sale_price;
339
+ }else{
340
+ unset($product[$key]);
341
+ }
342
+ if(isset($product[$key]['value']) && $product[$key]['value'] >0){
343
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
344
+ }
345
+ }else if($key == 'availability'){
346
+ $tvc_find = array("instock","outofstock","onbackorder");
347
+ $tvc_replace = array("in stock","out of stock","preorder");
348
+ if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
349
+ $stock_status = $postmeta_var->$value;
350
+ $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
351
+ $product[$key] = sanitize_text_field($stock_status);
352
+ }else{
353
+ $stock_status = $postmeta_var->_stock_status;
354
+ $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
355
+ $product[$key] = sanitize_text_field($stock_status);
356
+ }
357
+ }else if(in_array($key, array("brand")) && $plan_id != 1){
358
+ //list of cutom option added
359
+ $product_brand = ""; $is_custom_attr_brand = false;
360
+ $woo_attr_list = json_decode(json_encode($this->TVC_Admin_Helper->getTableData($tve_table_prefix.'woocommerce_attribute_taxonomies', ['attribute_name'])), true);
361
+ if(!empty($woo_attr_list)){
362
+ foreach ($woo_attr_list as $key_attr => $value_attr) {
363
+ if(isset($value_attr['field']) && $value_attr['field'] == $value){
364
+ $is_custom_attr_brand = true;
365
+ $product_brand = $this->TVC_Admin_Helper->get_custom_taxonomy_name($postvalue->w_product_id, "pa_".$value);
366
+ }
367
  }
368
  }
369
+ if($is_custom_attr_brand == false && $product_brand == ""){
370
+ $product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
371
+ }
372
+ if($product_brand != ""){
373
+ $product[$key] = sanitize_text_field($product_brand);
374
+ }
375
+ }else if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
376
+ $product[$key] = sanitize_text_field($postmeta_var->$value);
377
  }
 
 
 
 
 
 
 
 
378
  }
379
+ $item = [
380
+ 'merchant_id' => sanitize_text_field($merchantId),
381
+ 'batch_id' => sanitize_text_field(++$batchId),
382
+ 'method' => 'insert',
383
+ 'product' => $product
384
+ ];
385
+ $items[] = $item;
386
+ $validProducts[] = $postvalue;
387
  }
388
+ } else {
389
+ //Delete the variant product which does not have children
390
+ $deletedIds[] = $postvalue->w_product_id;
 
 
 
 
391
  }
392
+ }else if( !empty($prd) ){ // for simple product
393
+ $image_id = $prd->get_image_id();
394
+ $product['image_link'] = esc_url_raw(wp_get_attachment_image_url($image_id, 'full'));
395
+ $productTypes = $this->get_product_category($postvalue->w_product_id);
396
+ if(!empty($productTypes)){
397
+ $product['productTypes'] = $productTypes;
398
+ }
399
+ foreach($formArray as $key => $value){
400
+ if($key == 'id'){
401
+ $product[$key] = isset($postObj->$value) ? $postObj->$value : $postvalue->w_product_id;
402
+ $product['offer_id'] = isset($postObj->$value) ? $postObj->$value : $postvalue->w_product_id;
403
+ }elseif($key == 'price'){
404
+ if(isset($postObj->$value) && $postObj->$value > 0){
405
+ $product[$key]['value'] = $postObj->$value;
406
+ }else if(isset($postObj->_regular_price) && $postObj->_regular_price && $postObj->_regular_price >0 ){
407
+ $product[$key]['value'] = $postObj->_regular_price;
408
+ }else if(isset($postObj->_price) && $postObj->_price && $postObj->_price >0 ){
409
+ $product[$key]['value'] = $postObj->_price;
410
+ }else if(isset($postObj->_sale_price) && $postObj->_sale_price && $postObj->_sale_price >0 ){
411
+ $product[$key]['value'] = $postObj->_sale_price;
412
+ }
413
+ if(isset($product[$key]['value']) && $product[$key]['value'] >0){
414
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
415
+ }else{
416
+ $skipProducts[$postObj->ID] = $postObj;
417
+ }
418
+ }else if($key == 'sale_price'){
419
+ if(isset($postObj->$value) && $postObj->$value > 0){
420
+ $product[$key]['value'] = $postObj->$value;
421
+ }else if(isset($postObj->_sale_price) && $postObj->_sale_price && $postObj->_sale_price >0 ){
422
+ $product[$key]['value'] = $postObj->_sale_price;
423
+ }
424
+ if(isset($product[$key]['value']) && $product[$key]['value'] >0){
425
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
426
+ }
427
+ }else if($key == 'availability'){
428
+ $tvc_find = array("instock","outofstock","onbackorder");
429
+ $tvc_replace = array("in stock","out of stock","preorder");
430
+ if(isset($postObj->$value) && $postObj->$value != ""){
431
+ $stock_status = $postObj->$value;
432
+ $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
433
+ $product[$key] = sanitize_text_field($stock_status);
434
+ }else{
435
+ $stock_status = $postObj->_stock_status;
436
+ $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
437
+ $product[$key] = sanitize_text_field($stock_status);
438
+ }
439
+ }else if(in_array($key, array("brand")) && $plan_id != 1){
440
+ //list of cutom option added
441
+ $product_brand = ""; $is_custom_attr_brand = false;
442
+ $woo_attr_list = json_decode(json_encode($this->TVC_Admin_Helper->getTableData($tve_table_prefix.'woocommerce_attribute_taxonomies', ['attribute_name'])), true);
443
+ if(!empty($woo_attr_list)){
444
+ foreach ($woo_attr_list as $key_attr => $value_attr) {
445
+ if(isset($value_attr['field']) && $value_attr['field'] == $value){
446
+ $is_custom_attr_brand = true;
447
+ $product_brand = $this->TVC_Admin_Helper->get_custom_taxonomy_name($postvalue->w_product_id, "pa_".$value);
448
+ }
449
  }
450
  }
451
+ if($is_custom_attr_brand == false && $product_brand == ""){
452
+ $product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
453
+ }
454
+ if($product_brand != ""){
455
+ $product[$key] = sanitize_text_field($product_brand);
456
+ }
457
+ }else if(isset($postObj->$value) && $postObj->$value != ""){
458
+ $product[$key] = $postObj->$value;
459
+ }
460
  }
461
+ $item = [
462
+ 'merchant_id' => sanitize_text_field($merchantId),
463
+ 'batch_id' => sanitize_text_field(++$batchId),
464
+ 'method' => 'insert',
465
+ 'product' => $product
466
+ ];
467
+ $items[] = $item;
468
+ $validProducts[] = $postvalue;
469
  }
 
 
 
 
 
 
 
470
  }
471
+ return array('items' => $items, 'valid_products'=>$validProducts, 'deleted_products'=> $deletedIds, 'skipProducts'=> $skipProducts, 'product_ids'=>$product_ids);
472
  }
473
+ } catch (Exception $e) {
474
+ $this->TVC_Admin_Helper ->plugin_log($e->getMessage(), 'product_sync');
475
  }
476
  }
477
  public function call_auto_sync_product( $last_sync_product_id = array()){
478
+ $this->TVC_Admin_Helper->plugin_log("Start auto sync with last_sync_product_id=".$last_sync_product_id, 'product_sync');
479
  $product_count = $this->TVC_Admin_DB_Helper->tvc_row_count('ee_product_sync_data');
480
  //$count = 0;
481
  $pre_last_sync_product_id = sanitize_text_field($last_sync_product_id);
493
  $products = $wpdb->get_results( $wpdb->prepare("select * from `$tablename` where `id` > %d LIMIT %d", $last_sync_product_id, $product_batch_size), OBJECT);
494
  $entries = [];
495
  if(!empty($products)){
496
+ $p_map_attribute = $this->tvc_get_map_product_attribute($products, $tvc_currency, $merchantId);
497
+ //Delete the variant product which does not have children
498
+ if(!empty($p_map_attribute) && isset($p_map_attribute['deleted_products']) && !empty($p_map_attribute['deleted_products'])){
499
+ $dids = esc_sql(implode(', ', $p_map_attribute['deleted_products']));
500
+ $wpdb->query("DELETE FROM $tablename where `w_product_id` in ($dids)");
501
+ }
502
  if(!empty($p_map_attribute) && isset($p_map_attribute['items']) && !empty($p_map_attribute['items'])){
503
  // call product sync API
504
  $data = [
507
  'subscription_id' => sanitize_text_field($subscriptionId),
508
  'entries' => $p_map_attribute['items']
509
  ];
510
+ $this->TVC_Admin_Helper->plugin_log("Auto before product sync API Call for ".count($p_map_attribute['items']). " products", 'product_sync');
511
+ $response = $this->customApiObj->products_sync($data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512
  $sync_status = 0;
513
+ if($response->error== false){
514
  $sync_status = 1;
515
  }
516
  // End call product sync API
517
+ $this->TVC_Admin_Helper->plugin_log("after product sync API Call", 'product_sync');
518
  $sync_product_ids = (isset($p_map_attribute['product_ids']))?$p_map_attribute['product_ids']:"";
519
  $last_sync_product_id =end($products)->id;
520
  $total_sync_product = 0;
553
  );
554
  $this->TVC_Admin_DB_Helper->tvc_add_row('ee_product_sync_call', $t_data, array("%s", "%d", "%d", "%s", "%s", "%s", "%d", "%d", "%d" ));
555
  as_enqueue_async_action('ee_auto_product_sync_check', array('last_sync_product_id' => intval($last_sync_product_id) ));
556
+ $this->TVC_Admin_Helper->plugin_log("Done and update ee_auto_product_sync_check", 'product_sync');
557
  }
558
  }
559
  }
654
  'display' => esc_html__( 'Every Five Seconds' ) );
655
  return $schedules;
656
  }
657
+
658
+ public function cron_todo_product_sync($request)
659
+ {
660
+ $TVC_Admin_Helper = new TVC_Admin_Helper();
661
+ $ee_additional_data = $TVC_Admin_Helper->get_ee_additional_data();
662
+ as_unschedule_all_actions('auto_product_sync_process_scheduler');
663
+ as_unschedule_all_actions('init_product_sync_process_scheduler');
664
+ global $wpdb;
665
+ try {
666
+ $product_db_batch_size = 200; // batch size to insert in database
667
+ $TVC_Admin_DB_Helper = new TVC_Admin_DB_Helper();
668
+ $prouct_pre_sync_table = esc_sql($wpdb->prefix . "ee_prouct_pre_sync_data");
669
+ $mappedCats = unserialize(get_option('ee_prod_mapped_cats'));
670
+ print_r($ee_additional_data);
671
+ if (!empty($ee_additional_data) && isset($ee_additional_data['is_mapping_update']) && $ee_additional_data['is_mapping_update'] == true) {
672
+ // Add products in product pre sync table
673
+ if (!empty($mappedCats)) {
674
+ // truncate data from product pre sync table
675
+ if ($TVC_Admin_DB_Helper->tvc_row_count("ee_prouct_pre_sync_data") > 0) {
676
+ $TVC_Admin_DB_Helper->tvc_safe_truncate_table($prouct_pre_sync_table);
677
+ }
678
+
679
+ $batch_count = 0;
680
+ $values = array();
681
+ $place_holders = array();
682
+ foreach ($mappedCats as $mc_key => $mappedCat) {
683
+ $all_products = get_posts(
684
+ array(
685
+ 'post_type' => 'product',
686
+ 'posts_per_page' => 1500,
687
+ 'numberposts' => -1,
688
+ 'post_status' => 'publish',
689
+ 'tax_query' => array(
690
+ array(
691
+ 'taxonomy' => 'product_cat',
692
+ 'field' => 'term_id',
693
+ 'terms' => $mc_key,
694
+ /* category name */
695
+ 'operator' => 'IN',
696
+ 'include_children' => false
697
+ )
698
+ )
699
+ )
700
+ );
701
+ $TVC_Admin_Helper->plugin_log("category id " . $mc_key . " gmc product name " . $mappedCat['name'] . " - product count - " . count($all_products), 'product_sync'); // Add logs
702
+ if (!empty($all_products)) {
703
+ foreach ($all_products as $postvalue) {
704
+ $batch_count++;
705
+ array_push($values, esc_sql($postvalue->ID), esc_sql($mc_key), esc_sql($mappedCat['id']), 1, date('Y-m-d H:i:s', current_time('timestamp')));
706
+ $place_holders[] = "('%d', '%d', '%d','%d', '%s')";
707
+ if ($batch_count >= $product_db_batch_size) {
708
+ $query = "INSERT INTO `$prouct_pre_sync_table` (w_product_id, w_cat_id, g_cat_id, product_sync_profile_id, create_date) VALUES ";
709
+ $query .= implode(', ', $place_holders);
710
+ $wpdb->query($wpdb->prepare($query, $values));
711
+ $batch_count = 0;
712
+ $values = array();
713
+ $place_holders = array();
714
+ }
715
+ } //end product list loop
716
+ } // end products if
717
+ } //end category loop
718
+ // Add products in database
719
+ if ($batch_count > 0) {
720
+ $query = "INSERT INTO `$prouct_pre_sync_table` (w_product_id, w_cat_id, g_cat_id, product_sync_profile_id, create_date) VALUES ";
721
+ $query .= implode(', ', $place_holders);
722
+ $wpdb->query($wpdb->prepare($query, $values));
723
+ }
724
+ }
725
+
726
+ $ee_additional_data['is_mapping_update'] = false;
727
+ $ee_additional_data['is_process_start'] = true;
728
+ $ee_additional_data['product_sync_alert'] = "Product sync process is ready to start";
729
+ $TVC_Admin_Helper->set_ee_additional_data($ee_additional_data);
730
+ }
731
+
732
+ // Get again data to verify falgs
733
+ $ee_additional_data = $TVC_Admin_Helper->get_ee_additional_data();
734
+ $ee_additional_data['product_sync_alert'] = NULL;
735
+ $TVC_Admin_Helper->set_ee_additional_data($ee_additional_data);
736
+ /*try {
737
+ // add scheduled cron job
738
+ as_unschedule_all_actions( 'auto_product_sync_process_scheduler' );*/
739
+ $TVC_Admin_Helper->plugin_log("auto product sync process start", 'product_sync');
740
+ if (!empty($ee_additional_data) && isset($ee_additional_data['is_process_start']) && $ee_additional_data['is_process_start'] == true) {
741
+ if (!class_exists('TVCProductSyncHelper')) {
742
+ include(ENHANCAD_PLUGIN_DIR . 'includes/setup/class-tvc-product-sync-helper.php');
743
+ }
744
+ $TVCProductSyncHelper = new TVCProductSyncHelper();
745
+ $response = $TVCProductSyncHelper->call_batch_wise_auto_sync_product();
746
+ if (!empty($response) && isset($response['message'])) {
747
+ $TVC_Admin_Helper->plugin_log("Batch wise auto sync process response " . $response['message'], 'product_sync');
748
+ }
749
+
750
+ $tablename = esc_sql($wpdb->prefix . "ee_prouct_pre_sync_data");
751
+ $total_pending_pro = $wpdb->get_var("SELECT COUNT(*) as a FROM $tablename where `status` = 0");
752
+ if ($total_pending_pro == 0) {
753
+ // Truncate pre sync table
754
+ $TVC_Admin_DB_Helper = new TVC_Admin_DB_Helper();
755
+ $TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
756
+
757
+ $ee_additional_data['is_process_start'] = false;
758
+ $ee_additional_data['is_auto_sync_start'] = true;
759
+ $ee_additional_data['product_sync_alert'] = NULL;
760
+ $TVC_Admin_Helper->set_ee_additional_data($ee_additional_data);
761
+ $TVC_Admin_Helper->plugin_log("product sync process done", 'product_sync');
762
+ } else {
763
+ /*// add scheduled cron job
764
+ if ( false === as_next_scheduled_action( 'tvc_add_cron_interval_for_product_sync' ) ) {
765
+ // as_schedule_cron_action( time(), '0/3 * * * *', 'auto_product_sync_process_scheduler' );
766
+ as_schedule_single_action( time()+5, 'auto_product_sync_process_scheduler' );
767
+ }*/
768
+ $TVC_Admin_Helper->plugin_log("recall product sync process", 'product_sync');
769
+ // $this->tvc_call_auto_product_sync_process();
770
+ }
771
+ } else {
772
+ // add scheduled cron job
773
+ // $TVC_Admin_Helper->plugin_log("auto test 2", 'product_sync');
774
+ // as_unschedule_all_actions('auto_product_sync_process_scheduler');
775
+ // as_unschedule_action('auto_product_sync_process_scheduler');
776
+ // $TVC_Admin_Helper->plugin_log("auto test 3", 'product_sync');
777
+ $TVC_Admin_Helper->plugin_log("product sync process is already done", 'product_sync');
778
+ }
779
+ echo json_encode(array('status' => 'success', "message" => esc_html__("Product sync process started successfully")));
780
+ return true;
781
+ /*} catch (Exception $e) {
782
+ $ee_additional_data['product_sync_alert'] = $e->getMessage();
783
+ $TVC_Admin_Helper->set_ee_additional_data($ee_additional_data);
784
+ $TVC_Admin_Helper->plugin_log($e->getMessage(), 'product_sync');
785
+ return true;
786
+ }*/
787
+ } catch (Exception $e) {
788
+ $ee_additional_data['product_sync_alert'] = $e->getMessage();
789
+ $TVC_Admin_Helper->set_ee_additional_data($ee_additional_data);
790
+ $TVC_Admin_Helper->plugin_log($e->getMessage(), 'product_sync');
791
+ }
792
+ return true;
793
+ }
794
  }// end Class
795
  }
796
  new TVC_Admin_Auto_Product_sync_Helper();
admin/css/custom-style.css CHANGED
@@ -2633,6 +2633,9 @@ textarea.form-control, .select2.select2-container--default textarea.select2-sele
2633
  .tvc-hide{
2634
  display: none;
2635
  }
 
 
 
2636
  .tvc_licence_key_change_wapper{height: 40px;}
2637
  .tvc_licence_key_change{cursor: pointer;}
2638
  .tvc_licence_key_change_wapper.google-account-analytics .acc-num{text-align: left; min-width: 100%; border: 1.3px solid #b4b9be; display: table;
2633
  .tvc-hide{
2634
  display: none;
2635
  }
2636
+ .tvc-show{
2637
+ display: block;
2638
+ }
2639
  .tvc_licence_key_change_wapper{height: 40px;}
2640
  .tvc_licence_key_change{cursor: pointer;}
2641
  .tvc_licence_key_change_wapper.google-account-analytics .acc-num{text-align: left; min-width: 100%; border: 1.3px solid #b4b9be; display: table;
admin/css/style.css CHANGED
@@ -1536,4 +1536,5 @@ site-verified-pos{
1536
  .onbordording-step .newggladsbtn{margin-bottom: 5px;}
1537
  #tvc_confirm_submite .ppblubtn.btn-w50{align-items: baseline;margin-bottom: 10px; margin-left: 8px; width: 48%; font-size: 12px;}
1538
  #tvc_confirm_submite .onbrdpp-body p{ font-size: 18px;}
1539
- #tvc_confirm_submite .ppblubtn.btn-w50:hover{color: #fff;}
 
1536
  .onbordording-step .newggladsbtn{margin-bottom: 5px;}
1537
  #tvc_confirm_submite .ppblubtn.btn-w50{align-items: baseline;margin-bottom: 10px; margin-left: 8px; width: 48%; font-size: 12px;}
1538
  #tvc_confirm_submite .onbrdpp-body p{ font-size: 18px;}
1539
+ #tvc_confirm_submite .ppblubtn.btn-w50:hover{color: #fff;}
1540
+ #con_conversion_label{margin-bottom: 5px;}
admin/helper/class-onboarding-helper.php CHANGED
@@ -371,6 +371,12 @@ if(!class_exists('Conversios_Onboarding_Helper')):
371
  $settings[$val] = isset($old_setting[$val])?sanitize_text_field($old_setting[$val]):"";
372
  }
373
 
 
 
 
 
 
 
374
  $ga_ec = (isset($data["ga_ec"]) && $data["ga_ec"] == "1")?1:0;
375
  update_option('ga_EC', sanitize_text_field($ga_ec) );
376
 
371
  $settings[$val] = isset($old_setting[$val])?sanitize_text_field($old_setting[$val]):"";
372
  }
373
 
374
+ //remove old conversion label if google_ads_id changed
375
+ if($old_setting['google_ads_id'] != $settings['google_ads_id']){
376
+ update_option( 'ee_conversio_send_to', null );
377
+ }
378
+
379
+
380
  $ga_ec = (isset($data["ga_ec"]) && $data["ga_ec"] == "1")?1:0;
381
  update_option('ga_EC', sanitize_text_field($ga_ec) );
382
 
admin/js/onboarding-custom.js CHANGED
@@ -768,7 +768,7 @@ function list_googl_ads_account(tvc_data) {
768
  }, 5000); */
769
 
770
  loaderSection(false);
771
- $('#ads-account').prop('disabled', false);
772
  }
773
  });
774
  }
@@ -822,7 +822,7 @@ function list_google_merchant_account(tvc_data){
822
  setTimeout(function(){
823
  loaderSection(false);
824
  }, 2000);
825
- $('#google_merchant_center_id').prop('disabled', false);
826
  }
827
  });
828
  }
768
  }, 5000); */
769
 
770
  loaderSection(false);
771
+ jQuery('#ads-account').prop('disabled', false);
772
  }
773
  });
774
  }
822
  setTimeout(function(){
823
  loaderSection(false);
824
  }, 2000);
825
+ jQuery('#google_merchant_center_id').prop('disabled', false);
826
  }
827
  });
828
  }
admin/partials/general-fields.php CHANGED
@@ -905,33 +905,29 @@ $is_show_tracking_method_options = $TVC_Admin_Helper->is_show_tracking_method_o
905
  </label>
906
  <label class="align-middle">
907
  <?php
908
- if($this->current_customer_id != ""){
909
- $response = $this->customApiObj->get_conversion_list($this->current_customer_id);
910
- if(property_exists($response,"error") && $response->error == true){
911
- echo "<div class='google_conversion_label_message alert alert-danger google_ads_conversion_label_message' role='alert'>No conversion labels are retrived, kindly refersh once else check if conversion label is available in your google ads account.</div>";
912
- }
913
- if(property_exists($response,"error") && $response->error == false){
914
- if(property_exists($response,"data") && $response->data != "" && !empty($response->data)){
915
- $selected_conversio_send_to = get_option('ee_conversio_send_to');?>
916
- <select name='ee_conversio_send_to' id='google_ads_conversion_label' <?php if($googleDetail->google_ads_conversion_tracking!=1){ echo 'disabled'; } ?>>
917
- <?php $selected = "";
918
- foreach ($response->data as $key => $value) {
919
- $con_string=strip_tags($value->tagSnippets);
920
- $conversion_label = $TVC_Admin_Helper->get_conversion_label($con_string);
921
- if($selected_conversio_send_to==$conversion_label){
922
- $selected = "selected";
923
- }else{
924
- $selected = "";
925
- }
926
- ?>
927
- <option <?php echo $selected; ?> value="<?php echo esc_attr($conversion_label); ?>"><?php echo esc_attr($conversion_label); ?>
928
- </option>
929
- <?php }
930
- echo "</select>";
931
- }
932
- }
933
  }
934
  ?>
 
935
  </label>
936
  </div>
937
  <?php }else{?>
@@ -983,6 +979,49 @@ $is_show_tracking_method_options = $TVC_Admin_Helper->is_show_tracking_method_o
983
  echo get_connect_google_popup_html_to_active_licence();
984
  ?>
985
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
986
  jQuery(document).ready(function () {
987
  jQuery(document).on('click','.con_faq_title',function(event){
988
  let faq_id = jQuery(this).attr("data-id");
905
  </label>
906
  <label class="align-middle">
907
  <?php
908
+ $ee_conversio_send_to = get_option('ee_conversio_send_to');
909
+ ?>
910
+ <div>
911
+ <select id="con_conversion_label" name='ee_conversio_send_to' <?php if(!empty($ee_conversio_send_to)){?>disabled <?php } ?> class="<?php if(empty($ee_conversio_send_to)){?>tvc-hide <?php } ?> ">
912
+ <?php
913
+ if(!empty($ee_conversio_send_to)){?>
914
+ <option value="<?php echo esc_attr($ee_conversio_send_to);?>" ><?php echo esc_attr($ee_conversio_send_to); ?>
915
+ </option>
916
+ <?php
917
+ } ?>
918
+ </select>
919
+ </div>
920
+ <div class='google_conversion_label_message alert alert-danger google_ads_conversion_label_message tvc-hide' role='alert'><?php esc_html_e("No conversion labels are retrived, kindly refersh once else check if conversion label is available in your google ads account.","enhanced-e-commerce-for-woocommerce-store");?>
921
+ </div>
922
+ <button id="con_edit_text" class="btn btn-primary con_conversion_label con_edit_text" data-id ="con_conversion_label" name="con_conversion_label">
923
+ <?php
924
+ if(empty($ee_conversio_send_to)){
925
+ esc_html_e("Add conversion label","enhanced-e-commerce-for-woocommerce-store");
926
+ }else{
927
+ esc_html_e("Edit conversion label","enhanced-e-commerce-for-woocommerce-store");
 
 
 
 
 
928
  }
929
  ?>
930
+ </button>
931
  </label>
932
  </div>
933
  <?php }else{?>
979
  echo get_connect_google_popup_html_to_active_licence();
980
  ?>
981
  <script>
982
+ jQuery(document).on('click','.con_edit_text', function(event) {
983
+ event.preventDefault();
984
+ jQuery("#con_conversion_label").removeAttr('disabled');
985
+ });
986
+
987
+
988
+
989
+ jQuery(document).on('click','.con_conversion_label', function(event) {
990
+ event.preventDefault();
991
+ var data = {
992
+ action: "con_get_conversion_list"
993
+ };
994
+ jQuery.ajax({
995
+ type: "POST",
996
+ dataType: "json",
997
+ url: tvc_ajax_url,
998
+ data: data,
999
+ beforeSend: function(){
1000
+ tvc_helper.loaderSection(true);
1001
+ },
1002
+ success: function(response){
1003
+ if(response == 0) {
1004
+ jQuery('.google_conversion_label_message').show();
1005
+ jQuery('#con_conversion_label').hide();
1006
+ tvc_helper.loaderSection(false);
1007
+ return;
1008
+ }else{
1009
+ var response;
1010
+ var con_select='<option value="">Please select conversion label</option>';
1011
+ for (var key in response){
1012
+ con_select +='<option value="'+response[key]+'">'+response[key]+'</option>';
1013
+ }
1014
+ document.getElementById('con_conversion_label').innerHTML = con_select;
1015
+ jQuery("#con_conversion_label").removeClass("tvc-hide");
1016
+ jQuery('.con_conversion_label').hide();
1017
+ tvc_helper.loaderSection(false);
1018
+ }
1019
+ }
1020
+
1021
+ });
1022
+ });
1023
+
1024
+
1025
  jQuery(document).ready(function () {
1026
  jQuery(document).on('click','.con_faq_title',function(event){
1027
  let faq_id = jQuery(this).attr("data-id");
enhanced-ecommerce-google-analytics.php CHANGED
@@ -15,7 +15,7 @@
15
  * Plugin Name: Conversios.io - All-in-one Google Analytics, Pixels and Product Feed Manager for WooCommerce
16
  * Plugin URI: https://www.conversios.io/
17
  * Description: Track Ecommerce events and conversions in Google Analytics, GA4, Google Ads, Facebook Pixel, Snapchat, Pinterest, Tiktok, Bing via Google Tag Manager. Build dynamic audiences and track ROAS performance in Google Ads, Meta (Facebook + Instagram), Snapchat, Pinterest, Tiktok, Microsoft Ads and Twitter to run successful shopping campaigns. Automate your product feed to Google Merchant Center for running performance max campaigns for your WooCommerce products to boost ROAS (Revenue on Ad Spends).
18
- * Version: 5.1.0
19
  * Author: Conversios
20
  * Author URI: conversios.io
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', '5.1.0' );
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 - All-in-one Google Analytics, Pixels and Product Feed Manager for WooCommerce
16
  * Plugin URI: https://www.conversios.io/
17
  * Description: Track Ecommerce events and conversions in Google Analytics, GA4, Google Ads, Facebook Pixel, Snapchat, Pinterest, Tiktok, Bing via Google Tag Manager. Build dynamic audiences and track ROAS performance in Google Ads, Meta (Facebook + Instagram), Snapchat, Pinterest, Tiktok, Microsoft Ads and Twitter to run successful shopping campaigns. Automate your product feed to Google Merchant Center for running performance max campaigns for your WooCommerce products to boost ROAS (Revenue on Ad Spends).
18
+ * Version: 5.1.1
19
  * Author: Conversios
20
  * Author URI: conversios.io
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', '5.1.1' );
41
  $fullName = plugin_basename( __FILE__ );
42
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
43
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
includes/data/class-tvc-ajax-file.php CHANGED
@@ -37,6 +37,7 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
37
  add_action('wp_ajax_tvc_call_notice_dismiss_trigger', array($this, 'tvc_call_notice_dismiss_trigger'));
38
  add_action('wp_ajax_tvc_call_notification_dismiss', array($this, 'tvc_call_notification_dismiss'));
39
  add_action('wp_ajax_auto_product_sync_setting', array($this, 'auto_product_sync_setting'));
 
40
  add_action('wp_ajax_tvc_call_active_licence', array($this, 'tvc_call_active_licence'));
41
  add_action('wp_ajax_tvc_call_add_survey', array($this, 'tvc_call_add_survey'));
42
 
@@ -554,6 +555,30 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
554
  }
555
  exit;
556
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
557
  public function tvc_call_notification_dismiss(){
558
  if($this->safe_ajax_call(filter_input(INPUT_POST, 'TVCNonce'), 'tvc_call_notification_dismiss-nonce')){
559
  $ee_dismiss_id = isset($_POST['data']['ee_dismiss_id'])?sanitize_text_field($_POST['data']['ee_dismiss_id']):"";
37
  add_action('wp_ajax_tvc_call_notice_dismiss_trigger', array($this, 'tvc_call_notice_dismiss_trigger'));
38
  add_action('wp_ajax_tvc_call_notification_dismiss', array($this, 'tvc_call_notification_dismiss'));
39
  add_action('wp_ajax_auto_product_sync_setting', array($this, 'auto_product_sync_setting'));
40
+ add_action('wp_ajax_con_get_conversion_list', array($this, 'con_get_conversion_list'));
41
  add_action('wp_ajax_tvc_call_active_licence', array($this, 'tvc_call_active_licence'));
42
  add_action('wp_ajax_tvc_call_add_survey', array($this, 'tvc_call_add_survey'));
43
 
555
  }
556
  exit;
557
  }
558
+
559
+ public function con_get_conversion_list(){
560
+ $TVC_Admin_Helper = new TVC_Admin_Helper();
561
+ $this->customApiObj = new CustomApi();
562
+ $this->current_customer_id = $TVC_Admin_Helper->get_currentCustomerId();
563
+ if($this->current_customer_id != ""){
564
+ $response = $this->customApiObj->get_conversion_list($this->current_customer_id);
565
+ if(property_exists($response,"error") && $response->error == false){
566
+ if(property_exists($response,"data") && $response->data != "" && !empty($response->data)){
567
+ $selected_conversio_send_to = get_option('ee_conversio_send_to');
568
+ $conversion_label = array();
569
+ foreach ($response->data as $key => $value) {
570
+ $con_string=strip_tags($value->tagSnippets);
571
+ $conversion_label_check = $TVC_Admin_Helper->get_conversion_label($con_string);
572
+ if($conversion_label_check != "" && $conversion_label_check != null ){
573
+ $conversion_label[] = $TVC_Admin_Helper->get_conversion_label($con_string);
574
+ }
575
+ }
576
+ echo json_encode($conversion_label);
577
+ exit;
578
+ }
579
+ }
580
+ }
581
+ }
582
  public function tvc_call_notification_dismiss(){
583
  if($this->safe_ajax_call(filter_input(INPUT_POST, 'TVCNonce'), 'tvc_call_notification_dismiss-nonce')){
584
  $ee_dismiss_id = isset($_POST['data']['ee_dismiss_id'])?sanitize_text_field($_POST['data']['ee_dismiss_id']):"";
public/class-enhanced-ecommerce-google-analytics-public-pro.php CHANGED
@@ -1696,7 +1696,7 @@ src="https://www.facebook.com/tr?id=<?php echo esc_js($this->fb_pixel_id); ?>&ev
1696
  $checkout_step_2_selector = ($checkout_step_2_selector)?$checkout_step_2_selector:"input[name=billing_first_name]";
1697
 
1698
  //first name on focus call fire
1699
- $step2_onFocus = 't_tracked_focus=0; jQuery("'. esc_js($checkout_step_2_selector).'").on("focus",function(){ if(t_tracked_focus===0){' . $code_step_2 . ' t_tracked_focus++;}});';
1700
  }
1701
  //check woocommerce version and add code
1702
  $this->wc_version_compare($step2_onFocus);
@@ -1964,15 +1964,15 @@ class Con_GTM_Tracking extends Con_Settings {
1964
  /**
1965
  * product list page
1966
  **/
1967
- public function product_list_view(){
 
1968
  if ($this->disable_tracking($this->ga_eeT)) {
1969
  return;
1970
  }
1971
  $listtype = '';
1972
  if ( isset( $woocommerce_loop['listtype'] ) && ( '' !== $woocommerce_loop['listtype'] ) ) {
1973
  $listtype = $woocommerce_loop['listtype'];
1974
- }
1975
- global $product, $woocommerce_loop;
1976
  $this->con_product_list_item_extra_tag($product, $listtype);
1977
  }
1978
  /**
@@ -2348,15 +2348,15 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
2348
  return false;
2349
  }
2350
  $product_id = $product->get_id();
2351
- $product_cat = '';
2352
  if ( is_product_category() ) {
2353
  global $wp_query;
2354
  $cat_obj = $wp_query->get_queried_object();
2355
  $product_cat = $cat_obj->name;
2356
  } else {
2357
  $product_cat = $this->con_get_product_category( $product_id );
2358
- }
2359
-
2360
  if ( is_search() ) {
2361
  $list_name = __( 'Search Results', 'duracelltomi-google-tag-manager' );
2362
  } elseif ( '' !== $listtype ) {
1696
  $checkout_step_2_selector = ($checkout_step_2_selector)?$checkout_step_2_selector:"input[name=billing_first_name]";
1697
 
1698
  //first name on focus call fire
1699
+ $step2_onFocus = 't_tracked_focus=0; jQuery(document.body).on("focus", "'. esc_js($checkout_step_2_selector).'", function(){ if(t_tracked_focus===0){' . $code_step_2 . ' t_tracked_focus++;}});';
1700
  }
1701
  //check woocommerce version and add code
1702
  $this->wc_version_compare($step2_onFocus);
1964
  /**
1965
  * product list page
1966
  **/
1967
+ public function product_list_view(){
1968
+ global $product, $woocommerce_loop;
1969
  if ($this->disable_tracking($this->ga_eeT)) {
1970
  return;
1971
  }
1972
  $listtype = '';
1973
  if ( isset( $woocommerce_loop['listtype'] ) && ( '' !== $woocommerce_loop['listtype'] ) ) {
1974
  $listtype = $woocommerce_loop['listtype'];
1975
+ }
 
1976
  $this->con_product_list_item_extra_tag($product, $listtype);
1977
  }
1978
  /**
2348
  return false;
2349
  }
2350
  $product_id = $product->get_id();
2351
+ /*$product_cat = '';
2352
  if ( is_product_category() ) {
2353
  global $wp_query;
2354
  $cat_obj = $wp_query->get_queried_object();
2355
  $product_cat = $cat_obj->name;
2356
  } else {
2357
  $product_cat = $this->con_get_product_category( $product_id );
2358
+ }*/
2359
+ $list_name = "";
2360
  if ( is_search() ) {
2361
  $list_name = __( 'Search Results', 'duracelltomi-google-tag-manager' );
2362
  } elseif ( '' !== $listtype ) {
public/class-enhanced-ecommerce-google-analytics-public.php CHANGED
@@ -1654,8 +1654,8 @@ src="https://www.facebook.com/tr?id=<?php echo esc_js($this->fb_pixel_id); ?>&ev
1654
  $checkout_step_2_selector = ( isset( $this->c_t_o['tvc_checkout_step_2_selector']) && $this->c_t_o['tvc_checkout_step_2_selector'] == "custom" )?$this->c_t_o:array();
1655
  $checkout_step_2_selector = $this->get_selector_val_from_array_for_gmt($checkout_step_2_selector, 'tvc_checkout_step_2_selector');
1656
  $checkout_step_2_selector = ($checkout_step_2_selector)?$checkout_step_2_selector:"input[name=billing_first_name]";
1657
- //first name on focus call fire
1658
- $step2_onFocus = 't_tracked_focus=0; jQuery("'. esc_js($checkout_step_2_selector).'").on("focus",function(){ if(t_tracked_focus===0){' . $code_step_2 . ' t_tracked_focus++;}});';
1659
  }
1660
  //check woocommerce version and add code
1661
  $this->wc_version_compare($step2_onFocus);
@@ -1808,15 +1808,15 @@ class Con_GTM_Tracking extends Con_Settings {
1808
  /**
1809
  * product list page
1810
  **/
1811
- public function product_list_view(){
 
1812
  if ($this->disable_tracking($this->ga_eeT)) {
1813
  return;
1814
  }
1815
  $listtype = '';
1816
  if ( isset( $woocommerce_loop['listtype'] ) && ( '' !== $woocommerce_loop['listtype'] ) ) {
1817
  $listtype = $woocommerce_loop['listtype'];
1818
- }
1819
- global $product, $woocommerce_loop;
1820
  $this->con_product_list_item_extra_tag($product, $listtype);
1821
  }
1822
  /**
@@ -2190,15 +2190,15 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
2190
  return false;
2191
  }
2192
  $product_id = $product->get_id();
2193
- $product_cat = '';
2194
  if ( is_product_category() ) {
2195
  global $wp_query;
2196
  $cat_obj = $wp_query->get_queried_object();
2197
  $product_cat = $cat_obj->name;
2198
  } else {
2199
  $product_cat = $this->con_get_product_category( $product_id );
2200
- }
2201
-
2202
  if ( is_search() ) {
2203
  $list_name = __( 'Search Results', 'duracelltomi-google-tag-manager' );
2204
  } elseif ( '' !== $listtype ) {
1654
  $checkout_step_2_selector = ( isset( $this->c_t_o['tvc_checkout_step_2_selector']) && $this->c_t_o['tvc_checkout_step_2_selector'] == "custom" )?$this->c_t_o:array();
1655
  $checkout_step_2_selector = $this->get_selector_val_from_array_for_gmt($checkout_step_2_selector, 'tvc_checkout_step_2_selector');
1656
  $checkout_step_2_selector = ($checkout_step_2_selector)?$checkout_step_2_selector:"input[name=billing_first_name]";
1657
+ //first name on focus call fire
1658
+ $step2_onFocus = 't_tracked_focus=0; jQuery(document.body).on("focus", "'. esc_js($checkout_step_2_selector).'", function(){ if(t_tracked_focus===0){' . $code_step_2 . ' t_tracked_focus++;}});';
1659
  }
1660
  //check woocommerce version and add code
1661
  $this->wc_version_compare($step2_onFocus);
1808
  /**
1809
  * product list page
1810
  **/
1811
+ public function product_list_view(){
1812
+ global $product, $woocommerce_loop;
1813
  if ($this->disable_tracking($this->ga_eeT)) {
1814
  return;
1815
  }
1816
  $listtype = '';
1817
  if ( isset( $woocommerce_loop['listtype'] ) && ( '' !== $woocommerce_loop['listtype'] ) ) {
1818
  $listtype = $woocommerce_loop['listtype'];
1819
+ }
 
1820
  $this->con_product_list_item_extra_tag($product, $listtype);
1821
  }
1822
  /**
2190
  return false;
2191
  }
2192
  $product_id = $product->get_id();
2193
+ /*$product_cat = '';
2194
  if ( is_product_category() ) {
2195
  global $wp_query;
2196
  $cat_obj = $wp_query->get_queried_object();
2197
  $product_cat = $cat_obj->name;
2198
  } else {
2199
  $product_cat = $this->con_get_product_category( $product_id );
2200
+ }*/
2201
+ $list_name = "";
2202
  if ( is_search() ) {
2203
  $list_name = __( 'Search Results', 'duracelltomi-google-tag-manager' );
2204
  } elseif ( '' !== $listtype ) {
readme.txt CHANGED
@@ -8,8 +8,8 @@ Author: Conversios
8
  Requires at least: 4.6
9
  Tested up to: 6.1.1
10
  Requires PHP: 5.6 or Higher
11
- Stable tag: 5.1.0
12
- Version: 5.1.0
13
  License: GPLv3
14
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
 
@@ -214,6 +214,10 @@ There could be duplicate tracking via manually implemented GA tracking snippet a
214
 
215
  == Changelog ==
216
 
 
 
 
 
217
  = 5.1.0 - 24/11/2022 =
218
  * The new release contains easy-to-implement updates to better adapt our Google Tag Manager capabilities, including the ability to deploy custom GTM features. For a hassle-free deployment of dynamic remarketing and conversion tags, we have also incorporated all pixels (Google ads, Facebook ads, Microsoft ads, Twitter ads, Pinterest ads, Snapchat ads, and Tiktok ads) option in onboarding.
219
  * We have added the how-to guides for pixel implementation.
8
  Requires at least: 4.6
9
  Tested up to: 6.1.1
10
  Requires PHP: 5.6 or Higher
11
+ Stable tag: 5.1.1
12
+ Version: 5.1.1
13
  License: GPLv3
14
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
 
214
 
215
  == Changelog ==
216
 
217
+ = 5.1.1 - 05/12/2022 =
218
+ * For a quicker and better user experience, we have improved the pixel settings in this release, giving you the option to add and update your Google ads conversion label.
219
+ * Minor bug fixes and improvements to the auto product sync feature are also included.
220
+
221
  = 5.1.0 - 24/11/2022 =
222
  * The new release contains easy-to-implement updates to better adapt our Google Tag Manager capabilities, including the ability to deploy custom GTM features. For a hassle-free deployment of dynamic remarketing and conversion tags, we have also incorporated all pixels (Google ads, Facebook ads, Microsoft ads, Twitter ads, Pinterest ads, Snapchat ads, and Tiktok ads) option in onboarding.
223
  * We have added the how-to guides for pixel implementation.