Advanced Shipment Tracking for WooCommerce - Version 2.4.4

Version Description

  • Fixed PHP Notice: Undefined index: DHL uk in plugins\woo-advanced-shipment-tracking\includes\class-wc-advanced-shipment-tracking-install.php on line 1560
  • Fixed - If Delivered Status is not enabled - do not change order status "Delivered" or to any other status (Pending right now)
  • Updated html class of add tracking provider lightbox in orders listing page
  • Updated - remove event grouping by status to display all events in trackship tracking page
  • Added - limit bulk action Get Shipment Status to maximum 100 orders at one time
  • Added description on select tracking page field
Download this release

Release Info

Developer zorem
Plugin Icon 128x128 Advanced Shipment Tracking for WooCommerce
Version 2.4.4
Comparing to
See all releases

Code changes from version 2.3.8 to 2.4.4

Files changed (36) hide show
  1. assets/css/admin.css +76 -3
  2. assets/css/front.css +20 -3
  3. assets/css/icons/invalid-user-key-v4.png +0 -0
  4. assets/js/admin.js +13 -0
  5. assets/js/customizer-scripts.js +11 -0
  6. assets/js/front.js +4 -4
  7. assets/js/shipping_row.js +14 -5
  8. assets/shipment-provider-img/dhl-ecommerce.png +0 -0
  9. assets/shipment-provider-img/dhl-express-uk.png +0 -0
  10. assets/shipment-provider-img/dhl-parcel-uk-asd.png +0 -0
  11. assets/shipment-provider-img/dhl-parcel-uk.png +0 -0
  12. assets/shipment-provider-img/gls-europe.png +0 -0
  13. assets/shipment-provider-img/gls-italy.png +0 -0
  14. assets/shipment-provider-img/{hermes.png → hermes-germany.png} +0 -0
  15. assets/shipment-provider-img/hermes-world.png +0 -0
  16. assets/shipment-provider-img/malaysia-post.png +0 -0
  17. assets/shipment-provider-img/postnl-international-3s.png +0 -0
  18. assets/shipment-provider-img/xpressbees.png +0 -0
  19. assets/shipment-provider-img/yanwen.png +0 -0
  20. assets/shipment-provider-img/yun-express-tracking.png +0 -0
  21. includes/api/v1/class-wc-advanced-shipment-tracking-rest-api-controller.php +42 -2
  22. includes/class-wc-advanced-shipment-tracking-admin.php +309 -73
  23. includes/class-wc-advanced-shipment-tracking-api-call.php +19 -8
  24. includes/class-wc-advanced-shipment-tracking-front.php +206 -137
  25. includes/class-wc-advanced-shipment-tracking-install.php +143 -6
  26. includes/class-wc-advanced-shipment-tracking.php +144 -61
  27. includes/customizer/class-wc-availableforpickup-email-customizer.php +1 -1
  28. includes/customizer/class-wc-email-customizer.php +48 -28
  29. includes/emails/class-shipment-delivered-email.php +2 -1
  30. includes/views/admin_options_bulk_upload.php +1 -1
  31. includes/views/admin_options_settings (Eran Shor's conflicted copy 2019-08-07).php +0 -34
  32. includes/views/admin_options_shipping_provider.php +2 -4
  33. readme.txt +62 -7
  34. templates/emails/tracking-info.php +6 -4
  35. templates/myaccount/view-order.php +1 -1
  36. woocommerce-advanced-shipment-tracking.php +10 -8
assets/css/admin.css CHANGED
@@ -303,6 +303,11 @@ input.tab_input_1:checked + label{
303
  .ast_admin_content .form-table th.titledesc {
304
  width: 50%;
305
  }
 
 
 
 
 
306
  .woocommerce.zorem_admin_layout table.form-table th.th_80 {
307
  width: 80%;
308
  }
@@ -762,6 +767,15 @@ span.email_status_span i.enable {
762
  margin-top: 4px;
763
  display: inline-block;
764
  }
 
 
 
 
 
 
 
 
 
765
  .wcast-shipment-status-icon .icon-delivered:before{
766
  content: ' ';
767
  background-image: url(icons/delivered-v4.png);
@@ -924,6 +938,15 @@ span.email_status_span i.enable {
924
  display: inline-block;
925
  vertical-align: middle;
926
  }
 
 
 
 
 
 
 
 
 
927
 
928
  .wcast-shipment-status-icon i {
929
  font-size: 25px;
@@ -1430,12 +1453,30 @@ a.active{
1430
  height: 100%;
1431
  text-align: center;
1432
  }
 
 
 
 
 
 
 
 
 
 
 
 
1433
  .popupwrapper:after {
1434
  content: '';
1435
  display: inline-block;
1436
  vertical-align: middle;
1437
  height: 100%;
1438
  }
 
 
 
 
 
 
1439
  .popuprow {
1440
  display: inline-block;
1441
  vertical-align: middle;
@@ -1450,6 +1491,20 @@ a.active{
1450
  max-height: 90%;
1451
  overflow-y: overlay;
1452
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1453
  .popupclose {
1454
  position: absolute;
1455
  width: 100%;
@@ -1458,17 +1513,17 @@ a.active{
1458
  top: 0;
1459
  left: 0;
1460
  }
1461
- .popupwrapper input[type=text]{
1462
  line-height: 24px;
1463
  color: #0d0d0d;
1464
  width: 90%;
1465
  margin-bottom: 10px;
1466
  /*border: 1px solid #ddd !important;*/
1467
  }
1468
- .popupwrapper input[type=text].image_path{
1469
  width: 68%;
1470
  }
1471
- .popupwrapper select,.popupwrapper .select2{
1472
  line-height: 24px;
1473
  color: #0d0d0d;
1474
  width: 90%;
@@ -1621,6 +1676,24 @@ p.tracking-preview-desc {
1621
  width: 80%;
1622
  margin: 1em auto;
1623
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1624
  @media screen and (min-width: 1850px) {
1625
  .provider{
1626
  padding:10px;
303
  .ast_admin_content .form-table th.titledesc {
304
  width: 50%;
305
  }
306
+ .woocommerce .ast_admin_content table.form-table th label .woocommerce-help-tip{
307
+ margin: -4px 0 0 5px;
308
+ position: relative;
309
+ font-size: 21px;
310
+ }
311
  .woocommerce.zorem_admin_layout table.form-table th.th_80 {
312
  width: 80%;
313
  }
767
  margin-top: 4px;
768
  display: inline-block;
769
  }
770
+ .wcast-shipment-status-icon .icon-invalid_user_key:before{
771
+ content: ' ';
772
+ background-image: url(icons/invalid-user-key-v4.png);
773
+ width: 20px;
774
+ height: 20px;
775
+ background-size: cover;
776
+ display: inline-block;
777
+ vertical-align: middle;
778
+ }
779
  .wcast-shipment-status-icon .icon-delivered:before{
780
  content: ' ';
781
  background-image: url(icons/delivered-v4.png);
938
  display: inline-block;
939
  vertical-align: middle;
940
  }
941
+ .ast-shipment-status .icon-invalid_user_key:before{
942
+ content: ' ';
943
+ background-image: url(icons/invalid-user-key-v4.png);
944
+ width: 20px;
945
+ height: 20px;
946
+ background-size: cover;
947
+ display: inline-block;
948
+ vertical-align: middle;
949
+ }
950
 
951
  .wcast-shipment-status-icon i {
952
  font-size: 25px;
1453
  height: 100%;
1454
  text-align: center;
1455
  }
1456
+
1457
+ .trackingpopup_wrapper {
1458
+ position: fixed;
1459
+ top: 0;
1460
+ left: 0;
1461
+ background: rgba(0, 0, 0, 0.4);
1462
+ z-index: 10;
1463
+ width: 100%;
1464
+ height: 100%;
1465
+ text-align: center;
1466
+ }
1467
+
1468
  .popupwrapper:after {
1469
  content: '';
1470
  display: inline-block;
1471
  vertical-align: middle;
1472
  height: 100%;
1473
  }
1474
+ .trackingpopup_wrapper:after {
1475
+ content: '';
1476
+ display: inline-block;
1477
+ vertical-align: middle;
1478
+ height: 100%;
1479
+ }
1480
  .popuprow {
1481
  display: inline-block;
1482
  vertical-align: middle;
1491
  max-height: 90%;
1492
  overflow-y: overlay;
1493
  }
1494
+ .trackingpopup_row {
1495
+ display: inline-block;
1496
+ vertical-align: middle;
1497
+ max-width: 300px;
1498
+ background: #f9f9f9;
1499
+ padding: 30px;
1500
+ position: relative;
1501
+ z-index: 10;
1502
+ border-radius: 2px;
1503
+ width: 97%;
1504
+ width: calc(100% - 5px);
1505
+ max-height: 90%;
1506
+ overflow-y: overlay;
1507
+ }
1508
  .popupclose {
1509
  position: absolute;
1510
  width: 100%;
1513
  top: 0;
1514
  left: 0;
1515
  }
1516
+ .popupwrapper input[type=text],.trackingpopup_wrapper input[type=text]{
1517
  line-height: 24px;
1518
  color: #0d0d0d;
1519
  width: 90%;
1520
  margin-bottom: 10px;
1521
  /*border: 1px solid #ddd !important;*/
1522
  }
1523
+ .popupwrapper input[type=text].image_path,.trackingpopup_wrapper input[type=text].image_path{
1524
  width: 68%;
1525
  }
1526
+ .popupwrapper select,.popupwrapper .select2,.trackingpopup_wrapper select,.trackingpopup_wrapper .select2{
1527
  line-height: 24px;
1528
  color: #0d0d0d;
1529
  width: 90%;
1676
  width: 80%;
1677
  margin: 1em auto;
1678
  }
1679
+
1680
+ /*** Dashboard Widget CSS ***/
1681
+ .ast-dashborad-widget.row{
1682
+ width: 100%;
1683
+ -js-display: flex;
1684
+ display: -ms-flexbox;
1685
+ display: flex;
1686
+ -ms-flex-flow: row wrap;
1687
+ flex-flow: row wrap;
1688
+ }
1689
+ .ast-dashborad-widget.row .large-6 {
1690
+ max-width: 47%;
1691
+ -ms-flex-preferred-size: 47%;
1692
+ flex-basis: 47%;
1693
+ position: relative;
1694
+ border: 1px dashed #ddd;
1695
+ padding: 5px;
1696
+ }
1697
  @media screen and (min-width: 1850px) {
1698
  .provider{
1699
  padding:10px;
assets/css/front.css CHANGED
@@ -19,7 +19,8 @@
19
  }
20
  .tracker-progress-bar-with-dots .progress {
21
  margin-bottom: 35px;
22
- height: 5px;
 
23
  }
24
  .tracker-progress-bar-with-dots .progress .progress-bar {
25
  box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.15)
@@ -38,7 +39,7 @@
38
  }
39
  .tracker-progress-bar-with-dots .state-3 {
40
  position: absolute;
41
- left: 100%
42
  }
43
  .tracker-progress-bar-with-dots .state-label {
44
  width: 75px;
@@ -361,6 +362,11 @@ table.tracking-table{
361
  .h4-heading{
362
  border-bottom: 1px solid #eee;
363
  }
 
 
 
 
 
364
  @media screen and (max-width: 767px) {
365
  .col.tracking-detail{
366
  padding: 20px 15px 0;
@@ -378,6 +384,11 @@ table.tracking-table{
378
  .status-section{
379
  max-width: 80%;
380
  }
 
 
 
 
 
381
  }
382
  @media screen and (max-width: 550px) {
383
  .mobile-section{
@@ -423,8 +434,9 @@ table.tracking-table{
423
  }
424
  .mobile-section .tracker-progress-bar.tracker-progress-bar-with-dots:before {
425
  content: '';
426
- height: 100%;
427
  position: absolute;
 
428
  left: 48px;
429
  width: 5px;
430
  background-color: #C1C1C1;
@@ -450,4 +462,9 @@ table.tracking-table{
450
  margin-top: 20px;
451
  padding-left: 20px;
452
  }
 
 
 
 
 
453
  }
19
  }
20
  .tracker-progress-bar-with-dots .progress {
21
  margin-bottom: 35px;
22
+ height: 5px;
23
+ margin-left: 15px;
24
  }
25
  .tracker-progress-bar-with-dots .progress .progress-bar {
26
  box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.15)
39
  }
40
  .tracker-progress-bar-with-dots .state-3 {
41
  position: absolute;
42
+ left: 95%
43
  }
44
  .tracker-progress-bar-with-dots .state-label {
45
  width: 75px;
362
  .h4-heading{
363
  border-bottom: 1px solid #eee;
364
  }
365
+ .tracker-progress-bar-with-dots .dot.past-state,.tracker-progress-bar-with-dots .dot.future-state{
366
+ background-size: 50px;
367
+ background-repeat: no-repeat;
368
+ background-position: center center;
369
+ }
370
  @media screen and (max-width: 767px) {
371
  .col.tracking-detail{
372
  padding: 20px 15px 0;
384
  .status-section{
385
  max-width: 80%;
386
  }
387
+ .tracker-progress-bar-with-dots .dot.past-state,.tracker-progress-bar-with-dots .dot.future-state{
388
+ background-size: 45px;
389
+ background-repeat: no-repeat;
390
+ background-position: center center;
391
+ }
392
  }
393
  @media screen and (max-width: 550px) {
394
  .mobile-section{
434
  }
435
  .mobile-section .tracker-progress-bar.tracker-progress-bar-with-dots:before {
436
  content: '';
437
+ height: 93%;
438
  position: absolute;
439
+ top: 10px;
440
  left: 48px;
441
  width: 5px;
442
  background-color: #C1C1C1;
462
  margin-top: 20px;
463
  padding-left: 20px;
464
  }
465
+ .tracker-progress-bar-with-dots .dot.past-state,.tracker-progress-bar-with-dots .dot.future-state{
466
+ background-size: 45px;
467
+ background-repeat: no-repeat;
468
+ background-position: center center;
469
+ }
470
  }
assets/css/icons/invalid-user-key-v4.png ADDED
Binary file
assets/js/admin.js CHANGED
@@ -319,6 +319,19 @@ jQuery(document).on("click", ".inline_tracking_delete", function(){
319
  }
320
  });
321
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  function showerror(element){
323
  element.css("border","1px solid red");
324
  }
319
  }
320
  });
321
 
322
+ jQuery(document).on("submit", ".post-type-shop_order #posts-filter", function(){
323
+ var form = jQuery('.post-type-shop_order #posts-filter');
324
+ var bulk_select = jQuery('#bulk-action-selector-top').val();
325
+
326
+ if(bulk_select == 'get_shipment_status'){
327
+ var checked_checkbox = jQuery(".type-shop_order .check-column input[type='checkbox']:checked");
328
+ if(checked_checkbox.length > 100){
329
+ alert(ast_admin_js.i18n.get_shipment_status_message);
330
+ return false;
331
+ }
332
+ }
333
+ });
334
+
335
  function showerror(element){
336
  element.css("border","1px solid red");
337
  }
assets/js/customizer-scripts.js CHANGED
@@ -18,6 +18,10 @@ jQuery(document).ready(function() {
18
  if(jQuery("#_customize-input-show_track_label").prop("checked") != true){
19
  jQuery('#customize-control-track_header_text').hide();
20
  }
 
 
 
 
21
 
22
  });
23
  jQuery(document).on("change", "#_customize-input-show_track_label", function(){
@@ -26,6 +30,13 @@ jQuery(document).on("change", "#_customize-input-show_track_label", function(){
26
  } else{
27
  jQuery('#customize-control-track_header_text').hide();
28
  }
 
 
 
 
 
 
 
29
  });
30
  jQuery(document).on("change", "#customize-control-woocommerce_customer_delivered_order_settings-enabled input", function(){
31
  if(jQuery(this).prop("checked") == true){
18
  if(jQuery("#_customize-input-show_track_label").prop("checked") != true){
19
  jQuery('#customize-control-track_header_text').hide();
20
  }
21
+
22
+ if(jQuery("#_customize-input-wcast_enable_delivered_ga_tracking").prop("checked") != true){
23
+ jQuery('#customize-control-wcast_delivered_analytics_link').hide();
24
+ }
25
 
26
  });
27
  jQuery(document).on("change", "#_customize-input-show_track_label", function(){
30
  } else{
31
  jQuery('#customize-control-track_header_text').hide();
32
  }
33
+ });
34
+ jQuery(document).on("change", "#_customize-input-wcast_enable_delivered_ga_tracking", function(){
35
+ if(jQuery(this).prop("checked") == true){
36
+ jQuery('#customize-control-wcast_delivered_analytics_link').show();
37
+ } else{
38
+ jQuery('#customize-control-wcast_delivered_analytics_link').hide();
39
+ }
40
  });
41
  jQuery(document).on("change", "#customize-control-woocommerce_customer_delivered_order_settings-enabled input", function(){
42
  if(jQuery(this).prop("checked") == true){
assets/js/front.js CHANGED
@@ -46,11 +46,11 @@ jQuery(document).on("click", ".back_to_tracking_form", function(){
46
  });
47
  jQuery(document).on("click", ".view_table_rows", function(){
48
  jQuery(this).hide();
49
- jQuery('.hide_table_rows').show();
50
- jQuery('table.tracking-table tr:nth-child(n+3)').show();
51
  });
52
  jQuery(document).on("click", ".hide_table_rows", function(){
53
  jQuery(this).hide();
54
- jQuery('.view_table_rows').show();
55
- jQuery('table.tracking-table tr:nth-child(n+3)').hide();
56
  });
46
  });
47
  jQuery(document).on("click", ".view_table_rows", function(){
48
  jQuery(this).hide();
49
+ jQuery(this).closest('.shipment_progress_div').find('.hide_table_rows').show();
50
+ jQuery(this).closest('.shipment_progress_div').find('table.tracking-table tr:nth-child(n+3)').show();
51
  });
52
  jQuery(document).on("click", ".hide_table_rows", function(){
53
  jQuery(this).hide();
54
+ jQuery(this).closest('.shipment_progress_div').find('.view_table_rows').show();
55
+ jQuery(this).closest('.shipment_progress_div').find('table.tracking-table tr:nth-child(n+3)').hide();
56
  });
assets/js/shipping_row.js CHANGED
@@ -538,14 +538,14 @@ jQuery(document).on("click", ".close_synch_popup", function(){
538
  error = true;
539
  } else{
540
  hideerror(thumb_url);
541
- }*/
542
 
543
  if( tracking_url.val() === '' ){
544
  showerror(tracking_url);
545
  error = true;
546
  } else{
547
  hideerror(tracking_url);
548
- }
549
 
550
 
551
  if(error == true){
@@ -672,12 +672,12 @@ jQuery(document).on("submit", "#edit_provider_form", function(){
672
  hideerror(shipping_country);
673
  }
674
 
675
- if( tracking_url.val() === '' ){
676
  showerror(tracking_url);
677
  error = true;
678
  } else{
679
  hideerror(tracking_url);
680
- }
681
 
682
 
683
  if(error == true){
@@ -895,4 +895,13 @@ function showerror(element){
895
  }
896
  function hideerror(element){
897
  element.css("border","1px solid #ddd");
898
- }
 
 
 
 
 
 
 
 
 
538
  error = true;
539
  } else{
540
  hideerror(thumb_url);
541
+ }
542
 
543
  if( tracking_url.val() === '' ){
544
  showerror(tracking_url);
545
  error = true;
546
  } else{
547
  hideerror(tracking_url);
548
+ }*/
549
 
550
 
551
  if(error == true){
672
  hideerror(shipping_country);
673
  }
674
 
675
+ /*if( tracking_url.val() === '' ){
676
  showerror(tracking_url);
677
  error = true;
678
  } else{
679
  hideerror(tracking_url);
680
+ }*/
681
 
682
 
683
  if(error == true){
895
  }
896
  function hideerror(element){
897
  element.css("border","1px solid #ddd");
898
+ }
899
+ jQuery(document).on("change", "#wc_ast_status_shipped", function(){
900
+ if(jQuery(this).prop("checked") == true){
901
+ jQuery("[for=show_in_completed] .multiple_label").text('Shipped');
902
+ jQuery("label .shipped_label").text('shipped');
903
+ } else{
904
+ jQuery("[for=show_in_completed] .multiple_label").text('Completed');
905
+ jQuery("label .shipped_label").text('completed');
906
+ }
907
+ });
assets/shipment-provider-img/dhl-ecommerce.png ADDED
Binary file
assets/shipment-provider-img/dhl-express-uk.png ADDED
Binary file
assets/shipment-provider-img/dhl-parcel-uk-asd.png ADDED
Binary file
assets/shipment-provider-img/dhl-parcel-uk.png ADDED
Binary file
assets/shipment-provider-img/gls-europe.png ADDED
Binary file
assets/shipment-provider-img/gls-italy.png ADDED
Binary file
assets/shipment-provider-img/{hermes.png → hermes-germany.png} RENAMED
File without changes
assets/shipment-provider-img/hermes-world.png ADDED
Binary file
assets/shipment-provider-img/malaysia-post.png ADDED
Binary file
assets/shipment-provider-img/postnl-international-3s.png ADDED
Binary file
assets/shipment-provider-img/xpressbees.png ADDED
Binary file
assets/shipment-provider-img/yanwen.png ADDED
Binary file
assets/shipment-provider-img/yun-express-tracking.png ADDED
Binary file
includes/api/v1/class-wc-advanced-shipment-tracking-rest-api-controller.php CHANGED
@@ -122,7 +122,7 @@ class WC_Advanced_Shipment_Tracking_V1_REST_API_Controller extends WC_REST_Contr
122
  ) );
123
 
124
  //check_wcast_installed
125
- register_rest_route( $this->namespace, '/check_wcast_installed', array(
126
  array(
127
  'methods' => 'POST',
128
  'callback' => array( $this, 'check_wcast_installed' ),
@@ -136,6 +136,15 @@ class WC_Advanced_Shipment_Tracking_V1_REST_API_Controller extends WC_REST_Contr
136
  * check_wcast_installed
137
  */
138
  public function check_wcast_installed( $request ){
 
 
 
 
 
 
 
 
 
139
  $data = array(
140
  'status' => 'installed'
141
  );
@@ -182,7 +191,10 @@ class WC_Advanced_Shipment_Tracking_V1_REST_API_Controller extends WC_REST_Contr
182
  update_post_meta( $order_id, "shipment_status", $shipment_status);
183
  }
184
  $st->check_tracking_delivered( $order_id );
185
- exit;
 
 
 
186
  }
187
 
188
  /**
@@ -418,6 +430,34 @@ class WC_Advanced_Shipment_Tracking_V1_REST_API_Controller extends WC_REST_Contr
418
  wp_reset_postdata();
419
  }
420
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  if ( ! $this->is_valid_order_id( $order_id ) ) {
422
  return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce-shipment-tracking' ), array( 'status' => 404 ) );
423
  }
122
  ) );
123
 
124
  //check_wcast_installed
125
+ register_rest_route( $this->namespace, '/check_wcast_installed', array(
126
  array(
127
  'methods' => 'POST',
128
  'callback' => array( $this, 'check_wcast_installed' ),
136
  * check_wcast_installed
137
  */
138
  public function check_wcast_installed( $request ){
139
+ $wc_ast_api_key = get_option('wc_ast_api_key');
140
+ $wc_ast_api_enabled = get_option('wc_ast_api_enabled');
141
+ if(empty($wc_ast_api_key)){
142
+ update_option('wc_ast_api_key',$request['user_key']);
143
+ }
144
+ if($wc_ast_api_enabled == ''){
145
+ update_option('wc_ast_api_enabled',1);
146
+ }
147
+
148
  $data = array(
149
  'status' => 'installed'
150
  );
191
  update_post_meta( $order_id, "shipment_status", $shipment_status);
192
  }
193
  $st->check_tracking_delivered( $order_id );
194
+ $data = array(
195
+ 'status' => 'success'
196
+ );
197
+ return rest_ensure_response( $data );
198
  }
199
 
200
  /**
430
  wp_reset_postdata();
431
  }
432
  }
433
+
434
+ if ( is_plugin_active( 'wp-lister/wp-lister.php' ) || is_plugin_active( 'wp-lister-for-ebay/wp-lister.php' )) {
435
+ $args = array(
436
+ 'post_type' => 'shop_order',
437
+ 'posts_per_page' => '1',
438
+ 'meta_query' => array(
439
+ 'relation' => 'AND',
440
+ array(
441
+ 'key' => '_ebay_order_id',
442
+ 'value' => $order_id
443
+ ),
444
+ ),
445
+ 'post_status' => array('wc-pending', 'wc-processing', 'wc-on-hold', 'wc-completed', 'wc-delivered', 'wc-cancelled', 'wc-refunded', 'wc-failed','wc-bit-payment') ,
446
+ );
447
+ $posts = get_posts( $args );
448
+ $my_query = new WP_Query( $args );
449
+
450
+ if( $my_query->have_posts() ) {
451
+ while( $my_query->have_posts()) {
452
+ $my_query->the_post();
453
+ if(get_the_ID()){
454
+ $order_id = get_the_ID();
455
+ }
456
+ } // end while
457
+ } // end if
458
+ wp_reset_postdata();
459
+ }
460
+
461
  if ( ! $this->is_valid_order_id( $order_id ) ) {
462
  return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce-shipment-tracking' ), array( 'status' => 404 ) );
463
  }
includes/class-wc-advanced-shipment-tracking-admin.php CHANGED
@@ -113,6 +113,12 @@ class WC_Advanced_Shipment_Tracking_Admin {
113
  // add 'get_shipment_status' order meta box order action
114
  add_action( 'woocommerce_order_actions', array( $this, 'add_order_meta_box_get_shipment_status_actions' ) );
115
  add_action( 'woocommerce_order_action_get_shipment_status_edit_order', array( $this, 'process_order_meta_box_actions_get_shipment_status' ) );
 
 
 
 
 
 
116
  }
117
 
118
  // trigger when order status changed to shipped or completed
@@ -135,12 +141,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
135
  add_filter("trackship_status_filter", array($this, "trackship_status_filter_func"), 10 , 1);
136
 
137
  // filter for shipment status icon
138
- add_filter("trackship_status_icon_filter", array($this, "trackship_status_icon_filter_func"), 10 , 2);
139
-
140
- //added wrong tracking filter
141
- add_filter( 'views_edit-shop_order', array( $this, 'filter_views_edit_shop_order'), 10, 1 );
142
- //change query for invalid tracking
143
- add_filter( 'parse_query', array( $this, 'zorem_woocommerce_admin_order_filter_query') );
144
 
145
  add_action( 'wcast_retry_trackship_apicall', array( $this, 'wcast_retry_trackship_apicall_func' ) );
146
 
@@ -168,7 +169,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
168
 
169
  add_action( 'wp_ajax_update_shipment_status', array( $this, 'update_shipment_status_fun') );
170
 
171
- add_action( 'wp_ajax_sync_providers', array( $this, 'sync_providers_fun') );
172
  }
173
 
174
  /*
@@ -569,10 +570,12 @@ class WC_Advanced_Shipment_Tracking_Admin {
569
  $has_est_delivery = false;
570
  $status = $shipment_status[$key]['status'];
571
  $status_date = $shipment_status[$key]['status_date'];
572
- $est_delivery_date = $shipment_status[$key]['est_delivery_date'];
 
 
573
  if( $status != 'delivered' && $status != 'return_to_sender' && !empty($est_delivery_date) ){
574
  $has_est_delivery = true;
575
- }
576
  ?>
577
  <li id="tracking-item-<?php echo $tracking_item['tracking_id'];?>" class="tracking-item-<?php echo $tracking_item['tracking_id'];?>">
578
  <div class="wcast-shipment-status-icon">
@@ -612,6 +615,12 @@ class WC_Advanced_Shipment_Tracking_Admin {
612
 
613
  wp_enqueue_script( 'woocommerce-advanced-shipment-tracking-js', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/admin.js', array( 'jquery' ), wc_advanced_shipment_tracking()->version);
614
 
 
 
 
 
 
 
615
  if(!isset($_GET['page'])) {
616
  return;
617
  }
@@ -715,7 +724,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
715
 
716
  }
717
  }
718
- wp_enqueue_script( 'shipment_tracking_table_rows' );
719
  ?>
720
  <h1 class="plugin-title"><?php _e('Advanced Shipment Tracking', 'woo-advanced-shipment-tracking'); ?></h1>
721
  <div class="wrap woocommerce zorem_admin_layout">
@@ -775,7 +784,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
775
  <th scope="row" class="titledesc" >
776
  <label for=""><?php echo $array['title']?><?php if(isset($array['title_link'])){ echo $array['title_link']; } ?>
777
  <?php if( isset($array['tooltip']) ){?>
778
- <span class="woocommerce-help-tip tipTip" title="<?php echo $array['tooltip']?>"></span>
779
  <?php } ?>
780
  </label>
781
  </th>
@@ -796,10 +805,18 @@ class WC_Advanced_Shipment_Tracking_Admin {
796
  $checked = '';
797
  }
798
  }
 
 
 
 
 
 
 
799
  ?>
800
  <span class="mdl-list__item-secondary-action">
801
  <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="<?php echo $id?>">
802
- <input type="checkbox" id="<?php echo $id?>" name="<?php echo $id?>" class="mdl-switch__input" <?php echo $checked ?> value="1"/>
 
803
  </label>
804
  </span>
805
  <?php } elseif( $array['type'] == 'multiple_checkbox' ){ ?>
@@ -907,6 +924,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
907
  function get_trackship_general_data(){
908
  $wc_ast_api_key = get_option('wc_ast_api_key');
909
  $trackers_balance = get_option( 'trackers_balance' );
 
910
  if($wc_ast_api_key){
911
  $connected = true;
912
  $show_trackship_field = true;
@@ -916,6 +934,11 @@ class WC_Advanced_Shipment_Tracking_Admin {
916
  $show_trackship_field = false;
917
  $show_trackship_description = true;
918
  }
 
 
 
 
 
919
  $page_list = wp_list_pluck( get_pages(), 'post_title', 'ID' );
920
 
921
  $form_data = array(
@@ -937,6 +960,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
937
  'title' => __( 'Set order status Delivered when order is delivered', 'woo-advanced-shipment-tracking' ),
938
  'show' => $show_trackship_field,
939
  'class' => '',
 
940
  ),
941
  'wc_ast_trackship_description' => array(
942
  'type' => 'desc',
@@ -963,15 +987,24 @@ class WC_Advanced_Shipment_Tracking_Admin {
963
  $connected = false;
964
  $show_trackship_field = false;
965
  $show_trackship_description = true;
966
- }
 
967
  $page_list = wp_list_pluck( get_pages(), 'post_title', 'ID' );
968
-
 
 
 
 
 
 
 
969
  $form_data = array(
970
  'wc_ast_trackship_page_id' => array(
971
  'type' => 'dropdown',
972
  'title' => __( 'Select Tracking Page', 'woo-advanced-shipment-tracking' ),
973
  'options' => $page_list,
974
  'show' => $show_trackship_field,
 
975
  'class' => '',
976
  ),
977
  'wc_ast_remove_trackship_branding' => array(
@@ -1054,6 +1087,18 @@ class WC_Advanced_Shipment_Tracking_Admin {
1054
  } else{
1055
  $show_invoice_field = false;
1056
  }
 
 
 
 
 
 
 
 
 
 
 
 
1057
  $form_data = array(
1058
  'wc_ast_status_shipped' => array(
1059
  'type' => 'checkbox',
@@ -1061,6 +1106,13 @@ class WC_Advanced_Shipment_Tracking_Admin {
1061
  'show' => true,
1062
  'class' => '',
1063
  ),
 
 
 
 
 
 
 
1064
  'wc_ast_unclude_tracking_info' => array(
1065
  'type' => 'multiple_checkbox',
1066
  'title' => __( 'On which customer order status email to include tracking info?', 'woo-advanced-shipment-tracking' ),'options' => array(
@@ -1069,7 +1121,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
1069
  "show_in_refunded" =>__( 'Refunded', 'woo-advanced-shipment-tracking' ),
1070
  "show_in_processing" =>__( 'Processing', 'woo-advanced-shipment-tracking' ),
1071
  "show_in_failed" =>__( 'Failed', 'woo-advanced-shipment-tracking' ),
1072
- "show_in_completed" =>__( 'Completed', 'woo-advanced-shipment-tracking' ),
1073
  ),
1074
  'show' => true,
1075
  'class' => '',
@@ -1270,6 +1322,33 @@ class WC_Advanced_Shipment_Tracking_Admin {
1270
  }
1271
  }
1272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1273
  $tracking_provider = $_POST['tracking_provider'];
1274
  $tracking_number = $_POST['tracking_number'];
1275
  $date_shipped = str_replace("/","-",$_POST['date_shipped']);
@@ -1277,7 +1356,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
1277
  $date_shipped = date("d-m-Y");
1278
  }
1279
  $replace_tracking_info = $_POST['replace_tracking_info'];
1280
- // echo '<pre>';print_r($_POST['trackings']);echo '</pre>';
1281
  global $wpdb;
1282
  $woo_shippment_table_name = $this->table;
1283
  $shippment_provider = $wpdb->get_var( "SELECT COUNT(*) FROM $woo_shippment_table_name WHERE provider_name = '".$tracking_provider."'" );
@@ -1303,8 +1382,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
1303
 
1304
  if ( count( $tracking_items ) > 0 ) {
1305
  foreach ( $tracking_items as $key => $item ) {
1306
- $tracking_number = $item['tracking_number'];
1307
-
1308
  if(in_array($tracking_number, array_column($_POST['trackings'], 'tracking_number'))) {
1309
 
1310
  } else{
@@ -1324,7 +1402,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
1324
  'status_shipped' => wc_clean( $_POST['status_shipped'] ),
1325
  );
1326
  $order = wc_get_order($order_id);
1327
- //echo '<pre>';print_r($order);echo '</pre>';exit;
1328
  if ( $order === false ) {
1329
  echo '<li class="error">Failed - Invalid Order Id - '.$_POST['order_id'].'</li>';exit;
1330
  } else{
@@ -1373,7 +1451,13 @@ class WC_Advanced_Shipment_Tracking_Admin {
1373
  return $redirect_to;
1374
 
1375
  $processed_ids = array();
1376
-
 
 
 
 
 
 
1377
  foreach ( $post_ids as $post_id ) {
1378
 
1379
  $this->trigger_woocommerce_order_status_completed( $post_id );
@@ -1459,6 +1543,10 @@ class WC_Advanced_Shipment_Tracking_Admin {
1459
  case "carrier_unsupported":
1460
  $status = __( 'Carrier unsupported', 'woo-advanced-shipment-tracking' );
1461
  break;
 
 
 
 
1462
  }
1463
  return $status;
1464
  }
@@ -1498,55 +1586,16 @@ class WC_Advanced_Shipment_Tracking_Admin {
1498
  case "INVALID_TRACKING_NUM":
1499
  $html = '<i class="fa fa-question-circle icon-'.$status.'" aria-hidden="true"></i>';
1500
  break;
 
 
 
1501
  default:
1502
  $html = '<i class="fa fa-question-circle icon-'.$status.'" aria-hidden="true"></i>';
1503
  break;
1504
 
1505
  }
1506
  return $html;
1507
- }
1508
-
1509
- /*
1510
- * added wrong tracking filter
1511
- */
1512
- function filter_views_edit_shop_order( $array ) {
1513
- global $wpdb;
1514
- $sql = "SELECT count(DISTINCT pm.post_id)
1515
- FROM $wpdb->postmeta pm
1516
- JOIN $wpdb->posts p ON (p.ID = pm.post_id)
1517
- WHERE pm.meta_key = 'shipment_status' AND pm.meta_value like '%INVALID_TRACKING_NUM%' AND p.post_type = 'shop_order' ";
1518
- $count = $wpdb->get_var($sql);
1519
-
1520
- $query = array(
1521
- 'post_type' => 'shop_order',
1522
- );
1523
- $result = new WP_Query($query);
1524
-
1525
-
1526
- $class = ( isset( $_REQUEST['wrong_tracking'] ) && $_REQUEST['wrong_tracking'] == 'yes' ) ? 'current' : '';
1527
- $url = "edit.php?post_type=shop_order";
1528
- $query_string = add_query_arg( 'wrong_tracking', urlencode('yes'), $url );
1529
- $array['wrong_tracking'] = '<a href="' . $query_string . '" class="' . $class . '">' . __('Wrong Tracking ('.$count.')', 'wpla') . '</a>';
1530
- return $array;
1531
- }
1532
-
1533
- /*
1534
- * change query for invalid tracking nunmber
1535
- */
1536
- function zorem_woocommerce_admin_order_filter_query( $query ) {
1537
- global $typenow, $wp_query, $wpdb;
1538
-
1539
- if ( $typenow == 'shop_order' ) {
1540
-
1541
- if ( ! empty( $_GET['wrong_tracking'] ) ) {
1542
-
1543
- $query->set('meta_key', 'shipment_status');
1544
- $query->set('meta_value', 'INVALID_TRACKING_NUM' );
1545
- $query->set('meta_compare', 'LIKE' );
1546
-
1547
- }
1548
- }
1549
- }
1550
 
1551
  /*
1552
  * retry trackship api call
@@ -1898,15 +1947,10 @@ class WC_Advanced_Shipment_Tracking_Admin {
1898
  }
1899
 
1900
  public function sync_providers_fun(){
1901
- global $wpdb;
1902
- $wc_ast_api_key = get_option('wc_ast_api_key');
1903
- $url = 'https://trackship.info/wp-json/WCAST/v1/Provider';
1904
- $arg = array(
1905
- 'body' => array(
1906
- 'user_key' => $wc_ast_api_key
1907
- ),
1908
- );
1909
- $resp = wp_remote_get( $url, $arg );
1910
  $providers = json_decode($resp['body'],true);
1911
 
1912
  $default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table WHERE shipping_default = 1" );
@@ -1952,6 +1996,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
1952
  }
1953
  } else{
1954
  $img_url = $provider['img_url'];
 
1955
  $img_slug = sanitize_title($provider_name);
1956
  $img = wc_advanced_shipment_tracking()->get_plugin_path().'/assets/shipment-provider-img/'.$img_slug.'.png';
1957
 
@@ -1981,7 +2026,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
1981
  }
1982
  }
1983
  foreach($default_shippment_providers as $db_provider){
1984
- if(!is_array($providers_name[$db_provider->provider_name])){
1985
  $where = array(
1986
  'provider_name' => $db_provider->provider_name,
1987
  'shipping_default' => 1
@@ -2050,4 +2095,195 @@ class WC_Advanced_Shipment_Tracking_Admin {
2050
  <a class="view_synch_details" id="view_deleted_details" href="javaScript:void(0);" style="display: block;"><?php _e( 'view details', 'woo-advanced-shipment-tracking'); ?></a>
2051
  <a class="view_synch_details" id="hide_deleted_details" href="javaScript:void(0);" style="display: none;"><?php _e( 'hide details', 'woo-advanced-shipment-tracking'); ?></a>
2052
  <?php }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2053
  }
113
  // add 'get_shipment_status' order meta box order action
114
  add_action( 'woocommerce_order_actions', array( $this, 'add_order_meta_box_get_shipment_status_actions' ) );
115
  add_action( 'woocommerce_order_action_get_shipment_status_edit_order', array( $this, 'process_order_meta_box_actions_get_shipment_status' ) );
116
+
117
+ // add bulk order filter for exported / non-exported orders
118
+ add_action( 'restrict_manage_posts', array( $this, 'filter_orders_by_shipment_status') , 20 );
119
+ add_filter( 'request', array( $this, 'filter_orders_by_shipment_status_query' ) );
120
+
121
+ //add_action( 'wp_dashboard_setup', array( $this, 'ast_add_dashboard_widgets') );
122
  }
123
 
124
  // trigger when order status changed to shipped or completed
141
  add_filter("trackship_status_filter", array($this, "trackship_status_filter_func"), 10 , 1);
142
 
143
  // filter for shipment status icon
144
+ add_filter("trackship_status_icon_filter", array($this, "trackship_status_icon_filter_func"), 10 , 2);
 
 
 
 
 
145
 
146
  add_action( 'wcast_retry_trackship_apicall', array( $this, 'wcast_retry_trackship_apicall_func' ) );
147
 
169
 
170
  add_action( 'wp_ajax_update_shipment_status', array( $this, 'update_shipment_status_fun') );
171
 
172
+ add_action( 'wp_ajax_sync_providers', array( $this, 'sync_providers_fun') );
173
  }
174
 
175
  /*
570
  $has_est_delivery = false;
571
  $status = $shipment_status[$key]['status'];
572
  $status_date = $shipment_status[$key]['status_date'];
573
+ if(isset($shipment_status[$key]['est_delivery_date'])){
574
+ $est_delivery_date = $shipment_status[$key]['est_delivery_date'];
575
+ }
576
  if( $status != 'delivered' && $status != 'return_to_sender' && !empty($est_delivery_date) ){
577
  $has_est_delivery = true;
578
+ }
579
  ?>
580
  <li id="tracking-item-<?php echo $tracking_item['tracking_id'];?>" class="tracking-item-<?php echo $tracking_item['tracking_id'];?>">
581
  <div class="wcast-shipment-status-icon">
615
 
616
  wp_enqueue_script( 'woocommerce-advanced-shipment-tracking-js', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/admin.js', array( 'jquery' ), wc_advanced_shipment_tracking()->version);
617
 
618
+ wp_localize_script( 'woocommerce-advanced-shipment-tracking-js', 'ast_admin_js', array(
619
+ 'i18n' => array(
620
+ 'get_shipment_status_message' => __( 'Get Shipment Status is limited to 100 orders at a time, please select up to 100 orders.', 'woo-advanced-shipment-tracking' ),
621
+ ),
622
+ ) );
623
+
624
  if(!isset($_GET['page'])) {
625
  return;
626
  }
724
 
725
  }
726
  }
727
+ wp_enqueue_script( 'shipment_tracking_table_rows' );
728
  ?>
729
  <h1 class="plugin-title"><?php _e('Advanced Shipment Tracking', 'woo-advanced-shipment-tracking'); ?></h1>
730
  <div class="wrap woocommerce zorem_admin_layout">
784
  <th scope="row" class="titledesc" >
785
  <label for=""><?php echo $array['title']?><?php if(isset($array['title_link'])){ echo $array['title_link']; } ?>
786
  <?php if( isset($array['tooltip']) ){?>
787
+ <span class="woocommerce-help-tip tipTip" title1="<?php echo $array['tooltip']?>"></span>
788
  <?php } ?>
789
  </label>
790
  </th>
805
  $checked = '';
806
  }
807
  }
808
+
809
+ if($array['disabled'] == true){
810
+ $disabled = 'disabled';
811
+ $checked = '';
812
+ } else{
813
+ $disabled = '';
814
+ }
815
  ?>
816
  <span class="mdl-list__item-secondary-action">
817
  <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="<?php echo $id?>">
818
+ <input type="hidden" name="<?php echo $id?>" value="0"/>
819
+ <input type="checkbox" id="<?php echo $id?>" name="<?php echo $id?>" class="mdl-switch__input" <?php echo $checked ?> value="1" <?php echo $disabled; ?>/>
820
  </label>
821
  </span>
822
  <?php } elseif( $array['type'] == 'multiple_checkbox' ){ ?>
924
  function get_trackship_general_data(){
925
  $wc_ast_api_key = get_option('wc_ast_api_key');
926
  $trackers_balance = get_option( 'trackers_balance' );
927
+ $wc_ast_status_delivered = get_option( 'wc_ast_status_delivered' );
928
  if($wc_ast_api_key){
929
  $connected = true;
930
  $show_trackship_field = true;
934
  $show_trackship_field = false;
935
  $show_trackship_description = true;
936
  }
937
+ if($wc_ast_status_delivered){
938
+ $disabled_change_to_delivered = false;
939
+ } else{
940
+ $disabled_change_to_delivered = true;
941
+ }
942
  $page_list = wp_list_pluck( get_pages(), 'post_title', 'ID' );
943
 
944
  $form_data = array(
960
  'title' => __( 'Set order status Delivered when order is delivered', 'woo-advanced-shipment-tracking' ),
961
  'show' => $show_trackship_field,
962
  'class' => '',
963
+ 'disabled' => $disabled_change_to_delivered,
964
  ),
965
  'wc_ast_trackship_description' => array(
966
  'type' => 'desc',
987
  $connected = false;
988
  $show_trackship_field = false;
989
  $show_trackship_description = true;
990
+ }
991
+
992
  $page_list = wp_list_pluck( get_pages(), 'post_title', 'ID' );
993
+ $wc_ast_trackship_page_id = get_option('wc_ast_trackship_page_id');
994
+ $post = get_post($wc_ast_trackship_page_id);
995
+ $slug = $post->post_name;
996
+
997
+ if($slug != 'ts-shipment-tracking'){
998
+ $page_desc = __( 'You must add the shortcode [wcast-track-order] to the "page name" in order for the tracking page to work.', 'woo-advanced-shipment-tracking' );
999
+ }
1000
+
1001
  $form_data = array(
1002
  'wc_ast_trackship_page_id' => array(
1003
  'type' => 'dropdown',
1004
  'title' => __( 'Select Tracking Page', 'woo-advanced-shipment-tracking' ),
1005
  'options' => $page_list,
1006
  'show' => $show_trackship_field,
1007
+ 'desc' => $page_desc,
1008
  'class' => '',
1009
  ),
1010
  'wc_ast_remove_trackship_branding' => array(
1087
  } else{
1088
  $show_invoice_field = false;
1089
  }
1090
+
1091
+ $wc_ast_status_shipped = get_option('wc_ast_status_shipped');
1092
+ if($wc_ast_status_shipped == 1){
1093
+ $completed_order_label = __( 'Shipped', 'woo-advanced-shipment-tracking' );
1094
+ $mark_as_shipped_label = __( 'Default "mark as <span class="shipped_label">shipped</span>" checkbox state', 'woo-advanced-shipment-tracking' );
1095
+ $mark_as_shipped_tooltip = __( "This means that the 'mark as <span class='shipped_label'>shipped</span>' will be selected by default when adding tracking info to orders.", 'woo-advanced-shipment-tracking' );
1096
+ } else{
1097
+ $completed_order_label = __( 'Completed', 'woo-advanced-shipment-tracking' );
1098
+ $mark_as_shipped_label = __( 'Default "mark as <span class="shipped_label">completed</span>" checkbox state', 'woo-advanced-shipment-tracking' );
1099
+ $mark_as_shipped_tooltip = __( "This means that the 'mark as <span class='shipped_label'>completed</span>' will be selected by default when adding tracking info to orders.", 'woo-advanced-shipment-tracking' );
1100
+ }
1101
+
1102
  $form_data = array(
1103
  'wc_ast_status_shipped' => array(
1104
  'type' => 'checkbox',
1106
  'show' => true,
1107
  'class' => '',
1108
  ),
1109
+ 'wc_ast_default_mark_shipped' => array(
1110
+ 'type' => 'checkbox',
1111
+ 'title' => $mark_as_shipped_label,
1112
+ 'tooltip' => $mark_as_shipped_tooltip,
1113
+ 'show' => true,
1114
+ 'class' => '',
1115
+ ),
1116
  'wc_ast_unclude_tracking_info' => array(
1117
  'type' => 'multiple_checkbox',
1118
  'title' => __( 'On which customer order status email to include tracking info?', 'woo-advanced-shipment-tracking' ),'options' => array(
1121
  "show_in_refunded" =>__( 'Refunded', 'woo-advanced-shipment-tracking' ),
1122
  "show_in_processing" =>__( 'Processing', 'woo-advanced-shipment-tracking' ),
1123
  "show_in_failed" =>__( 'Failed', 'woo-advanced-shipment-tracking' ),
1124
+ "show_in_completed" =>__( $completed_order_label, 'woo-advanced-shipment-tracking' ),
1125
  ),
1126
  'show' => true,
1127
  'class' => '',
1322
  }
1323
  }
1324
 
1325
+ if ( is_plugin_active( 'wp-lister/wp-lister.php' ) || is_plugin_active( 'wp-lister-for-ebay/wp-lister.php' )) {
1326
+ $args = array(
1327
+ 'post_type' => 'shop_order',
1328
+ 'posts_per_page' => '1',
1329
+ 'meta_query' => array(
1330
+ 'relation' => 'AND',
1331
+ array(
1332
+ 'key' => '_ebay_order_id',
1333
+ 'value' => $order_id
1334
+ ),
1335
+ ),
1336
+ 'post_status' => array('wc-pending', 'wc-processing', 'wc-on-hold', 'wc-completed', 'wc-delivered', 'wc-cancelled', 'wc-refunded', 'wc-failed','wc-bit-payment') ,
1337
+ );
1338
+ $posts = get_posts( $args );
1339
+ $my_query = new WP_Query( $args );
1340
+
1341
+ if( $my_query->have_posts() ) {
1342
+ while( $my_query->have_posts()) {
1343
+ $my_query->the_post();
1344
+ if(get_the_ID()){
1345
+ $order_id = get_the_ID();
1346
+ }
1347
+ } // end while
1348
+ } // end if
1349
+ wp_reset_postdata();
1350
+ }
1351
+
1352
  $tracking_provider = $_POST['tracking_provider'];
1353
  $tracking_number = $_POST['tracking_number'];
1354
  $date_shipped = str_replace("/","-",$_POST['date_shipped']);
1356
  $date_shipped = date("d-m-Y");
1357
  }
1358
  $replace_tracking_info = $_POST['replace_tracking_info'];
1359
+
1360
  global $wpdb;
1361
  $woo_shippment_table_name = $this->table;
1362
  $shippment_provider = $wpdb->get_var( "SELECT COUNT(*) FROM $woo_shippment_table_name WHERE provider_name = '".$tracking_provider."'" );
1382
 
1383
  if ( count( $tracking_items ) > 0 ) {
1384
  foreach ( $tracking_items as $key => $item ) {
1385
+ $tracking_number = $item['tracking_number'];
 
1386
  if(in_array($tracking_number, array_column($_POST['trackings'], 'tracking_number'))) {
1387
 
1388
  } else{
1402
  'status_shipped' => wc_clean( $_POST['status_shipped'] ),
1403
  );
1404
  $order = wc_get_order($order_id);
1405
+
1406
  if ( $order === false ) {
1407
  echo '<li class="error">Failed - Invalid Order Id - '.$_POST['order_id'].'</li>';exit;
1408
  } else{
1451
  return $redirect_to;
1452
 
1453
  $processed_ids = array();
1454
+
1455
+ $order_count = count($post_ids);
1456
+
1457
+ if($order_count > 100){
1458
+ return $redirect_to;
1459
+ }
1460
+
1461
  foreach ( $post_ids as $post_id ) {
1462
 
1463
  $this->trigger_woocommerce_order_status_completed( $post_id );
1543
  case "carrier_unsupported":
1544
  $status = __( 'Carrier unsupported', 'woo-advanced-shipment-tracking' );
1545
  break;
1546
+ case "invalid_user_key":
1547
+ $status = __( 'Invalid User Key', 'woo-advanced-shipment-tracking' );
1548
+ break;
1549
+
1550
  }
1551
  return $status;
1552
  }
1586
  case "INVALID_TRACKING_NUM":
1587
  $html = '<i class="fa fa-question-circle icon-'.$status.'" aria-hidden="true"></i>';
1588
  break;
1589
+ case "invalid_user_key":
1590
+ $html = '<span class="icon-'.$status.'">';
1591
+ break;
1592
  default:
1593
  $html = '<i class="fa fa-question-circle icon-'.$status.'" aria-hidden="true"></i>';
1594
  break;
1595
 
1596
  }
1597
  return $html;
1598
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1599
 
1600
  /*
1601
  * retry trackship api call
1947
  }
1948
 
1949
  public function sync_providers_fun(){
1950
+ global $wpdb;
1951
+
1952
+ $url = 'https://trackship.info/wp-json/WCAST/v1/Provider';
1953
+ $resp = wp_remote_get( $url );
 
 
 
 
 
1954
  $providers = json_decode($resp['body'],true);
1955
 
1956
  $default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table WHERE shipping_default = 1" );
1996
  }
1997
  } else{
1998
  $img_url = $provider['img_url'];
1999
+
2000
  $img_slug = sanitize_title($provider_name);
2001
  $img = wc_advanced_shipment_tracking()->get_plugin_path().'/assets/shipment-provider-img/'.$img_slug.'.png';
2002
 
2026
  }
2027
  }
2028
  foreach($default_shippment_providers as $db_provider){
2029
+ if(!isset($providers_name[$db_provider->provider_name])){
2030
  $where = array(
2031
  'provider_name' => $db_provider->provider_name,
2032
  'shipping_default' => 1
2095
  <a class="view_synch_details" id="view_deleted_details" href="javaScript:void(0);" style="display: block;"><?php _e( 'view details', 'woo-advanced-shipment-tracking'); ?></a>
2096
  <a class="view_synch_details" id="hide_deleted_details" href="javaScript:void(0);" style="display: none;"><?php _e( 'hide details', 'woo-advanced-shipment-tracking'); ?></a>
2097
  <?php }
2098
+ /**
2099
+ * Add bulk filter for Shipment status in orders list
2100
+ *
2101
+ * @since 2.4
2102
+ */
2103
+ public function filter_orders_by_shipment_status(){
2104
+ global $typenow;
2105
+
2106
+ if ( 'shop_order' === $typenow ) {
2107
+
2108
+ $count = $this->get_order_count();
2109
+
2110
+ $terms = array(
2111
+ 'unknown' => (object) array( 'count' => $count['unknown'], 'term' => __( 'Unknown', 'woo-advanced-shipment-tracking' ) ),
2112
+ 'pre_transit' => (object) array( 'count' => $count['pre_transit'],'term' => __( 'Pre Transit', 'woo-advanced-shipment-tracking' ) ),
2113
+ 'in_transit' => (object) array( 'count' => $count['in_transit'],'term' => __( 'In Transit', 'woo-advanced-shipment-tracking' ) ),
2114
+ 'available_for_pickup' => (object) array( 'count' => $count['available_for_pickup'],'term' => __( 'Available for Pickup', 'woo-advanced-shipment-tracking' ) ),
2115
+ 'out_for_delivery' => (object) array( 'count' => $count['out_for_delivery'],'term' => __( 'Out for Delivery', 'woo-advanced-shipment-tracking' ) ),
2116
+ 'delivered' => (object) array( 'count' => $count['delivered'],'term' => __( 'Delivered', 'woo-advanced-shipment-tracking' ) ),
2117
+ 'failed_attempt' => (object) array( 'count' => $count['failed_attempt'],'term' => __( 'Failed Attempt', 'woo-advanced-shipment-tracking' ) ),
2118
+ 'cancelled' => (object) array( 'count' => $count['cancelled'],'term' => __( 'Cancelled', 'woo-advanced-shipment-tracking' ) ),
2119
+ 'carrier_unsupported' => (object) array( 'count' => $count['carrier_unsupported'],'term' => __( 'Carrier Unsupported', 'woo-advanced-shipment-tracking' ) ),
2120
+ 'return_to_sender' => (object) array( 'count' => $count['return_to_sender'],'term' => __( 'Return To Sender', 'woo-advanced-shipment-tracking' ) ),
2121
+ 'INVALID_TRACKING_NUM' => (object) array( 'count' => $count['invalid_tracking_number'],'term' => __( 'Invalid Tracking Number', 'woo-advanced-shipment-tracking' ) ),
2122
+ );
2123
+
2124
+ ?>
2125
+ <select name="_shop_order_shipment_status" id="dropdown_shop_order_shipment_status">
2126
+ <option value=""><?php _e( 'Filter by shipment status', 'woo-advanced-shipment-tracking' ); ?></option>
2127
+ <?php foreach ( $terms as $value => $term ) : ?>
2128
+ <option value="<?php echo esc_attr( $value ); ?>" <?php echo esc_attr( isset( $_GET['_shop_order_shipment_status'] ) ? selected( $value, $_GET['_shop_order_shipment_status'], false ) : '' ); ?>>
2129
+ <?php printf( '%1$s (%2$s)', esc_html( $term->term ), esc_html( $term->count ) ); ?>
2130
+ </option>
2131
+ <?php endforeach; ?>
2132
+ </select>
2133
+ <?php
2134
+ }
2135
+ }
2136
+
2137
+ /**
2138
+ * Get the order count for orders by shipment status
2139
+ * @since 2.4
2140
+ */
2141
+ private function get_order_count() {
2142
+
2143
+ $query_args = array(
2144
+ 'fields' => 'ids',
2145
+ 'post_type' => 'shop_order',
2146
+ 'post_status' => isset( $_GET['post_status'] ) ? $_GET['post_status'] : 'any',
2147
+ 'meta_query' => array(
2148
+ array(
2149
+ 'key' => 'shipment_status',
2150
+ 'value' => '',
2151
+ 'compare' => 'LIKE',
2152
+ )
2153
+ ),
2154
+ 'nopaging' => true,
2155
+ );
2156
+
2157
+ $order_query = new WP_Query( $query_args );
2158
+
2159
+ $query_args['meta_query'][0]['value'] = 'delivered';
2160
+ $delivered_query = new WP_Query( $query_args );
2161
+
2162
+ $query_args['meta_query'][0]['value'] = 'unknown';
2163
+ $unknown_query = new WP_Query( $query_args );
2164
+
2165
+ $query_args['meta_query'][0]['value'] = 'pre_transit';
2166
+ $pre_transit_query = new WP_Query( $query_args );
2167
+
2168
+ $query_args['meta_query'][0]['value'] = 'in_transit';
2169
+ $in_transit_query = new WP_Query( $query_args );
2170
+
2171
+ $query_args['meta_query'][0]['value'] = 'available_for_pickup';
2172
+ $available_for_pickup_query = new WP_Query( $query_args );
2173
+
2174
+ $query_args['meta_query'][0]['value'] = 'out_for_delivery';
2175
+ $out_for_delivery_query = new WP_Query( $query_args );
2176
+
2177
+ $query_args['meta_query'][0]['value'] = 'failed_attempt';
2178
+ $failed_attempt_query = new WP_Query( $query_args );
2179
+
2180
+ $query_args['meta_query'][0]['value'] = 'cancelled';
2181
+ $cancelled_query = new WP_Query( $query_args );
2182
+
2183
+ $query_args['meta_query'][0]['value'] = 'carrier_unsupported';
2184
+ $carrier_unsupported_query = new WP_Query( $query_args );
2185
+
2186
+ $query_args['meta_query'][0]['value'] = 'return_to_sender';
2187
+ $return_to_sender_query = new WP_Query( $query_args );
2188
+
2189
+ $query_args['meta_query'][0]['value'] = 'INVALID_TRACKING_NUM';
2190
+ $invalid_tracking_number_query = new WP_Query( $query_args );
2191
+
2192
+ return array( 'unknown' => $unknown_query->found_posts, 'pre_transit' => $pre_transit_query->found_posts, 'in_transit' => $in_transit_query->found_posts, 'available_for_pickup' => $available_for_pickup_query->found_posts, 'out_for_delivery' => $out_for_delivery_query->found_posts, 'failed_attempt' => $failed_attempt_query->found_posts, 'cancelled' => $cancelled_query->found_posts, 'carrier_unsupported' => $carrier_unsupported_query->found_posts, 'return_to_sender' => $return_to_sender_query->found_posts, 'delivered' => $delivered_query->found_posts, 'invalid_tracking_number' => $invalid_tracking_number_query->found_posts);
2193
+ }
2194
+ /**
2195
+ * Process bulk filter action for shipment status orders
2196
+ *
2197
+ * @since 3.0.0
2198
+ * @param array $vars query vars without filtering
2199
+ * @return array $vars query vars with (maybe) filtering
2200
+ */
2201
+ public function filter_orders_by_shipment_status_query( $vars ){
2202
+ global $typenow;
2203
+
2204
+ if ( 'shop_order' === $typenow && isset( $_GET['_shop_order_shipment_status'] )) {
2205
+ $vars['meta_key'] = 'shipment_status';
2206
+ $vars['meta_value'] = $_GET['_shop_order_shipment_status'];
2207
+ $vars['meta_compare'] = 'LIKE';
2208
+ }
2209
+
2210
+ return $vars;
2211
+ }
2212
+ /**
2213
+ * Add a new dashboard widget.
2214
+ */
2215
+ public function ast_add_dashboard_widgets() {
2216
+ wp_add_dashboard_widget( 'dashboard_widget', 'TrackShip Reports', array( $this, 'dashboard_widget_function') );
2217
+ }
2218
+ /**
2219
+ * Output the contents of the dashboard widget
2220
+ */
2221
+ public function dashboard_widget_function( $post, $callback_args ) { ?>
2222
+ <div class="ast-dashborad-widget row align-equal row-dashed" id="">
2223
+ <div class="col medium-6 small-12 large-6">
2224
+ <div class="col-inner">
2225
+ <p data-line-height="s"><strong>Shipment Trackers</strong></p>
2226
+ <p><span style="font-size: 100%;"><span style="font-size: 200%;" data-text-color="primary">7</span>
2227
+ <span class="ft12 red">42% <i class="fa fa-arrow-down"></i></span></span>
2228
+ </p>
2229
+ </div>
2230
+ </div>
2231
+ <div class="col medium-6 small-12 large-6">
2232
+ <div class="col-inner">
2233
+ <p data-line-height="s"><strong>Shipment Providers</strong></p>
2234
+ <table class="table">
2235
+ <tbody>
2236
+ <tr class="card-category">
2237
+ <td><strong>ups</strong></td>
2238
+ <td>3</td>
2239
+ <td><span class="ft12 green">0% <i class="fa fa-arrow-up"></i></span></td>
2240
+ </tr>
2241
+ <tr class="card-category">
2242
+ <td><strong>usps</strong></td>
2243
+ <td>2</td>
2244
+ <td><span class="ft12 red">33% <i class="fa fa-arrow-down"></i></span></td>
2245
+ </tr>
2246
+ <tr class="card-category">
2247
+ <td><strong>dhlparcel-nl</strong></td>
2248
+ <td>1</td>
2249
+ <td><span class="ft12 green">100% <i class="fa fa-arrow-up"></i></span></td>
2250
+ </tr>
2251
+ </tbody>
2252
+ </table>
2253
+ </div>
2254
+ </div>
2255
+ <div class="col medium-6 small-12 large-6">
2256
+ <div class="col-inner">
2257
+ <p data-line-height="s"><strong>Shipment Status</strong></p>
2258
+ <p data-line-height="s">
2259
+ </p>
2260
+ <table class="table">
2261
+ <tbody>
2262
+ <tr class="card-category">
2263
+ <td><strong>Delivered</strong></td>
2264
+ <td>6</td>
2265
+ <td><span class="ft12 red">45% <i class="fa fa-arrow-down"></i></span></td>
2266
+ </tr>
2267
+ <tr class="card-category">
2268
+ <td><strong>Return to sender</strong></td>
2269
+ <td>1</td>
2270
+ <td><span class="ft12 green">100% <i class="fa fa-arrow-up"></i></span></td>
2271
+ </tr>
2272
+ </tbody>
2273
+ </table>
2274
+ </div>
2275
+ </div>
2276
+ <div class="col medium-6 small-12 large-6">
2277
+ <div class="col-inner">
2278
+ <p data-line-height="s"><strong>Tracking Issues</strong></p>
2279
+ <table class="table">
2280
+ <tbody>
2281
+ </tbody>
2282
+ </table>
2283
+ </div>
2284
+ </div>
2285
+ <style scope="scope">
2286
+ </style>
2287
+ </div>
2288
+ <?php }
2289
  }
includes/class-wc-advanced-shipment-tracking-api-call.php CHANGED
@@ -14,7 +14,7 @@ class WC_Advanced_Shipment_Tracking_Api_Call {
14
  }
15
 
16
  public function get_trackship_apicall( $order_id ){
17
- //error_reporting(E_ALL); ini_set('display_errors', 1);
18
  $logger = wc_get_logger();
19
  $context = array( 'source' => 'wc_ast_trackship' );
20
 
@@ -22,7 +22,7 @@ class WC_Advanced_Shipment_Tracking_Api_Call {
22
  $tracking_items = $order->get_meta( '_wc_shipment_tracking_items', true );
23
 
24
  $shipment_status = get_post_meta( $order_id, "shipment_status", true);
25
- //echo '<pre>';print_r($tracking_items);echo '</pre>';exit;
26
  if( $tracking_items ){
27
  foreach( ( array )$tracking_items as $key => $val ){
28
  if($shipment_status[$key]['status'] == 'delivered')continue;
@@ -92,11 +92,8 @@ class WC_Advanced_Shipment_Tracking_Api_Call {
92
  $logger = wc_get_logger();
93
  $context = array( 'source' => 'Trackship_apicall_error' );
94
  $logger->error( "Error code : ".$code. " For Order id :" .$order->get_id(), $context );
95
- }
96
-
97
-
98
- }
99
-
100
  }
101
  }
102
  }
@@ -105,9 +102,21 @@ class WC_Advanced_Shipment_Tracking_Api_Call {
105
 
106
  public function get_trackship_data( $order, $tracking_number, $tracking_provider ){
107
  $user_key = get_option("wc_ast_api_key");
108
- $domain = get_site_url();
109
  $order_id = $order->get_id();
110
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  $url = 'https://trackship.info/wp-json/tracking/create';
112
 
113
  $args['body'] = array(
@@ -116,6 +125,8 @@ class WC_Advanced_Shipment_Tracking_Api_Call {
116
  'domain' => $domain,
117
  'tracking_number' => $tracking_number,
118
  'tracking_provider' => $tracking_provider,
 
 
119
  );
120
 
121
  $args['headers'] = array(
14
  }
15
 
16
  public function get_trackship_apicall( $order_id ){
17
+
18
  $logger = wc_get_logger();
19
  $context = array( 'source' => 'wc_ast_trackship' );
20
 
22
  $tracking_items = $order->get_meta( '_wc_shipment_tracking_items', true );
23
 
24
  $shipment_status = get_post_meta( $order_id, "shipment_status", true);
25
+
26
  if( $tracking_items ){
27
  foreach( ( array )$tracking_items as $key => $val ){
28
  if($shipment_status[$key]['status'] == 'delivered')continue;
92
  $logger = wc_get_logger();
93
  $context = array( 'source' => 'Trackship_apicall_error' );
94
  $logger->error( "Error code : ".$code. " For Order id :" .$order->get_id(), $context );
95
+ }
96
+ }
 
 
 
97
  }
98
  }
99
  }
102
 
103
  public function get_trackship_data( $order, $tracking_number, $tracking_provider ){
104
  $user_key = get_option("wc_ast_api_key");
105
+ $domain = get_home_url();
106
  $order_id = $order->get_id();
107
 
108
+ if($order->get_shipping_country() != null){
109
+ $shipping_country = $order->get_shipping_country();
110
+ } else{
111
+ $shipping_country = $order->get_billing_country();
112
+ }
113
+
114
+ if($order->get_shipping_postcode() != null){
115
+ $shipping_postal_code = $order->get_shipping_postcode();
116
+ } else{
117
+ $shipping_postal_code = $order->get_billing_postcode();
118
+ }
119
+
120
  $url = 'https://trackship.info/wp-json/tracking/create';
121
 
122
  $args['body'] = array(
125
  'domain' => $domain,
126
  'tracking_number' => $tracking_number,
127
  'tracking_provider' => $tracking_provider,
128
+ 'postal_code' => $shipping_postal_code,
129
+ 'destination_country' => $shipping_country,
130
  );
131
 
132
  $args['headers'] = array(
includes/class-wc-advanced-shipment-tracking-front.php CHANGED
@@ -15,6 +15,21 @@ class WC_Advanced_Shipment_Tracking_Front {
15
  * Initialize the main plugin function
16
  */
17
  public function __construct() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  $this->init();
20
  }
@@ -50,6 +65,7 @@ class WC_Advanced_Shipment_Tracking_Front {
50
  wp_enqueue_style( 'front_style', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/front.css', array(), wc_advanced_shipment_tracking()->version );
51
  }
52
  public function woo_track_order_function(){
 
53
  $wc_ast_api_key = get_option('wc_ast_api_key');
54
  $primary_color = get_option('wc_ast_select_primary_color');
55
  $success_color = get_option('wc_ast_select_success_color');
@@ -57,31 +73,7 @@ class WC_Advanced_Shipment_Tracking_Front {
57
  $border_color = get_option('wc_ast_select_border_color');
58
  ?>
59
  <style>
60
- <?php /*if($success_color){ ?>
61
- .bg-success{
62
- background-color:<?php echo $success_color; ?> !important;
63
- }
64
- .tracker-progress-bar-with-dots .success .dot{
65
- border-color: <?php echo $success_color; ?>;
66
- }
67
- .text-success{
68
- color: <?php echo $success_color; ?> !important;
69
- }
70
- .progress-bar.bg-success:before{
71
- background-color: <?php echo $success_color; ?>;
72
- }
73
- <?php } ?>
74
- <?php if($warning_color){ ?>
75
- .bg-warning{
76
- background-color:<?php echo $warning_color; ?> !important;
77
- }
78
- .tracker-progress-bar-with-dots .warning .dot{
79
- border-color: <?php echo $warning_color; ?>;
80
- }
81
- .text-warning{
82
- color: <?php echo $warning_color; ?> !important;
83
- }
84
- <?php } */?>
85
  <?php if($primary_color){ ?>
86
  .bg-secondary{
87
  background-color:<?php echo $primary_color; ?> !important;
@@ -119,23 +111,22 @@ class WC_Advanced_Shipment_Tracking_Front {
119
  if($order_key != $_GET['order_key']){
120
  return;
121
  }
122
- //$order_key = $_GET['key'];
123
  if(!get_post_status( $order_id )){
124
  return;
125
  }
126
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
127
- $tracking_items = get_post_meta( $order_id, '_wc_shipment_tracking_items', true );
128
- //$get_order_key = get_post_meta( $order_id, 'order_key', true );
129
  } else {
130
  $order = new WC_Order( $order_id );
131
- $tracking_items = $order->get_meta( '_wc_shipment_tracking_items', true );
132
- //$get_order_key = $order->order_key;
133
  }
134
  if(!$tracking_items){
135
  unset($order_id);
136
  }
137
 
138
  }
 
139
  ?>
140
 
141
  <?php
@@ -223,43 +214,80 @@ class WC_Advanced_Shipment_Tracking_Front {
223
  }
224
  }
225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  $num = 1;
227
- $total_trackings = sizeof($tracking_items);
 
228
  foreach($tracking_items as $item){
 
229
  $tracking_number = $item['tracking_number'];
230
  $trackship_url = 'https://trackship.info';
231
- $url = $trackship_url.'/wp-json/wc/v1/get_tracking_info_by_number';
 
 
 
 
 
 
 
 
232
  $args['body'] = array(
233
- 'tracking_number' => $tracking_number
 
 
 
234
  );
235
  $response = wp_remote_post( $url, $args );
236
  $data = $response['body'];
237
  $decoded_data = json_decode($data);
238
- //echo '<pre>';print_r($decoded_data);echo '</pre>';
 
 
239
  if(!empty($decoded_data)){
240
  $tracker = $decoded_data[0];
241
  }
242
 
243
- $tracking_detail_org = '';
 
244
 
 
 
 
 
245
 
 
246
 
247
- if(isset($tracker->tracking_detail) && $tracker->tracking_detail != 'null'){
248
- $tracking_detail = array_reverse(json_decode($tracker->tracking_detail));
249
- $tracking_detail_org = json_decode($tracker->tracking_detail);
250
- $trackind_detail_by_status = array();
251
- foreach ($tracking_detail_org as $key => $item) {
252
- $trackind_detail_by_status[$item->status] = $item;
253
- }
254
- $trackind_detail_by_status_rev = array_reverse($trackind_detail_by_status);
255
- }
256
-
257
- $unixTimestamp = strtotime($tracker->est_delivery_date);
258
- //Get the day of the week using PHP's date function.
259
- $day = date("l", $unixTimestamp);
260
- if(!empty($tracking_detail_org)){
261
- //echo '<pre>';print_r($tracking_detail_org);echo '</pre>';
262
-
263
  if($tracker->ep_status == "unknown"){ $state0_class = 'unknown'; } else{ $state0_class = 'pre_transit'; }
264
  if($tracker->ep_status == "return_to_sender" ){
265
  $state2_class = 'return_to_sender';
@@ -269,7 +297,8 @@ class WC_Advanced_Shipment_Tracking_Front {
269
  $state2_class = 'available_for_pickup';
270
  } else{
271
  $state2_class = 'out_for_delivery';
272
- }
 
273
  ?>
274
 
275
  <div class="tracking-detail col">
@@ -279,8 +308,8 @@ class WC_Advanced_Shipment_Tracking_Front {
279
  <?php } ?>
280
  <div class="tracking-header">
281
  <div class="col-md col-md-6">
282
- <?php _e( 'Order: ', 'woo-advanced-shipment-tracking' ); ?><span class="tracking-number">#<?php echo $order_id; ?></span><br/>
283
- <?php _e( 'Tracking: ', 'woo-advanced-shipment-tracking' ); ?><span class="tracking-number">#<?php echo $tracker->tracking_code; ?></span>
284
  <h1 class="shipment_status_heading <?php if($tracker->ep_status == "delivered") { echo 'text-success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure") { echo 'text-success'; } else{ echo 'text-secondary'; } ?>"><?php echo apply_filters("trackship_status_filter",$tracker->ep_status);?></h1>
285
  </div>
286
  <div class="col-md col-md-6">
@@ -297,15 +326,15 @@ class WC_Advanced_Shipment_Tracking_Front {
297
  <?php } ?>
298
  </div>
299
  </div>
300
-
301
  <div class="status-section desktop-section">
302
  <div class="tracker-progress-bar tracker-progress-bar-with-dots">
303
  <div class="progress">
304
- <div class="progress-bar <?php if($tracker->ep_status == "delivered") { echo 'bg-success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'bg-warning'; } else{ echo 'bg-secondary';} ?>" style="<?php /*if($tracker->ep_status == "in_transit") { echo 'width:33%;'; } elseif($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'width:66%';} elseif($tracker->ep_status == "delivered") { echo 'width:100%'; }*/ ?>"></div>
305
  </div>
306
  <div style="background-color: transparent;" class="<?php if($tracker->ep_status == "delivered") { echo 'success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure" || $tracker->ep_status == "unknown") { echo 'warning'; } else{ echo 'secondary';} ?>">
307
- <span class="dot state-0 <?php echo $state0_class?> <?php if($tracker->ep_status =="pre_transit"){ echo ' current-state'; } else{ echo 'past-state';} ?>"></span>
308
- <span class="state-label <?php if($tracker->ep_status =="pre_transit"){ echo 'current-state'; } else{ echo 'past-state';} ?>">
309
  <?php
310
  if($tracker->ep_status == "unknown"){
311
  echo apply_filters("trackship_status_filter",'unknown');
@@ -315,13 +344,13 @@ class WC_Advanced_Shipment_Tracking_Front {
315
  ?>
316
  </span>
317
 
318
- <span class="dot state-1 in_transit <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit"){ echo 'future-state'; } else{ echo 'past-state'; } ?>"></span>
319
- <span class="state-label state-1 <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit"){ echo 'future-state'; } else{ echo 'past-state'; } ?>">
320
  <?php echo apply_filters("trackship_status_filter",'in_transit'); ?>
321
  </span>
322
 
323
- <span class="dot state-2 <?php echo $state2_class; if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo ' current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit"){ echo ' future-state'; } else{ echo ' past-state'; } ?>"></span>
324
- <span class="state-label state-2 <?php if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit"){ echo 'future-state'; } else{ echo 'past-state'; } ?>">
325
  <?php
326
  if($tracker->ep_status == "return_to_sender"){
327
  echo apply_filters("trackship_status_filter",'return_to_sender');
@@ -333,8 +362,8 @@ class WC_Advanced_Shipment_Tracking_Front {
333
  ?>
334
  </span>
335
 
336
- <span class="dot state-3 delivered <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>"></span>
337
- <span class="state-label state-3 <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>">
338
  <?php echo apply_filters("trackship_status_filter",'delivered'); ?>
339
  </span>
340
  </div>
@@ -344,13 +373,13 @@ class WC_Advanced_Shipment_Tracking_Front {
344
  <div class="status-section mobile-section">
345
  <div class="tracker-progress-bar tracker-progress-bar-with-dots">
346
  <div class="progress">
347
- <div class="progress-bar <?php if($tracker->ep_status == "delivered") { echo 'bg-success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'bg-warning'; } else{ echo 'bg-secondary';} ?>" style="<?php /*if($tracker->ep_status == "in_transit") { echo 'height:33%;'; } elseif($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'height:66%';} elseif($tracker->ep_status == "delivered") { echo 'height:100%'; }*/ ?>"></div>
348
  </div>
349
  <div style="background-color: transparent;" class="<?php if($tracker->ep_status == "delivered") { echo 'success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure" || $tracker->ep_status == "unknown") { echo 'warning'; } else{ echo 'secondary';} ?>">
350
 
351
  <div class="dot-div">
352
- <span class="dot state-0 <?php echo $state0_class?> <?php if($tracker->ep_status =="pre_transit"){ echo ' current-state'; } else{ echo 'past-state';} ?>"></span>
353
- <span class="state-label <?php if($tracker->ep_status =="pre_transit"){ echo 'current-state'; } else{ echo 'past-state';} ?>">
354
  <?php
355
  if($tracker->ep_status == "unknown"){
356
  echo apply_filters("trackship_status_filter",'unknown');
@@ -362,15 +391,15 @@ class WC_Advanced_Shipment_Tracking_Front {
362
  </div>
363
 
364
  <div class="dot-div">
365
- <span class="dot state-1 in_transit <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit"){ echo 'future-state'; } else{ echo 'past-state'; } ?>"></span>
366
- <span class="state-label state-1 <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit"){ echo 'future-state'; } else{ echo 'past-state'; } ?>">
367
  <?php echo apply_filters("trackship_status_filter",'in_transit'); ?>
368
  </span>
369
  </div>
370
 
371
  <div class="dot-div">
372
- <span class="dot state-2 <?php echo $state2_class; if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo ' current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit"){ echo ' future-state'; } else{ echo ' past-state'; } ?>"></span>
373
- <span class="state-label state-2 <?php if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit"){ echo 'future-state'; } else{ echo ' past-state'; } ?>">
374
  <?php
375
  if($tracker->ep_status == "return_to_sender"){
376
  echo apply_filters("trackship_status_filter",'return_to_sender');
@@ -384,33 +413,30 @@ class WC_Advanced_Shipment_Tracking_Front {
384
  </div>
385
 
386
  <div class="dot-div">
387
- <span class="dot state-3 delivered <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>"></span>
388
- <span class="state-label state-3 <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>">
389
  <?php echo apply_filters("trackship_status_filter",'delivered'); ?>
390
  </span>
391
  </div>
392
 
393
  </div>
394
  </div>
395
- </div>
396
-
 
397
  <div class="shipment_progress_div">
398
- <div class="shipment_progress_heading_div">
399
- <?php if( sizeof($trackind_detail_by_status_rev) > 0 ){?>
400
- <h4 class="tracking-number h4-heading" style=""><?php _e( 'Tracking Details', 'woo-advanced-shipment-tracking' ); ?></h4>
401
- <?php } ?>
402
- </div>
403
- <?php if( sizeof($trackind_detail_by_status_rev) > 0 ){
404
- //echo '<pre>';print_r($trackind_detail_by_status_rev);echo '</pre>';
405
- ?>
406
  <table class="tracking-table">
407
  <tbody>
408
  <?php
409
  $i=0;
410
  foreach($trackind_detail_by_status_rev as $key=>$status_detail){ ?>
411
  <tr>
412
- <td><?php echo date("F d, Y",strtotime($status_detail->datetime)); ?> <?php echo date("g:i a", strtotime($status_detail->datetime)); ?></td>
413
- <td><?php echo apply_filters("trackship_status_filter",$key);?></td>
 
414
  <td><?php echo $status_detail->message; ?></td>
415
  </tr>
416
  <?php }
@@ -421,8 +447,9 @@ class WC_Advanced_Shipment_Tracking_Front {
421
 
422
  <a class="view_table_rows" href="javaScript:void(0);"><?php _e( 'view more', 'woo-advanced-shipment-tracking' ); ?></a>
423
  <a class="hide_table_rows" href="javaScript:void(0);"><?php _e( 'view less', 'woo-advanced-shipment-tracking' ); ?></a>
424
- <?php } } ?>
425
- </div>
 
426
  </div>
427
  <?php } else{ ?>
428
  <div class="tracking-detail col">
@@ -441,11 +468,13 @@ class WC_Advanced_Shipment_Tracking_Front {
441
  <?php } }
442
 
443
  public function get_tracking_info_fun(){
 
444
  $wc_ast_api_key = get_option('wc_ast_api_key');
445
  if(!$wc_ast_api_key){
446
  return;
447
  }
448
  $order_id = $_POST['order_id'];
 
449
  $email = $_POST['order_email'];
450
  if ( is_plugin_active( 'custom-order-numbers-for-woocommerce/custom-order-numbers-for-woocommerce.php' ) ) {
451
  $alg_wc_custom_order_numbers_enabled = get_option('alg_wc_custom_order_numbers_enabled');
@@ -514,7 +543,36 @@ class WC_Advanced_Shipment_Tracking_Front {
514
  wp_reset_postdata();
515
  }
516
  }
517
- //echo $order_email;exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518
  if(!get_post_status( $order_id )){
519
  echo '';
520
  exit;
@@ -545,30 +603,42 @@ class WC_Advanced_Shipment_Tracking_Front {
545
  foreach($tracking_items as $item){
546
  $tracking_number = $item['tracking_number'];
547
  $trackship_url = 'https://trackship.info';
548
- $url = $trackship_url.'/wp-json/wc/v1/get_tracking_info_by_number';
 
 
 
 
 
 
 
549
  $args['body'] = array(
550
- 'tracking_number' => $tracking_number
 
 
 
551
  );
 
552
  $response = wp_remote_post( $url, $args );
553
 
554
  $data = $response['body'];
555
  $decoded_data = json_decode($data);
556
- //echo '<pre>';print_r($decoded_data);echo '</pre>';exit;
557
- $tracker = $decoded_data[0];
 
 
 
 
 
 
558
  if(!$tracker){
559
  header("Status: 404 Not Found");
560
  exit;
561
  }
562
 
563
  $tracking_detail_org = '';
564
- if($tracker->tracking_detail != 'null'){
565
- $tracking_detail = array_reverse(json_decode($tracker->tracking_detail));
566
- $tracking_detail_org = json_decode($tracker->tracking_detail);
567
- $trackind_detail_by_status = array();
568
- foreach ($tracking_detail_org as $key => $item) {
569
- $trackind_detail_by_status[$item->status] = $item;
570
- }
571
- $trackind_detail_by_status_rev = array_reverse($trackind_detail_by_status);
572
  }
573
 
574
  if($tracker->ep_status == "unknown"){ $state0_class = 'unknown'; } else{ $state0_class = 'pre_transit'; }
@@ -584,7 +654,7 @@ class WC_Advanced_Shipment_Tracking_Front {
584
  $unixTimestamp = strtotime($decoded_data[0]->est_delivery_date);
585
  //Get the day of the week using PHP's date function.
586
  $day = date("l", $unixTimestamp);
587
- if($tracking_detail_org){
588
  ?>
589
  <div class="tracking-detail col">
590
  <?php if($total_trackings > 1 ){ ?>
@@ -593,8 +663,8 @@ class WC_Advanced_Shipment_Tracking_Front {
593
  <?php } ?>
594
  <div class="tracking-header">
595
  <div class="col-md col-md-6">
596
- <?php _e( 'Order: ', 'woo-advanced-shipment-tracking' ); ?><span class="tracking-number">#<?php echo $order_id; ?></span><br/>
597
- <?php _e( 'Tracking: ', 'woo-advanced-shipment-tracking' ); ?><span class="tracking-number">#<?php echo $tracker->tracking_code; ?></span>
598
  <h1 class="shipment_status_heading <?php if($tracker->ep_status == "delivered") { echo 'text-success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure") { echo 'text-success'; } else{ echo 'text-secondary'; } ?>"><?php echo apply_filters("trackship_status_filter",$tracker->ep_status);?></h1>
599
  </div>
600
  <div class="col-md col-md-6">
@@ -611,15 +681,16 @@ class WC_Advanced_Shipment_Tracking_Front {
611
  <?php } ?>
612
  </div>
613
  </div>
614
-
 
615
  <div class="status-section desktop-section">
616
  <div class="tracker-progress-bar tracker-progress-bar-with-dots">
617
  <div class="progress">
618
- <div class="progress-bar <?php if($tracker->ep_status == "delivered") { echo 'bg-success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'bg-warning'; } else{ echo 'bg-secondary';} ?>" style="<?php /*if($tracker->ep_status == "in_transit") { echo 'width:33%;'; } elseif($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'width:66%';} elseif($tracker->ep_status == "delivered") { echo 'width:100%'; }*/ ?>"></div>
619
  </div>
620
  <div style="background-color: transparent;" class="<?php if($tracker->ep_status == "delivered") { echo 'success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure" || $tracker->ep_status == "unknown") { echo 'warning'; } else{ echo 'secondary';} ?>">
621
- <span class="dot state-0 <?php echo $state0_class?> <?php if($tracker->ep_status =="pre_transit"){ echo ' current-state'; } else{ echo 'past-state';} ?>"></span>
622
- <span class="state-label <?php if($tracker->ep_status =="pre_transit"){ echo 'current-state'; } else{ echo 'past-state';} ?>">
623
  <?php
624
  if($tracker->ep_status == "unknown"){
625
  echo apply_filters("trackship_status_filter",'unknown');
@@ -629,13 +700,13 @@ class WC_Advanced_Shipment_Tracking_Front {
629
  ?>
630
  </span>
631
 
632
- <span class="dot state-1 in_transit <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit"){ echo 'future-state'; } else{ echo 'past-state'; } ?>"></span>
633
- <span class="state-label state-1 <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit"){ echo 'future-state'; } else{ echo 'past-state'; } ?>">
634
  <?php echo apply_filters("trackship_status_filter",'in_transit'); ?>
635
  </span>
636
 
637
- <span class="dot state-2 <?php echo $state2_class; if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo ' current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit"){ echo ' future-state'; } else{ echo ' past-state'; } ?>"></span>
638
- <span class="state-label state-2 <?php if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit"){ echo 'future-state'; } else{ echo 'past-state'; } ?>">
639
  <?php
640
  if($tracker->ep_status == "return_to_sender"){
641
  echo apply_filters("trackship_status_filter",'return_to_sender');
@@ -647,8 +718,8 @@ class WC_Advanced_Shipment_Tracking_Front {
647
  ?>
648
  </span>
649
 
650
- <span class="dot state-3 delivered <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>"></span>
651
- <span class="state-label state-3 <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>">
652
  <?php echo apply_filters("trackship_status_filter",'delivered'); ?>
653
  </span>
654
  </div>
@@ -658,13 +729,13 @@ class WC_Advanced_Shipment_Tracking_Front {
658
  <div class="status-section mobile-section">
659
  <div class="tracker-progress-bar tracker-progress-bar-with-dots">
660
  <div class="progress">
661
- <div class="progress-bar <?php if($tracker->ep_status == "delivered") { echo 'bg-success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'bg-warning'; } else{ echo 'bg-secondary';} ?>" style="<?php /*if($tracker->ep_status == "in_transit") { echo 'height:33%;'; } elseif($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'height:66%';} elseif($tracker->ep_status == "delivered") { echo 'height:100%'; }*/ ?>"></div>
662
  </div>
663
  <div style="background-color: transparent;" class="<?php if($tracker->ep_status == "delivered") { echo 'success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure" || $tracker->ep_status == "unknown") { echo 'warning'; } else{ echo 'secondary';} ?>">
664
 
665
  <div class="dot-div">
666
- <span class="dot state-0 <?php echo $state0_class?> <?php if($tracker->ep_status =="pre_transit"){ echo ' current-state'; } else{ echo 'past-state';} ?>"></span>
667
- <span class="state-label <?php if($tracker->ep_status =="pre_transit"){ echo 'current-state'; } else{ echo 'past-state';} ?>">
668
  <?php
669
  if($tracker->ep_status == "unknown"){
670
  echo apply_filters("trackship_status_filter",'unknown');
@@ -676,15 +747,15 @@ class WC_Advanced_Shipment_Tracking_Front {
676
  </div>
677
 
678
  <div class="dot-div">
679
- <span class="dot state-1 in_transit <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit"){ echo 'future-state'; } else{ echo 'past-state'; } ?>"></span>
680
- <span class="state-label state-1 <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit"){ echo 'future-state'; } else{ echo 'past-state'; } ?>">
681
  <?php echo apply_filters("trackship_status_filter",'in_transit'); ?>
682
  </span>
683
  </div>
684
 
685
  <div class="dot-div">
686
- <span class="dot state-2 <?php echo $state2_class; if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo ' current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit"){ echo ' future-state'; } else{ echo ' past-state'; } ?>"></span>
687
- <span class="state-label state-2 <?php if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit"){ echo 'future-state'; } else{ echo ' past-state'; } ?>">
688
  <?php
689
  if($tracker->ep_status == "return_to_sender"){
690
  echo apply_filters("trackship_status_filter",'return_to_sender');
@@ -698,8 +769,8 @@ class WC_Advanced_Shipment_Tracking_Front {
698
  </div>
699
 
700
  <div class="dot-div">
701
- <span class="dot state-3 delivered <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>"></span>
702
- <span class="state-label state-3 <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>">
703
  <?php echo apply_filters("trackship_status_filter",'delivered'); ?>
704
  </span>
705
  </div>
@@ -707,24 +778,21 @@ class WC_Advanced_Shipment_Tracking_Front {
707
  </div>
708
  </div>
709
  </div>
710
-
 
711
  <div class="shipment_progress_div">
712
- <div class="shipment_progress_heading_div">
713
- <?php if( sizeof($trackind_detail_by_status_rev) > 0 ){?>
714
- <h4 class="tracking-number h4-heading" style=""><?php _e( 'Tracking Details', 'woo-advanced-shipment-tracking' ); ?></h4>
715
- <?php } ?>
716
  </div>
717
- <?php if( sizeof($trackind_detail_by_status_rev) > 0 ){
718
- //echo '<pre>';print_r($trackind_detail_by_status_rev);echo '</pre>';
719
- ?>
720
  <table class="tracking-table">
721
  <tbody>
722
  <?php
723
  $i=0;
724
  foreach($trackind_detail_by_status_rev as $key=>$status_detail){ ?>
725
  <tr>
726
- <td><?php echo date("F d, Y",strtotime($status_detail->datetime)); ?> <?php echo date("g:i a", strtotime($status_detail->datetime)); ?></td>
727
- <td><?php echo apply_filters("trackship_status_filter",$key);?></td>
 
728
  <td><?php echo $status_detail->message; ?></td>
729
  </tr>
730
  <?php }
@@ -735,9 +803,10 @@ class WC_Advanced_Shipment_Tracking_Front {
735
 
736
  <a class="view_table_rows" href="javaScript:void(0);"><?php _e( 'view more', 'woo-advanced-shipment-tracking' ); ?></a>
737
  <a class="hide_table_rows" href="javaScript:void(0);"><?php _e( 'view less', 'woo-advanced-shipment-tracking' ); ?></a>
738
- <?php } } ?>
739
- </div>
740
- </div>
 
741
  <?php } else{ ?>
742
  <div class="tracking-detail col">
743
  <h1 class="shipment_status_heading text-secondary text-center"><?php _e( 'Tracking&nbsp;#&nbsp;'.$tracking_number, 'woo-advanced-shipment-tracking' ); ?></h1>
@@ -813,7 +882,7 @@ $wc_ast_api_key = get_option('wc_ast_api_key');
813
  <div class="tracking-header">
814
  <div class="col-md col-md-6">
815
  Order: <span class="tracking-number">#4542</span><br>
816
- Tracking: <span class="tracking-number">#9405511899561468285343</span>
817
  <h1 class="shipment_status_heading text-success">Delivered</h1>
818
  </div>
819
  <div class="col-md col-md-6">
@@ -915,4 +984,4 @@ $wc_ast_api_key = get_option('wc_ast_api_key');
915
  get_footer();
916
  exit;
917
  }
918
- }
15
  * Initialize the main plugin function
16
  */
17
  public function __construct() {
18
+ global $wpdb;
19
+ $this->table = $wpdb->prefix."woo_shippment_provider";
20
+ if( is_multisite() ){
21
+ if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
22
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
23
+ }
24
+ if ( is_plugin_active_for_network( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
25
+ $main_blog_prefix = $wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE);
26
+ $this->table = $main_blog_prefix."woo_shippment_provider";
27
+ } else{
28
+ $this->table = $wpdb->prefix."woo_shippment_provider";
29
+ }
30
+ } else{
31
+ $this->table = $wpdb->prefix."woo_shippment_provider";
32
+ }
33
 
34
  $this->init();
35
  }
65
  wp_enqueue_style( 'front_style', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/front.css', array(), wc_advanced_shipment_tracking()->version );
66
  }
67
  public function woo_track_order_function(){
68
+ global $wpdb;
69
  $wc_ast_api_key = get_option('wc_ast_api_key');
70
  $primary_color = get_option('wc_ast_select_primary_color');
71
  $success_color = get_option('wc_ast_select_success_color');
73
  $border_color = get_option('wc_ast_select_border_color');
74
  ?>
75
  <style>
76
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  <?php if($primary_color){ ?>
78
  .bg-secondary{
79
  background-color:<?php echo $primary_color; ?> !important;
111
  if($order_key != $_GET['order_key']){
112
  return;
113
  }
114
+
115
  if(!get_post_status( $order_id )){
116
  return;
117
  }
118
  if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
119
+ $tracking_items = get_post_meta( $order_id, '_wc_shipment_tracking_items', true );
 
120
  } else {
121
  $order = new WC_Order( $order_id );
122
+ $tracking_items = $order->get_meta( '_wc_shipment_tracking_items', true );
 
123
  }
124
  if(!$tracking_items){
125
  unset($order_id);
126
  }
127
 
128
  }
129
+
130
  ?>
131
 
132
  <?php
214
  }
215
  }
216
 
217
+ if ( is_plugin_active( 'wp-lister/wp-lister.php' ) ) {
218
+ $args = array(
219
+ 'post_type' => 'shop_order',
220
+ 'posts_per_page' => '1',
221
+ 'meta_query' => array(
222
+ 'relation' => 'AND',
223
+ array(
224
+ 'key' => '_ebay_order_id',
225
+ 'value' => $order_id
226
+ ),
227
+ ),
228
+ 'post_status' => array('wc-pending', 'wc-processing', 'wc-on-hold', 'wc-completed', 'wc-delivered', 'wc-cancelled', 'wc-refunded', 'wc-failed','wc-bit-payment') ,
229
+ );
230
+ $posts = get_posts( $args );
231
+ $my_query = new WP_Query( $args );
232
+
233
+ if( $my_query->have_posts() ) {
234
+ while( $my_query->have_posts()) {
235
+ $my_query->the_post();
236
+ if(get_the_ID()){
237
+ $order_id = get_the_ID();
238
+ }
239
+ } // end while
240
+ } // end if
241
+ wp_reset_postdata();
242
+ }
243
+
244
  $num = 1;
245
+ $total_trackings = sizeof($tracking_items);
246
+
247
  foreach($tracking_items as $item){
248
+
249
  $tracking_number = $item['tracking_number'];
250
  $trackship_url = 'https://trackship.info';
251
+ $tracking_provider = $item['tracking_provider'];
252
+ $results = $wpdb->get_row( "SELECT * FROM {$this->table} WHERE ts_slug= '{$tracking_provider}'");
253
+ $tracking_provider = $results->provider_name;
254
+
255
+ /*** Update in 2.4.1
256
+ * Change URL
257
+ * Add User Key
258
+ ***/
259
+ $url = $trackship_url.'/wp-json/tracking/get_tracking_info';
260
  $args['body'] = array(
261
+ 'tracking_number' => $tracking_number,
262
+ 'order_id' => $order_id,
263
+ 'domain' => get_home_url(),
264
+ 'user_key' => $wc_ast_api_key,
265
  );
266
  $response = wp_remote_post( $url, $args );
267
  $data = $response['body'];
268
  $decoded_data = json_decode($data);
269
+
270
+ $tracker = new \stdClass();
271
+ $tracker->ep_status = '';
272
  if(!empty($decoded_data)){
273
  $tracker = $decoded_data[0];
274
  }
275
 
276
+ $tracking_detail_org = '';
277
+ $trackind_detail_by_status_rev = '';
278
 
279
+ if(isset($tracker->tracking_detail) && $tracker->tracking_detail != 'null'){
280
+ $tracking_detail_org = json_decode($tracker->tracking_detail);
281
+ $trackind_detail_by_status_rev = array_reverse($tracking_detail_org);
282
+ }
283
 
284
+ if(!empty($decoded_data)){
285
 
286
+ if($tracker->est_delivery_date){
287
+ $unixTimestamp = strtotime($tracker->est_delivery_date);
288
+ $day = date("l", $unixTimestamp);
289
+ }
290
+
 
 
 
 
 
 
 
 
 
 
 
291
  if($tracker->ep_status == "unknown"){ $state0_class = 'unknown'; } else{ $state0_class = 'pre_transit'; }
292
  if($tracker->ep_status == "return_to_sender" ){
293
  $state2_class = 'return_to_sender';
297
  $state2_class = 'available_for_pickup';
298
  } else{
299
  $state2_class = 'out_for_delivery';
300
+ }
301
+
302
  ?>
303
 
304
  <div class="tracking-detail col">
308
  <?php } ?>
309
  <div class="tracking-header">
310
  <div class="col-md col-md-6">
311
+ <?php _e( 'Order: ', 'woo-advanced-shipment-tracking' ); ?><span class="tracking-number">#<?php echo apply_filters( 'ast_order_number_filter', $order_id); ?></span><br/>
312
+ <?php echo $tracking_provider; ?>: <span class="tracking-number"><?php echo $tracker->tracking_code; ?></span>
313
  <h1 class="shipment_status_heading <?php if($tracker->ep_status == "delivered") { echo 'text-success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure") { echo 'text-success'; } else{ echo 'text-secondary'; } ?>"><?php echo apply_filters("trackship_status_filter",$tracker->ep_status);?></h1>
314
  </div>
315
  <div class="col-md col-md-6">
326
  <?php } ?>
327
  </div>
328
  </div>
329
+ <?php if(isset($tracker->ep_status)){ ?>
330
  <div class="status-section desktop-section">
331
  <div class="tracker-progress-bar tracker-progress-bar-with-dots">
332
  <div class="progress">
333
+ <div class="progress-bar"></div>
334
  </div>
335
  <div style="background-color: transparent;" class="<?php if($tracker->ep_status == "delivered") { echo 'success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure" || $tracker->ep_status == "unknown") { echo 'warning'; } else{ echo 'secondary';} ?>">
336
+ <span class="dot state-0 <?php echo $state0_class?> <?php if($tracker->ep_status =="pre_transit" || $tracker->ep_status =="unknown"){ echo ' current-state'; } else{ echo 'past-state';} ?>"></span>
337
+ <span class="state-label <?php if($tracker->ep_status =="pre_transit" || $tracker->ep_status =="unknown"){ echo 'current-state'; } else{ echo 'past-state';} ?>">
338
  <?php
339
  if($tracker->ep_status == "unknown"){
340
  echo apply_filters("trackship_status_filter",'unknown');
344
  ?>
345
  </span>
346
 
347
+ <span class="dot state-1 in_transit <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown"){ echo 'future-state'; } else{ echo 'past-state'; } ?>"></span>
348
+ <span class="state-label state-1 <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown"){ echo 'future-state'; } else{ echo 'past-state'; } ?>">
349
  <?php echo apply_filters("trackship_status_filter",'in_transit'); ?>
350
  </span>
351
 
352
+ <span class="dot state-2 <?php echo $state2_class; if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo ' current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit"){ echo ' future-state'; } else{ echo ' past-state'; } ?>"></span>
353
+ <span class="state-label state-2 <?php if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit"){ echo 'future-state'; } else{ echo 'past-state'; } ?>">
354
  <?php
355
  if($tracker->ep_status == "return_to_sender"){
356
  echo apply_filters("trackship_status_filter",'return_to_sender');
362
  ?>
363
  </span>
364
 
365
+ <span class="dot state-3 delivered <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>"></span>
366
+ <span class="state-label state-3 <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>">
367
  <?php echo apply_filters("trackship_status_filter",'delivered'); ?>
368
  </span>
369
  </div>
373
  <div class="status-section mobile-section">
374
  <div class="tracker-progress-bar tracker-progress-bar-with-dots">
375
  <div class="progress">
376
+ <div class="progress-bar <?php if($tracker->ep_status == "delivered") { echo 'bg-success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'bg-warning'; } else{ echo 'bg-secondary';} ?>"></div>
377
  </div>
378
  <div style="background-color: transparent;" class="<?php if($tracker->ep_status == "delivered") { echo 'success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure" || $tracker->ep_status == "unknown") { echo 'warning'; } else{ echo 'secondary';} ?>">
379
 
380
  <div class="dot-div">
381
+ <span class="dot state-0 <?php echo $state0_class?> <?php if($tracker->ep_status =="pre_transit" || $tracker->ep_status =="unknown"){ echo ' current-state'; } else{ echo 'past-state';} ?>"></span>
382
+ <span class="state-label <?php if($tracker->ep_status =="pre_transit" || $tracker->ep_status =="unknown"){ echo 'current-state'; } else{ echo 'past-state';} ?>">
383
  <?php
384
  if($tracker->ep_status == "unknown"){
385
  echo apply_filters("trackship_status_filter",'unknown');
391
  </div>
392
 
393
  <div class="dot-div">
394
+ <span class="dot state-1 in_transit <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown"){ echo 'future-state'; } else{ echo 'past-state'; } ?>"></span>
395
+ <span class="state-label state-1 <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown"){ echo 'future-state'; } else{ echo 'past-state'; } ?>">
396
  <?php echo apply_filters("trackship_status_filter",'in_transit'); ?>
397
  </span>
398
  </div>
399
 
400
  <div class="dot-div">
401
+ <span class="dot state-2 <?php echo $state2_class; if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo ' current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit"){ echo ' future-state'; } else{ echo ' past-state'; } ?>"></span>
402
+ <span class="state-label state-2 <?php if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit"){ echo 'future-state'; } else{ echo ' past-state'; } ?>">
403
  <?php
404
  if($tracker->ep_status == "return_to_sender"){
405
  echo apply_filters("trackship_status_filter",'return_to_sender');
413
  </div>
414
 
415
  <div class="dot-div">
416
+ <span class="dot state-3 delivered <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>"></span>
417
+ <span class="state-label state-3 <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>">
418
  <?php echo apply_filters("trackship_status_filter",'delivered'); ?>
419
  </span>
420
  </div>
421
 
422
  </div>
423
  </div>
424
+ </div>
425
+ <?php } ?>
426
+ <?php if( !empty($trackind_detail_by_status_rev) ){ ?>
427
  <div class="shipment_progress_div">
428
+ <div class="shipment_progress_heading_div">
429
+ <h4 class="tracking-number h4-heading" style=""><?php _e( 'Tracking Details', 'woo-advanced-shipment-tracking' ); ?></h4>
430
+ </div>
 
 
 
 
 
431
  <table class="tracking-table">
432
  <tbody>
433
  <?php
434
  $i=0;
435
  foreach($trackind_detail_by_status_rev as $key=>$status_detail){ ?>
436
  <tr>
437
+ <td><?php echo date_i18n( get_option( 'date_format' ), strtotime($status_detail->datetime) ); ?>
438
+ <?php echo date_i18n( get_option( 'time_format' ), strtotime($status_detail->datetime) ); ?></td>
439
+ <td><?php echo apply_filters("trackship_status_filter",$status_detail->status);?></td>
440
  <td><?php echo $status_detail->message; ?></td>
441
  </tr>
442
  <?php }
447
 
448
  <a class="view_table_rows" href="javaScript:void(0);"><?php _e( 'view more', 'woo-advanced-shipment-tracking' ); ?></a>
449
  <a class="hide_table_rows" href="javaScript:void(0);"><?php _e( 'view less', 'woo-advanced-shipment-tracking' ); ?></a>
450
+ <?php } ?>
451
+ </div>
452
+ <?php } ?>
453
  </div>
454
  <?php } else{ ?>
455
  <div class="tracking-detail col">
468
  <?php } }
469
 
470
  public function get_tracking_info_fun(){
471
+ global $wpdb;
472
  $wc_ast_api_key = get_option('wc_ast_api_key');
473
  if(!$wc_ast_api_key){
474
  return;
475
  }
476
  $order_id = $_POST['order_id'];
477
+
478
  $email = $_POST['order_email'];
479
  if ( is_plugin_active( 'custom-order-numbers-for-woocommerce/custom-order-numbers-for-woocommerce.php' ) ) {
480
  $alg_wc_custom_order_numbers_enabled = get_option('alg_wc_custom_order_numbers_enabled');
543
  wp_reset_postdata();
544
  }
545
  }
546
+
547
+ if ( is_plugin_active( 'wp-lister/wp-lister.php' ) || is_plugin_active( 'wp-lister-for-ebay/wp-lister.php' )) {
548
+
549
+ $args = array(
550
+ 'post_type' => 'shop_order',
551
+ 'posts_per_page' => '1',
552
+ 'meta_query' => array(
553
+ 'relation' => 'AND',
554
+ array(
555
+ 'key' => '_ebay_order_id',
556
+ 'value' => $order_id
557
+ ),
558
+ ),
559
+ 'post_status' => array('wc-pending', 'wc-processing', 'wc-on-hold', 'wc-completed', 'wc-delivered', 'wc-cancelled', 'wc-refunded', 'wc-failed','wc-bit-payment') ,
560
+ );
561
+ $posts = get_posts( $args );
562
+
563
+ $my_query = new WP_Query( $args );
564
+
565
+ if( $my_query->have_posts() ) {
566
+ while( $my_query->have_posts()) {
567
+ $my_query->the_post();
568
+ if(get_the_ID()){
569
+ $order_id = get_the_ID();
570
+ }
571
+ } // end while
572
+ } // end if
573
+ wp_reset_postdata();
574
+ }
575
+
576
  if(!get_post_status( $order_id )){
577
  echo '';
578
  exit;
603
  foreach($tracking_items as $item){
604
  $tracking_number = $item['tracking_number'];
605
  $trackship_url = 'https://trackship.info';
606
+ $tracking_provider = $item['tracking_provider'];
607
+ $results = $wpdb->get_row( "SELECT * FROM {$this->table} WHERE ts_slug= '{$tracking_provider}'");
608
+ $tracking_provider = $results->provider_name;
609
+ /*** Update in 2.4.1
610
+ * Change URL
611
+ * Add User Key
612
+ ***/
613
+ $url = $trackship_url.'/wp-json/tracking/get_tracking_info';
614
  $args['body'] = array(
615
+ 'tracking_number' => $tracking_number,
616
+ 'order_id' => $order_id,
617
+ 'domain' => get_home_url(),
618
+ 'user_key' => $wc_ast_api_key,
619
  );
620
+
621
  $response = wp_remote_post( $url, $args );
622
 
623
  $data = $response['body'];
624
  $decoded_data = json_decode($data);
625
+
626
+ $tracker->ep_status = '';
627
+
628
+ $tracker = $decoded_data[0];
629
+
630
+ $tracking_detail_org = '';
631
+ $trackind_detail_by_status_rev = '';
632
+
633
  if(!$tracker){
634
  header("Status: 404 Not Found");
635
  exit;
636
  }
637
 
638
  $tracking_detail_org = '';
639
+ if($tracker->tracking_detail != 'null'){
640
+ $tracking_detail_org = json_decode($tracker->tracking_detail);
641
+ $trackind_detail_by_status_rev = array_reverse($tracking_detail_org);
 
 
 
 
 
642
  }
643
 
644
  if($tracker->ep_status == "unknown"){ $state0_class = 'unknown'; } else{ $state0_class = 'pre_transit'; }
654
  $unixTimestamp = strtotime($decoded_data[0]->est_delivery_date);
655
  //Get the day of the week using PHP's date function.
656
  $day = date("l", $unixTimestamp);
657
+ if($decoded_data){
658
  ?>
659
  <div class="tracking-detail col">
660
  <?php if($total_trackings > 1 ){ ?>
663
  <?php } ?>
664
  <div class="tracking-header">
665
  <div class="col-md col-md-6">
666
+ <?php _e( 'Order: ', 'woo-advanced-shipment-tracking' ); ?><span class="tracking-number">#<?php echo apply_filters( 'ast_order_number_filter', $order_id); ?></span><br/>
667
+ <?php echo $tracking_provider; ?>: <span class="tracking-number"><?php echo $tracker->tracking_code; ?></span>
668
  <h1 class="shipment_status_heading <?php if($tracker->ep_status == "delivered") { echo 'text-success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure") { echo 'text-success'; } else{ echo 'text-secondary'; } ?>"><?php echo apply_filters("trackship_status_filter",$tracker->ep_status);?></h1>
669
  </div>
670
  <div class="col-md col-md-6">
681
  <?php } ?>
682
  </div>
683
  </div>
684
+ <?php
685
+ if(isset($tracker->ep_status)){ ?>
686
  <div class="status-section desktop-section">
687
  <div class="tracker-progress-bar tracker-progress-bar-with-dots">
688
  <div class="progress">
689
+ <div class="progress-bar"></div>
690
  </div>
691
  <div style="background-color: transparent;" class="<?php if($tracker->ep_status == "delivered") { echo 'success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure" || $tracker->ep_status == "unknown") { echo 'warning'; } else{ echo 'secondary';} ?>">
692
+ <span class="dot state-0 <?php echo $state0_class?> <?php if($tracker->ep_status =="pre_transit" || $tracker->ep_status =="unknown"){ echo ' current-state'; } else{ echo 'past-state';} ?>"></span>
693
+ <span class="state-label <?php if($tracker->ep_status =="pre_transit" || $tracker->ep_status =="unknown"){ echo 'current-state'; } else{ echo 'past-state';} ?>">
694
  <?php
695
  if($tracker->ep_status == "unknown"){
696
  echo apply_filters("trackship_status_filter",'unknown');
700
  ?>
701
  </span>
702
 
703
+ <span class="dot state-1 in_transit <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown"){ echo 'future-state'; } else{ echo 'past-state'; } ?>"></span>
704
+ <span class="state-label state-1 <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown"){ echo 'future-state'; } else{ echo 'past-state'; } ?>">
705
  <?php echo apply_filters("trackship_status_filter",'in_transit'); ?>
706
  </span>
707
 
708
+ <span class="dot state-2 <?php echo $state2_class; if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo ' current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit"){ echo ' future-state'; } else{ echo ' past-state'; } ?>"></span>
709
+ <span class="state-label state-2 <?php if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit"){ echo 'future-state'; } else{ echo 'past-state'; } ?>">
710
  <?php
711
  if($tracker->ep_status == "return_to_sender"){
712
  echo apply_filters("trackship_status_filter",'return_to_sender');
718
  ?>
719
  </span>
720
 
721
+ <span class="dot state-3 delivered <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>"></span>
722
+ <span class="state-label state-3 <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>">
723
  <?php echo apply_filters("trackship_status_filter",'delivered'); ?>
724
  </span>
725
  </div>
729
  <div class="status-section mobile-section">
730
  <div class="tracker-progress-bar tracker-progress-bar-with-dots">
731
  <div class="progress">
732
+ <div class="progress-bar <?php if($tracker->ep_status == "delivered") { echo 'bg-success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'bg-warning'; } else{ echo 'bg-secondary';} ?>"></div>
733
  </div>
734
  <div style="background-color: transparent;" class="<?php if($tracker->ep_status == "delivered") { echo 'success'; } elseif($tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure" || $tracker->ep_status == "unknown") { echo 'warning'; } else{ echo 'secondary';} ?>">
735
 
736
  <div class="dot-div">
737
+ <span class="dot state-0 <?php echo $state0_class?> <?php if($tracker->ep_status =="pre_transit" || $tracker->ep_status =="unknown"){ echo ' current-state'; } else{ echo 'past-state';} ?>"></span>
738
+ <span class="state-label <?php if($tracker->ep_status =="pre_transit" || $tracker->ep_status =="unknown"){ echo 'current-state'; } else{ echo 'past-state';} ?>">
739
  <?php
740
  if($tracker->ep_status == "unknown"){
741
  echo apply_filters("trackship_status_filter",'unknown');
747
  </div>
748
 
749
  <div class="dot-div">
750
+ <span class="dot state-1 in_transit <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown"){ echo 'future-state'; } else{ echo 'past-state'; } ?>"></span>
751
+ <span class="state-label state-1 <?php if($tracker->ep_status == "in_transit"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown"){ echo 'future-state'; } else{ echo 'past-state'; } ?>">
752
  <?php echo apply_filters("trackship_status_filter",'in_transit'); ?>
753
  </span>
754
  </div>
755
 
756
  <div class="dot-div">
757
+ <span class="dot state-2 <?php echo $state2_class; if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo ' current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit"){ echo ' future-state'; } else{ echo ' past-state'; } ?>"></span>
758
+ <span class="state-label state-2 <?php if($tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "failure" || $tracker->ep_status == "return_to_sender"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit"){ echo 'future-state'; } else{ echo ' past-state'; } ?>">
759
  <?php
760
  if($tracker->ep_status == "return_to_sender"){
761
  echo apply_filters("trackship_status_filter",'return_to_sender');
769
  </div>
770
 
771
  <div class="dot-div">
772
+ <span class="dot state-3 delivered <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>"></span>
773
+ <span class="state-label state-3 <?php if($tracker->ep_status == "delivered"){ echo 'current-state'; } elseif($tracker->ep_status == "pre_transit" || $tracker->ep_status =="unknown" || $tracker->ep_status == "in_transit" || $tracker->ep_status == "out_for_delivery" || $tracker->ep_status == "available_for_pickup" || $tracker->ep_status == "return_to_sender" || $tracker->ep_status == "failure"){ echo 'future-state'; }?>">
774
  <?php echo apply_filters("trackship_status_filter",'delivered'); ?>
775
  </span>
776
  </div>
778
  </div>
779
  </div>
780
  </div>
781
+ <?php } ?>
782
+ <?php if( !empty($trackind_detail_by_status_rev) ){ ?>
783
  <div class="shipment_progress_div">
784
+ <div class="shipment_progress_heading_div">
785
+ <h4 class="tracking-number h4-heading" style=""><?php _e( 'Tracking Details', 'woo-advanced-shipment-tracking' ); ?></h4>
 
 
786
  </div>
 
 
 
787
  <table class="tracking-table">
788
  <tbody>
789
  <?php
790
  $i=0;
791
  foreach($trackind_detail_by_status_rev as $key=>$status_detail){ ?>
792
  <tr>
793
+ <td><?php echo date_i18n( get_option( 'date_format' ), strtotime($status_detail->datetime) ); ?>
794
+ <?php echo date_i18n( get_option( 'time_format' ), strtotime($status_detail->datetime) ); ?></td>
795
+ <td><?php echo apply_filters("trackship_status_filter",$status_detail->status);?></td>
796
  <td><?php echo $status_detail->message; ?></td>
797
  </tr>
798
  <?php }
803
 
804
  <a class="view_table_rows" href="javaScript:void(0);"><?php _e( 'view more', 'woo-advanced-shipment-tracking' ); ?></a>
805
  <a class="hide_table_rows" href="javaScript:void(0);"><?php _e( 'view less', 'woo-advanced-shipment-tracking' ); ?></a>
806
+ <?php } ?>
807
+ </div>
808
+ <?php } ?>
809
+ </div>
810
  <?php } else{ ?>
811
  <div class="tracking-detail col">
812
  <h1 class="shipment_status_heading text-secondary text-center"><?php _e( 'Tracking&nbsp;#&nbsp;'.$tracking_number, 'woo-advanced-shipment-tracking' ); ?></h1>
882
  <div class="tracking-header">
883
  <div class="col-md col-md-6">
884
  Order: <span class="tracking-number">#4542</span><br>
885
+ USPS: <span class="tracking-number">9405511899561468285343</span>
886
  <h1 class="shipment_status_heading text-success">Delivered</h1>
887
  </div>
888
  <div class="col-md col-md-6">
984
  get_footer();
985
  exit;
986
  }
987
+ }
includes/class-wc-advanced-shipment-tracking-install.php CHANGED
@@ -127,7 +127,7 @@ class WC_Advanced_Shipment_Tracking_Install {
127
  "shipping_default" => $shipping_provider['shipping_default'],
128
  ));
129
  }
130
- update_option( 'wc_advanced_shipment_tracking', '2.9');
131
  }
132
  }
133
  /**
@@ -234,9 +234,9 @@ class WC_Advanced_Shipment_Tracking_Install {
234
  ),
235
 
236
  12 => array (
237
- "provider_name" => 'Hermes',
238
- "ts_slug" => 'hermes',
239
- "provider_url" => 'https://tracking.hermesworld.com/?TrackID=%number%',
240
  "shipping_country" => 'DE',
241
  "shipping_default" => '1'
242
  ),
@@ -914,8 +914,23 @@ class WC_Advanced_Shipment_Tracking_Install {
914
  "provider_url" => 'https://www.deppon.com/en/toTrack.action',
915
  "shipping_country" => 'CN',
916
  "shipping_default" => '1',
917
- ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
918
  );
 
919
  return $providers;
920
  }
921
  /*
@@ -1428,8 +1443,130 @@ class WC_Advanced_Shipment_Tracking_Install {
1428
 
1429
  update_option( 'wc_advanced_shipment_tracking', '2.9');
1430
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1431
  }
1432
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1433
  /*
1434
  * Display admin notice on plugin install or update
1435
  */
@@ -1455,4 +1592,4 @@ class WC_Advanced_Shipment_Tracking_Install {
1455
  </div>
1456
  <?php
1457
  }
1458
- }
127
  "shipping_default" => $shipping_provider['shipping_default'],
128
  ));
129
  }
130
+ update_option( 'wc_advanced_shipment_tracking', '3.1');
131
  }
132
  }
133
  /**
234
  ),
235
 
236
  12 => array (
237
+ "provider_name" => 'Hermes Germany',
238
+ "ts_slug" => 'hermes-de',
239
+ "provider_url" => 'https://www.myhermes.de/empfangen/sendungsverfolgung/?suche=%number%',
240
  "shipping_country" => 'DE',
241
  "shipping_default" => '1'
242
  ),
914
  "provider_url" => 'https://www.deppon.com/en/toTrack.action',
915
  "shipping_country" => 'CN',
916
  "shipping_default" => '1',
917
+ ),
918
+ 106 => array (
919
+ "provider_name" => 'GLS Italy',
920
+ "ts_slug" => 'gls-italy',
921
+ "provider_url" => 'https://www.gls-italy.com/?option=com_gls&view=track_e_trace&mode=search&numero_spedizione=%number%&tipo_codice=nazionale',
922
+ "shipping_country" => 'IT',
923
+ "shipping_default" => '1',
924
+ ),
925
+ 107 => array (
926
+ "provider_name" => 'Hermes World',
927
+ "ts_slug" => 'hermes',
928
+ "provider_url" => 'https://new.myhermes.co.uk/track.html#/parcel/%number%/details',
929
+ "shipping_country" => 'Global',
930
+ "shipping_default" => '1',
931
+ ),
932
  );
933
+
934
  return $providers;
935
  }
936
  /*
1443
 
1444
  update_option( 'wc_advanced_shipment_tracking', '2.9');
1445
  }
1446
+ if(version_compare(get_option( 'wc_advanced_shipment_tracking' ),'3.0', '<') ){
1447
+ global $wpdb;
1448
+ $new_providers = array (
1449
+ 1 => array (
1450
+ "provider_name" => 'GLS Italy',
1451
+ "ts_slug" => 'gls-italy',
1452
+ "provider_url" => 'https://www.gls-italy.com/?option=com_gls&view=track_e_trace&mode=search&numero_spedizione=%number%&tipo_codice=nazionale',
1453
+ "shipping_country" => 'IT',
1454
+ "shipping_default" => '1',
1455
+ "display_in_order" => 0,
1456
+ )
1457
+ );
1458
+
1459
+ foreach($new_providers as $provider){
1460
+ $success = $wpdb->insert($this->table, array(
1461
+ "provider_name" => $provider['provider_name'],
1462
+ "ts_slug" => $provider['ts_slug'],
1463
+ "provider_url" => $provider['provider_url'],
1464
+ "shipping_country" => $provider['shipping_country'],
1465
+ "shipping_default" => $provider['shipping_default'],
1466
+ "display_in_order" => $provider['display_in_order'],
1467
+ ));
1468
+ }
1469
+ update_option( 'wc_advanced_shipment_tracking', '3.0');
1470
+ }
1471
+ if(version_compare(get_option( 'wc_advanced_shipment_tracking' ),'3.1', '<') ){
1472
+ $this->update_shipping_providers();
1473
+ update_option( 'wc_advanced_shipment_tracking', '3.1');
1474
+ }
1475
+ if(version_compare(get_option( 'wc_advanced_shipment_tracking' ),'3.2', '<') ){
1476
+ $this->update_shipping_providers();
1477
+ update_option( 'wc_advanced_shipment_tracking', '3.2');
1478
+ }
1479
+ if(version_compare(get_option( 'wc_advanced_shipment_tracking' ),'3.3', '<') ){
1480
+ global $wpdb;
1481
+ $results = $wpdb->get_row( "SELECT * FROM {$this->table} LIMIT 1");
1482
+ if(!isset($results->ts_slug)) {
1483
+ $res = $wpdb->query( sprintf( "ALTER TABLE %s ADD ts_slug text NULL DEFAULT NULL AFTER provider_name", $this->table) );
1484
+ }
1485
+ $this->update_shipping_providers();
1486
+ update_option( 'wc_advanced_shipment_tracking', '3.3');
1487
+ }
1488
  }
1489
  }
1490
+
1491
+ public function update_shipping_providers(){
1492
+ global $wpdb;
1493
+ $url = 'https://trackship.info/wp-json/WCAST/v1/Provider';
1494
+ $resp = wp_remote_get( $url );
1495
+ $providers = json_decode($resp['body'],true);
1496
+
1497
+ $providers_name = array();
1498
+
1499
+ $default_shippment_providers = $wpdb->get_results( "SELECT * FROM $this->table WHERE shipping_default = 1" );
1500
+
1501
+ foreach ( $default_shippment_providers as $key => $val ){
1502
+ $shippment_providers[ $val->provider_name ] = $val;
1503
+ }
1504
+
1505
+ foreach ( $providers as $key => $val ){
1506
+ $providers_name[ $val['provider_name'] ] = $val;
1507
+ }
1508
+
1509
+ foreach($providers as $provider){
1510
+
1511
+ $provider_name = $provider['shipping_provider'];
1512
+ $provider_url = $provider['provider_url'];
1513
+ $shipping_country = $provider['shipping_country'];
1514
+ $ts_slug = $provider['shipping_provider_slug'];
1515
+
1516
+ if(isset($shippment_providers[$provider_name])){
1517
+ $db_provider_url = $shippment_providers[$provider_name]->provider_url;
1518
+ $db_shipping_country = $shippment_providers[$provider_name]->shipping_country;
1519
+ $db_ts_slug = $shippment_providers[$provider_name]->ts_slug;
1520
+ if(($db_provider_url != $provider_url) || ($db_shipping_country != $shipping_country) || ($db_ts_slug != $ts_slug)){
1521
+ $data_array = array(
1522
+ 'ts_slug' => $ts_slug,
1523
+ 'provider_url' => $provider_url,
1524
+ 'shipping_country' => $shipping_country,
1525
+ );
1526
+ $where_array = array(
1527
+ 'provider_name' => $provider_name,
1528
+ );
1529
+ $wpdb->update( $this->table, $data_array, $where_array);
1530
+ }
1531
+ } else{
1532
+ $img_url = $provider['img_url'];
1533
+ $img_slug = sanitize_title($provider_name);
1534
+ $img = wc_advanced_shipment_tracking()->get_plugin_path().'/assets/shipment-provider-img/'.$img_slug.'.png';
1535
+
1536
+ $ch = curl_init();
1537
+
1538
+ curl_setopt($ch, CURLOPT_HEADER, 0);
1539
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1540
+ curl_setopt($ch, CURLOPT_URL, $img_url);
1541
+
1542
+ $data = curl_exec($ch);
1543
+ curl_close($ch);
1544
+
1545
+ file_put_contents($img, $data);
1546
+
1547
+
1548
+ $data_array = array(
1549
+ 'shipping_country' => sanitize_text_field($shipping_country),
1550
+ 'provider_name' => sanitize_text_field($provider_name),
1551
+ 'ts_slug' => $ts_slug,
1552
+ 'provider_url' => sanitize_text_field($provider_url),
1553
+ 'display_in_order' => 0,
1554
+ 'shipping_default' => 1,
1555
+ );
1556
+ $result = $wpdb->insert( $this->table, $data_array );
1557
+ }
1558
+ }
1559
+ foreach($default_shippment_providers as $db_provider){
1560
+
1561
+ if(!isset($providers_name[$db_provider->provider_name])){
1562
+ $where = array(
1563
+ 'provider_name' => $db_provider->provider_name,
1564
+ 'shipping_default' => 1
1565
+ );
1566
+ $wpdb->delete( $this->table, $where );
1567
+ }
1568
+ }
1569
+ }
1570
  /*
1571
  * Display admin notice on plugin install or update
1572
  */
1592
  </div>
1593
  <?php
1594
  }
1595
+ }
includes/class-wc-advanced-shipment-tracking.php CHANGED
@@ -57,7 +57,11 @@ class WC_Advanced_Shipment_Tracking_Actions {
57
  if ( ! empty( $results ) ) {
58
 
59
  foreach ( $results as $row ) {
60
- $shippment_providers[ $row->provider_name ] = apply_filters( 'shipping_provider_url_template', $row->provider_url, $row->provider_name );
 
 
 
 
61
  }
62
 
63
  $this->providers = $shippment_providers;
@@ -137,10 +141,8 @@ class WC_Advanced_Shipment_Tracking_Actions {
137
  );
138
  }
139
  echo '</ul>';
140
- //echo '<a href="javascript:void(0);" class="add_inline_tracking" data-order="'.$order_id.'">'.__( "Add Tracking", "woo-advanced-shipment-tracking" ).'</a>';
141
  } else {
142
- echo '–';
143
- //echo '<a href="javascript:void(0);" class="button wc-action-button wc-action-button-view add_inline_tracking" data-order="'.$order_id.'">'.__( "Add Tracking", "woo-advanced-shipment-tracking" ).'</a>';
144
  }
145
  return apply_filters( 'woocommerce_shipment_tracking_get_shipment_tracking_column', ob_get_clean(), $order_id, $tracking_items );
146
  }
@@ -169,17 +171,18 @@ class WC_Advanced_Shipment_Tracking_Actions {
169
 
170
  $shippment_providers = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name" );
171
 
172
- $default_provider = get_option("wc_ast_default_provider" );
 
173
 
174
  $wc_ast_status_shipped = get_option('wc_ast_status_shipped');
175
  if($wc_ast_status_shipped == 1){
176
- $change_order_status_label = 'Change order to Shipped?';
177
  } else{
178
- $change_order_status_label = 'Change order to Completed?';
179
  }
180
  ?>
181
- <div id="" class="popupwrapper add_tracking_popup" style="display:none;">
182
- <div class="popuprow">
183
  <h3 class="popup_title"><?php _e( 'Add Tracking Number', 'woo-advanced-shipment-tracking'); ?></h2>
184
  <form id="add_tracking_number_form" method="POST" class="add_tracking_number_form">
185
 
@@ -188,11 +191,15 @@ class WC_Advanced_Shipment_Tracking_Actions {
188
  <option value=""><?php _e( 'Provider:', 'woo-advanced-shipment-tracking' ); ?></option>
189
  <?php
190
  foreach($shippment_countries as $s_c){
191
- echo '<optgroup label="' . esc_attr( $WC_Countries->countries[$s_c->shipping_country] ) . '">';
 
 
 
 
 
192
  $country = $s_c->shipping_country;
193
  $shippment_providers_by_country = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE shipping_country = '$country' AND display_in_order = 1" );
194
- foreach ( $shippment_providers_by_country as $providers ) {
195
- //echo '<pre>';print_r($providers);echo '</pre>';
196
  $selected = ( $default_provider == esc_attr( $providers->ts_slug ) ) ? 'selected' : '';
197
  echo '<option value="' . esc_attr( $providers->ts_slug ) . '" '.$selected. '>' . esc_html( $providers->provider_name ) . '</option>';
198
  }
@@ -215,8 +222,8 @@ class WC_Advanced_Shipment_Tracking_Actions {
215
  ) );
216
  ?>
217
  <p class="form-field change_order_to_shipped_field ">
218
- <label for="change_order_to_shipped"><?php _e( 'Change order to Shipped?', 'woo-advanced-shipment-tracking'); ?></label>
219
- <input type="checkbox" class="checkbox" style="" name="change_order_to_shipped" id="change_order_to_shipped" value="yes">
220
  </p>
221
  <p class="" style="text-align:left;">
222
  <input type="hidden" name="action" value="add_inline_tracking_number">
@@ -241,8 +248,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
241
  * Returns a HTML node for a tracking item for the admin meta box
242
  */
243
  public function display_html_tracking_item_for_meta_box( $order_id, $item ) {
244
- $formatted = $this->get_formatted_tracking_item( $order_id, $item );
245
- //echo '<pre>';print_r($formatted);echo '</pre>';
246
  ?>
247
  <div class="tracking-item" id="tracking-item-<?php echo esc_attr( $item['tracking_id'] ); ?>">
248
  <p class="tracking-content">
@@ -333,12 +339,18 @@ class WC_Advanced_Shipment_Tracking_Actions {
333
  $shippment_providers = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name" );
334
 
335
  $default_provider = get_option("wc_ast_default_provider" );
 
 
 
 
 
 
336
 
337
  $wc_ast_status_shipped = get_option('wc_ast_status_shipped');
338
  if($wc_ast_status_shipped == 1){
339
- $change_order_status_label = 'Change order to Shipped?';
340
  } else{
341
- $change_order_status_label = 'Change order to Completed?';
342
  }
343
 
344
 
@@ -357,8 +369,12 @@ class WC_Advanced_Shipment_Tracking_Actions {
357
  echo '<p class="form-field tracking_provider_field"><label for="tracking_provider">' . __( 'Provider:', 'woo-advanced-shipment-tracking' ) . '</label><br/><select id="tracking_provider" name="tracking_provider" class="chosen_select" style="width:100%;">';
358
  echo '<option value="">'.__( 'Select Provider', 'woo-advanced-shipment-tracking' ).'</option>';
359
  foreach($shippment_countries as $s_c){
360
-
361
- echo '<optgroup label="' . esc_attr( $WC_Countries->countries[$s_c->shipping_country] ) . '">';
 
 
 
 
362
  $country = $s_c->shipping_country;
363
  $shippment_providers_by_country = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE shipping_country = '$country' AND display_in_order = 1" );
364
  foreach ( $shippment_providers_by_country as $providers ) {
@@ -406,8 +422,9 @@ class WC_Advanced_Shipment_Tracking_Actions {
406
  woocommerce_wp_checkbox( array(
407
  'id' => 'change_order_to_shipped',
408
  'label' => __( $change_order_status_label, 'woo-advanced-shipment-tracking' ),
409
- 'description' => '',
410
- 'value' => '',
 
411
  ) );
412
 
413
  echo '<button class="button button-primary button-save-form">' . __( 'Save Tracking', 'woo-advanced-shipment-tracking' ) . '</button>';
@@ -485,9 +502,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
485
  'date_shipped' => wc_clean( $_POST['date_shipped'] ),
486
  );
487
  if($_POST['change_order_to_shipped'] == 'yes'){
488
- $_POST['order_status'] = 'wc-completed';
489
- //$order = new WC_Order($post_id);
490
- //$order->update_status('completed');
491
  }
492
  $this->add_tracking_item( $post_id, $args );
493
  }
@@ -519,7 +534,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
519
  public function save_meta_box_ajax() {
520
  check_ajax_referer( 'create-tracking-item', 'security', true );
521
  $tracking_number = str_replace(' ', '', $_POST['tracking_number']);
522
- //echo '<pre>';print_r($_POST);echo '</pre>';exit;
523
  if ( isset( $_POST['tracking_number'] ) && $_POST['tracking_provider'] != '' && isset( $_POST['tracking_provider'] ) && strlen( $_POST['tracking_number'] ) > 0 ) {
524
 
525
  $order_id = wc_clean( $_POST['order_id'] );
@@ -701,7 +716,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
701
  $woo_shippment_table_name = wc_advanced_shipment_tracking()->table;
702
  $shippment_provider = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE provider_name='".$tracking_item['formatted_tracking_provider']."'" );
703
  $custom_thumb_id = $shippment_provider['0']->custom_thumb_id;
704
- //echo $custom_thumb_id;
705
  if($custom_thumb_id == 0){
706
  $src = wc_advanced_shipment_tracking()->plugin_dir_url()."assets/shipment-provider-img/".sanitize_title($tracking_item['formatted_tracking_provider']).".png";
707
  } else{
@@ -714,8 +729,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
714
  }
715
 
716
 
717
- if($display_thumbnail == 1){ ?>
718
- <!--img style="width: 30px;margin-right: 5px;" src="<?php echo $src; ?>"-->
719
  <?php }
720
  echo esc_html( $tracking_item['formatted_tracking_provider'] ); ?>
721
  </td>
@@ -778,11 +792,10 @@ class WC_Advanced_Shipment_Tracking_Actions {
778
 
779
  $link_format = '';
780
 
781
- foreach ( $this->get_providers() as $provider => $format ) {
782
-
783
- if ( sanitize_title( $provider ) === $tracking_item['tracking_provider'] ) {
784
- $link_format = $format;
785
- $formatted['formatted_tracking_provider'] = $provider;
786
  break;
787
  }
788
 
@@ -790,25 +803,42 @@ class WC_Advanced_Shipment_Tracking_Actions {
790
  break;
791
  }
792
  }
793
-
794
- if ( $link_format ) {
795
- $tracking_page = get_option('wc_ast_trackship_page_id');
796
- $wc_ast_api_key = get_option('wc_ast_api_key');
797
- $use_tracking_page = get_option('wc_ast_use_tracking_page');
798
-
799
- if( $wc_ast_api_key && $use_tracking_page){
800
- $order_key = $order->get_order_key();
801
- //echo $order_key;exit;
802
- $formatted['formatted_tracking_link'] = get_permalink( $tracking_page ).'?order_id='.$order_id.'&order_key='.$order_key;
803
- } else {
804
  $searchVal = array("%number%", str_replace(' ', '', "%2 $ s") );
805
  $tracking_number = str_replace(' ', '', $tracking_item['tracking_number']);
806
  $replaceVal = array( $tracking_number, urlencode( $postcode ) );
807
- $link_format = str_replace($searchVal, $replaceVal, $link_format);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
808
  $formatted['formatted_tracking_link'] = $link_format;
809
  }
810
- }
811
-
812
  }
813
 
814
  return $formatted;
@@ -856,18 +886,18 @@ class WC_Advanced_Shipment_Tracking_Actions {
856
  if($args['tracking_provider']){
857
  $tracking_item['tracking_provider'] = $args['tracking_provider'];
858
  }
859
- if($args['custom_tracking_provider']){
860
- $tracking_item['custom_tracking_provider'] = wc_clean( $args['custom_tracking_provider'] );
861
- }
862
- if($args['custom_tracking_link']){
863
- $tracking_item['custom_tracking_link'] = wc_clean( $args['custom_tracking_link'] );
864
- }
865
  if($args['tracking_number']){
866
  $tracking_item['tracking_number'] = wc_clean( $args['tracking_number'] );
867
  }
868
  if($args['date_shipped']){
869
- $tracking_item['date_shipped'] = wc_clean( strtotime( $args['date_shipped'] ) );
 
 
 
 
870
  }
 
871
  if($args['status_shipped']){
872
  $tracking_item['status_shipped'] = wc_clean( $args['status_shipped'] );
873
  }
@@ -876,11 +906,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
876
  $tracking_item['date_shipped'] = time();
877
  }
878
 
879
- if ( $tracking_item['custom_tracking_provider'] ) {
880
- $tracking_item['tracking_id'] = md5( "{$tracking_item['custom_tracking_provider']}-{$tracking_item['tracking_number']}" . microtime() );
881
- } else {
882
- $tracking_item['tracking_id'] = md5( "{$tracking_item['tracking_provider']}-{$tracking_item['tracking_number']}" . microtime() );
883
- }
884
 
885
  $tracking_items = $this->get_tracking_items( $order_id );
886
  $tracking_items[] = $tracking_item;
@@ -893,6 +919,62 @@ class WC_Advanced_Shipment_Tracking_Actions {
893
  }
894
  return $tracking_item;
895
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
896
 
897
  /**
898
  * Saves the tracking items array to post_meta.
@@ -987,13 +1069,14 @@ class WC_Advanced_Shipment_Tracking_Actions {
987
  public function check_tracking_delivered( $order_id ){
988
  $delivered = true;
989
  $shipment_status = get_post_meta( $order_id, "shipment_status", true);
 
990
  foreach( (array)$shipment_status as $shipment ){
991
  $status = $shipment['status'];
992
  if( $status != 'delivered' ){
993
  $delivered = false;
994
  }
995
  }
996
- if( count($shipment_status) > 0 && $delivered == true ){
997
  //trigger order deleivered
998
  $delivered_enabled = get_option( "wc_ast_status_change_to_delivered", 0);
999
  if( $delivered_enabled ){
57
  if ( ! empty( $results ) ) {
58
 
59
  foreach ( $results as $row ) {
60
+ //$shippment_providers[ $row->ts_slug ] = apply_filters( 'shipping_provider_url_template', $row->provider_url, $row->ts_slug );
61
+ $shippment_providers[ $row->ts_slug ] = array(
62
+ 'provider_name'=> $row->provider_name,
63
+ 'provider_url' => $row->provider_url,
64
+ );
65
  }
66
 
67
  $this->providers = $shippment_providers;
141
  );
142
  }
143
  echo '</ul>';
 
144
  } else {
145
+ echo '–';
 
146
  }
147
  return apply_filters( 'woocommerce_shipment_tracking_get_shipment_tracking_column', ob_get_clean(), $order_id, $tracking_items );
148
  }
171
 
172
  $shippment_providers = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name" );
173
 
174
+ $default_provider = get_option("wc_ast_default_provider" );
175
+ $wc_ast_default_mark_shipped = get_option("wc_ast_default_mark_shipped" );
176
 
177
  $wc_ast_status_shipped = get_option('wc_ast_status_shipped');
178
  if($wc_ast_status_shipped == 1){
179
+ $change_order_status_label = __( 'Change order to Shipped?', 'woo-advanced-shipment-tracking' );
180
  } else{
181
+ $change_order_status_label = __( 'Change order to Completed?', 'woo-advanced-shipment-tracking' );
182
  }
183
  ?>
184
+ <div id="" class="trackingpopup_wrapper add_tracking_popup" style="display:none;">
185
+ <div class="trackingpopup_row">
186
  <h3 class="popup_title"><?php _e( 'Add Tracking Number', 'woo-advanced-shipment-tracking'); ?></h2>
187
  <form id="add_tracking_number_form" method="POST" class="add_tracking_number_form">
188
 
191
  <option value=""><?php _e( 'Provider:', 'woo-advanced-shipment-tracking' ); ?></option>
192
  <?php
193
  foreach($shippment_countries as $s_c){
194
+ if($s_c->shipping_country != 'Global'){
195
+ $country_name = esc_attr( $WC_Countries->countries[$s_c->shipping_country] );
196
+ } else{
197
+ $country_name = 'Global';
198
+ }
199
+ echo '<optgroup label="' . $country_name . '">';
200
  $country = $s_c->shipping_country;
201
  $shippment_providers_by_country = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE shipping_country = '$country' AND display_in_order = 1" );
202
+ foreach ( $shippment_providers_by_country as $providers ) {
 
203
  $selected = ( $default_provider == esc_attr( $providers->ts_slug ) ) ? 'selected' : '';
204
  echo '<option value="' . esc_attr( $providers->ts_slug ) . '" '.$selected. '>' . esc_html( $providers->provider_name ) . '</option>';
205
  }
222
  ) );
223
  ?>
224
  <p class="form-field change_order_to_shipped_field ">
225
+ <label for="change_order_to_shipped"><?php echo $change_order_status_label; ?></label>
226
+ <input type="checkbox" class="checkbox" style="" name="change_order_to_shipped" id="change_order_to_shipped" value="yes" <?php if($wc_ast_default_mark_shipped == 1){ echo 'checked'; }?>>
227
  </p>
228
  <p class="" style="text-align:left;">
229
  <input type="hidden" name="action" value="add_inline_tracking_number">
248
  * Returns a HTML node for a tracking item for the admin meta box
249
  */
250
  public function display_html_tracking_item_for_meta_box( $order_id, $item ) {
251
+ $formatted = $this->get_formatted_tracking_item( $order_id, $item );
 
252
  ?>
253
  <div class="tracking-item" id="tracking-item-<?php echo esc_attr( $item['tracking_id'] ); ?>">
254
  <p class="tracking-content">
339
  $shippment_providers = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name" );
340
 
341
  $default_provider = get_option("wc_ast_default_provider" );
342
+ $wc_ast_default_mark_shipped = get_option("wc_ast_default_mark_shipped" );
343
+ $value = 1;
344
+ $cbvalue = '';
345
+ if($wc_ast_default_mark_shipped == 1){
346
+ $cbvalue = 1;
347
+ }
348
 
349
  $wc_ast_status_shipped = get_option('wc_ast_status_shipped');
350
  if($wc_ast_status_shipped == 1){
351
+ $change_order_status_label = __( 'Change order to Shipped?', 'woo-advanced-shipment-tracking' );
352
  } else{
353
+ $change_order_status_label = __( 'Change order to Completed?', 'woo-advanced-shipment-tracking' );
354
  }
355
 
356
 
369
  echo '<p class="form-field tracking_provider_field"><label for="tracking_provider">' . __( 'Provider:', 'woo-advanced-shipment-tracking' ) . '</label><br/><select id="tracking_provider" name="tracking_provider" class="chosen_select" style="width:100%;">';
370
  echo '<option value="">'.__( 'Select Provider', 'woo-advanced-shipment-tracking' ).'</option>';
371
  foreach($shippment_countries as $s_c){
372
+ if($s_c->shipping_country != 'Global'){
373
+ $country_name = esc_attr( $WC_Countries->countries[$s_c->shipping_country] );
374
+ } else{
375
+ $country_name = 'Global';
376
+ }
377
+ echo '<optgroup label="' . $country_name . '">';
378
  $country = $s_c->shipping_country;
379
  $shippment_providers_by_country = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE shipping_country = '$country' AND display_in_order = 1" );
380
  foreach ( $shippment_providers_by_country as $providers ) {
422
  woocommerce_wp_checkbox( array(
423
  'id' => 'change_order_to_shipped',
424
  'label' => __( $change_order_status_label, 'woo-advanced-shipment-tracking' ),
425
+ 'description' => '',
426
+ 'cbvalue' => $cbvalue,
427
+ 'value' => $value,
428
  ) );
429
 
430
  echo '<button class="button button-primary button-save-form">' . __( 'Save Tracking', 'woo-advanced-shipment-tracking' ) . '</button>';
502
  'date_shipped' => wc_clean( $_POST['date_shipped'] ),
503
  );
504
  if($_POST['change_order_to_shipped'] == 'yes'){
505
+ $_POST['order_status'] = 'wc-completed';
 
 
506
  }
507
  $this->add_tracking_item( $post_id, $args );
508
  }
534
  public function save_meta_box_ajax() {
535
  check_ajax_referer( 'create-tracking-item', 'security', true );
536
  $tracking_number = str_replace(' ', '', $_POST['tracking_number']);
537
+
538
  if ( isset( $_POST['tracking_number'] ) && $_POST['tracking_provider'] != '' && isset( $_POST['tracking_provider'] ) && strlen( $_POST['tracking_number'] ) > 0 ) {
539
 
540
  $order_id = wc_clean( $_POST['order_id'] );
716
  $woo_shippment_table_name = wc_advanced_shipment_tracking()->table;
717
  $shippment_provider = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE provider_name='".$tracking_item['formatted_tracking_provider']."'" );
718
  $custom_thumb_id = $shippment_provider['0']->custom_thumb_id;
719
+
720
  if($custom_thumb_id == 0){
721
  $src = wc_advanced_shipment_tracking()->plugin_dir_url()."assets/shipment-provider-img/".sanitize_title($tracking_item['formatted_tracking_provider']).".png";
722
  } else{
729
  }
730
 
731
 
732
+ if($display_thumbnail == 1){ ?>
 
733
  <?php }
734
  echo esc_html( $tracking_item['formatted_tracking_provider'] ); ?>
735
  </td>
792
 
793
  $link_format = '';
794
 
795
+ foreach ( $this->get_providers() as $provider => $format ) {
796
+ if ( $provider === $tracking_item['tracking_provider'] ) {
797
+ $link_format = $format['provider_url'];
798
+ $formatted['formatted_tracking_provider'] = $format['provider_name'];
 
799
  break;
800
  }
801
 
803
  break;
804
  }
805
  }
806
+
807
+ $tracking_page = get_option('wc_ast_trackship_page_id');
808
+ $wc_ast_api_key = get_option('wc_ast_api_key');
809
+ $use_tracking_page = get_option('wc_ast_use_tracking_page');
810
+
811
+ if( $wc_ast_api_key && $use_tracking_page){
812
+ $order_key = $order->get_order_key();
813
+ $formatted['formatted_tracking_link'] = get_permalink( $tracking_page ).'?order_id='.$order_id.'&order_key='.$order_key;
814
+ } else {
815
+ if ( $link_format ) {
 
816
  $searchVal = array("%number%", str_replace(' ', '', "%2 $ s") );
817
  $tracking_number = str_replace(' ', '', $tracking_item['tracking_number']);
818
  $replaceVal = array( $tracking_number, urlencode( $postcode ) );
819
+ $link_format = str_replace($searchVal, $replaceVal, $link_format);
820
+
821
+ if($order->get_shipping_country() != null){
822
+ $shipping_country = $order->get_shipping_country();
823
+ } else{
824
+ $shipping_country = $order->get_billing_country();
825
+ }
826
+
827
+ if($order->get_shipping_postcode() != null){
828
+ $shipping_postal_code = $order->get_shipping_postcode();
829
+ } else{
830
+ $shipping_postal_code = $order->get_billing_postcode();
831
+ }
832
+
833
+ $country_code = array("%country_code%", str_replace(' ', '', "%2 $ s") );
834
+ $link_format = str_replace($country_code, $shipping_country, $link_format);
835
+
836
+ $postal_code = array("%postal_code%", str_replace(' ', '', "%2 $ s") );
837
+ $link_format = str_replace($postal_code, $shipping_postal_code, $link_format);
838
+
839
  $formatted['formatted_tracking_link'] = $link_format;
840
  }
841
+ }
 
842
  }
843
 
844
  return $formatted;
886
  if($args['tracking_provider']){
887
  $tracking_item['tracking_provider'] = $args['tracking_provider'];
888
  }
889
+
 
 
 
 
 
890
  if($args['tracking_number']){
891
  $tracking_item['tracking_number'] = wc_clean( $args['tracking_number'] );
892
  }
893
  if($args['date_shipped']){
894
+ $date = str_replace("/","-",$args['date_shipped']);
895
+ $date = date_create($date);
896
+ $date = date_format($date,"d-m-Y");
897
+
898
+ $tracking_item['date_shipped'] = wc_clean( strtotime( $date ) );
899
  }
900
+
901
  if($args['status_shipped']){
902
  $tracking_item['status_shipped'] = wc_clean( $args['status_shipped'] );
903
  }
906
  $tracking_item['date_shipped'] = time();
907
  }
908
 
909
+ $tracking_item['tracking_id'] = md5( "{$tracking_item['tracking_provider']}-{$tracking_item['tracking_number']}" . microtime() );
 
 
 
 
910
 
911
  $tracking_items = $this->get_tracking_items( $order_id );
912
  $tracking_items[] = $tracking_item;
919
  }
920
  return $tracking_item;
921
  }
922
+
923
+ /*
924
+ * Adds a tracking item to the post_meta array from external system programatticaly
925
+ *
926
+ * @param int $order_id Order ID
927
+ * @param array $tracking_items List of tracking item
928
+ *
929
+ * @return array Tracking item
930
+ */
931
+ public function insert_tracking_item( $order_id, $args ) {
932
+ $tracking_item = array();
933
+ $tracking_provider = $args['tracking_provider'];
934
+
935
+ global $wpdb;
936
+ $woo_shippment_table_name = wc_advanced_shipment_tracking()->table;
937
+ $shippment_provider = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE provider_name='".$tracking_provider."'" );
938
+
939
+ if($args['tracking_provider']){
940
+ $tracking_item['tracking_provider'] = $shippment_provider['0']->ts_slug;
941
+ }
942
+ if($args['tracking_number']){
943
+ $tracking_item['tracking_number'] = wc_clean( $args['tracking_number'] );
944
+ }
945
+ if($args['date_shipped']){
946
+ $date = str_replace("/","-",$args['date_shipped']);
947
+ $date = date_create($date);
948
+ $date = date_format($date,"d-m-Y");
949
+
950
+ $tracking_item['date_shipped'] = wc_clean( strtotime( $date ) );
951
+ }
952
+
953
+ if($args['status_shipped']){
954
+ $tracking_item['status_shipped'] = wc_clean( $args['status_shipped'] );
955
+ }
956
+
957
+ if ( 0 == (int) $tracking_item['date_shipped'] ) {
958
+ $tracking_item['date_shipped'] = time();
959
+ }
960
+
961
+ $tracking_item['tracking_id'] = md5( "{$tracking_item['tracking_provider']}-{$tracking_item['tracking_number']}" . microtime() );
962
+
963
+ $tracking_items = $this->get_tracking_items( $order_id );
964
+ $tracking_items[] = $tracking_item;
965
+
966
+ if($tracking_item['tracking_provider']){
967
+ $this->save_tracking_items( $order_id, $tracking_items );
968
+ }
969
+
970
+ if( !empty($tracking_item['status_shipped'] )){
971
+ $order = new WC_Order( $order_id );
972
+ $order->update_status('completed');
973
+ }
974
+ return $tracking_item;
975
+ }
976
+
977
+
978
 
979
  /**
980
  * Saves the tracking items array to post_meta.
1069
  public function check_tracking_delivered( $order_id ){
1070
  $delivered = true;
1071
  $shipment_status = get_post_meta( $order_id, "shipment_status", true);
1072
+ $wc_ast_status_delivered = get_option('wc_ast_status_delivered');
1073
  foreach( (array)$shipment_status as $shipment ){
1074
  $status = $shipment['status'];
1075
  if( $status != 'delivered' ){
1076
  $delivered = false;
1077
  }
1078
  }
1079
+ if( count($shipment_status) > 0 && $delivered == true && $wc_ast_status_delivered){
1080
  //trigger order deleivered
1081
  $delivered_enabled = get_option( "wc_ast_status_change_to_delivered", 0);
1082
  if( $delivered_enabled ){
includes/customizer/class-wc-availableforpickup-email-customizer.php CHANGED
@@ -482,7 +482,7 @@ class wcast_availableforpickup_customizer_email {
482
  }
483
  // create a new email
484
  $email = new WC_Email();
485
- //$email->id = 'WC_Delivered_email';
486
  //echo '<pre>';print_r($email);echo '</pre>';
487
  // wrap the content with the email template and then add styles
488
  $message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
482
  }
483
  // create a new email
484
  $email = new WC_Email();
485
+ $email->id = 'WC_Delivered_email';
486
  //echo '<pre>';print_r($email);echo '</pre>';
487
  // wrap the content with the email template and then add styles
488
  $message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
includes/customizer/class-wc-email-customizer.php CHANGED
@@ -208,8 +208,8 @@ class wcast_initialise_customizer_email {
208
  );
209
  $wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[recipient]',
210
  array(
211
- 'label' => __( 'To', 'woo-advanced-shipment-tracking' ),
212
- 'description' => esc_html__( 'Enter emails here or use variables such as {customer_email}. Multiple emails can be separated by commas.', 'woo-advanced-shipment-tracking' ),
213
  'section' => 'customer_delivered_email',
214
  'type' => 'text',
215
  'input_attrs' => array(
@@ -232,7 +232,7 @@ class wcast_initialise_customizer_email {
232
  $wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[subject]',
233
  array(
234
  'label' => __( 'Email subject', 'woo-advanced-shipment-tracking' ),
235
- 'description' => esc_html__( 'Available placeholders: {site_title}, {order_number}', 'woo-advanced-shipment-tracking' ),
236
  'section' => 'customer_delivered_email',
237
  'type' => 'text',
238
  'input_attrs' => array(
@@ -255,7 +255,7 @@ class wcast_initialise_customizer_email {
255
  $wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[heading]',
256
  array(
257
  'label' => __( 'Email heading', 'woo-advanced-shipment-tracking' ),
258
- 'description' => esc_html__( 'Available placeholders: {site_title}, {order_number}', 'woo-advanced-shipment-tracking' ),
259
  'section' => 'customer_delivered_email',
260
  'type' => 'text',
261
  'input_attrs' => array(
@@ -266,6 +266,27 @@ class wcast_initialise_customizer_email {
266
  )
267
  );
268
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  // Display Shipment Provider image/thumbnail
270
  $wp_customize->add_setting( 'wcast_show_tracking_details',
271
  array(
@@ -276,7 +297,7 @@ class wcast_initialise_customizer_email {
276
  );
277
  $wp_customize->add_control( 'wcast_show_tracking_details',
278
  array(
279
- 'label' => __( 'Show tracking details', 'woo-advanced-shipment-tracking' ),
280
  'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
281
  'section' => 'customer_delivered_email',
282
  'type' => 'checkbox'
@@ -292,23 +313,24 @@ class wcast_initialise_customizer_email {
292
  );
293
  $wp_customize->add_control( 'wcast_show_order_details',
294
  array(
295
- 'label' => __( 'Show order details', 'woo-advanced-shipment-tracking' ),
296
  'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
297
  'section' => 'customer_delivered_email',
298
  'type' => 'checkbox'
299
  )
300
  );
 
301
  // Display Shipment Provider image/thumbnail
302
- $wp_customize->add_setting( 'wcast_show_billing_address',
303
  array(
304
- 'default' => $this->defaults['wcast_show_billing_address'],
305
  'transport' => 'refresh',
306
  'sanitize_callback' => ''
307
  )
308
  );
309
- $wp_customize->add_control( 'wcast_show_billing_address',
310
  array(
311
- 'label' => __( 'Show billing address', 'woo-advanced-shipment-tracking' ),
312
  'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
313
  'section' => 'customer_delivered_email',
314
  'type' => 'checkbox'
@@ -316,41 +338,39 @@ class wcast_initialise_customizer_email {
316
  );
317
 
318
  // Display Shipment Provider image/thumbnail
319
- $wp_customize->add_setting( 'wcast_show_shipping_address',
320
  array(
321
- 'default' => $this->defaults['wcast_show_shipping_address'],
322
  'transport' => 'refresh',
323
  'sanitize_callback' => ''
324
  )
325
  );
326
- $wp_customize->add_control( 'wcast_show_shipping_address',
327
  array(
328
- 'label' => __( 'Show shipping address', 'woo-advanced-shipment-tracking' ),
329
  'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
330
  'section' => 'customer_delivered_email',
331
  'type' => 'checkbox'
332
  )
333
  );
334
-
335
- // Test of TinyMCE control
336
- $wp_customize->add_setting( 'wcast_delivered_email_content',
337
  array(
338
- 'default' => $this->defaults['wcast_delivered_email_content'],
339
  'transport' => 'refresh',
340
- 'sanitize_callback' => 'wp_kses_post'
341
  )
342
  );
343
- $wp_customize->add_control( new Skyrocket_TinyMCE_Custom_control( $wp_customize, 'wcast_delivered_email_content',
344
  array(
345
- 'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
346
- 'description' => __( '', 'woo-advanced-shipment-tracking' ),
347
  'section' => 'customer_delivered_email',
348
- 'input_attrs' => array(
349
- 'toolbar1' => 'bold italic bullist numlist alignleft aligncenter alignright link',
350
- 'mediaButtons' => true,
351
- )
352
  )
353
- ) );
 
354
 
355
  $wp_customize->add_setting( 'wcast_delivered_analytics_link',
356
  array(
@@ -362,7 +382,7 @@ class wcast_initialise_customizer_email {
362
  $wp_customize->add_control( 'wcast_delivered_analytics_link',
363
  array(
364
  'label' => __( 'Google Analytics link tracking', 'woo-advanced-shipment-tracking' ),
365
- 'description' => esc_html__( 'This will be appended to URL in the email content', 'woo-advanced-shipment-tracking' ),
366
  'section' => 'customer_delivered_email',
367
  'type' => 'text',
368
  'input_attrs' => array(
208
  );
209
  $wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[recipient]',
210
  array(
211
+ 'label' => __( 'Receipts', 'woo-advanced-shipment-tracking' ),
212
+ 'description' => esc_html__( 'Enter emails use variables such as {customer_email}. Multiple emails can be separated by commas.', 'woo-advanced-shipment-tracking' ),
213
  'section' => 'customer_delivered_email',
214
  'type' => 'text',
215
  'input_attrs' => array(
232
  $wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[subject]',
233
  array(
234
  'label' => __( 'Email subject', 'woo-advanced-shipment-tracking' ),
235
+ 'description' => esc_html__( 'Available variables: {site_title}, {order_number}', 'woo-advanced-shipment-tracking' ),
236
  'section' => 'customer_delivered_email',
237
  'type' => 'text',
238
  'input_attrs' => array(
255
  $wp_customize->add_control( 'woocommerce_customer_delivered_order_settings[heading]',
256
  array(
257
  'label' => __( 'Email heading', 'woo-advanced-shipment-tracking' ),
258
+ 'description' => esc_html__( 'Available variables: {site_title}, {order_number}', 'woo-advanced-shipment-tracking' ),
259
  'section' => 'customer_delivered_email',
260
  'type' => 'text',
261
  'input_attrs' => array(
266
  )
267
  );
268
 
269
+
270
+ // Test of TinyMCE control
271
+ $wp_customize->add_setting( 'wcast_delivered_email_content',
272
+ array(
273
+ 'default' => $this->defaults['wcast_delivered_email_content'],
274
+ 'transport' => 'refresh',
275
+ 'sanitize_callback' => 'wp_kses_post'
276
+ )
277
+ );
278
+ $wp_customize->add_control( new Skyrocket_TinyMCE_Custom_control( $wp_customize, 'wcast_delivered_email_content',
279
+ array(
280
+ 'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
281
+ 'description' => __( 'available variables: {site_title}, {customer_email}, {customer_first_name}, {customer_last_name}, {customer_username}, {order_number}', 'woo-advanced-shipment-tracking' ),
282
+ 'section' => 'customer_delivered_email',
283
+ 'input_attrs' => array(
284
+ 'toolbar1' => 'bold italic bullist numlist alignleft aligncenter alignright link',
285
+ 'mediaButtons' => true,
286
+ )
287
+ )
288
+ ) );
289
+
290
  // Display Shipment Provider image/thumbnail
291
  $wp_customize->add_setting( 'wcast_show_tracking_details',
292
  array(
297
  );
298
  $wp_customize->add_control( 'wcast_show_tracking_details',
299
  array(
300
+ 'label' => __( 'Display tracking details', 'woo-advanced-shipment-tracking' ),
301
  'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
302
  'section' => 'customer_delivered_email',
303
  'type' => 'checkbox'
313
  );
314
  $wp_customize->add_control( 'wcast_show_order_details',
315
  array(
316
+ 'label' => __( 'Display order details', 'woo-advanced-shipment-tracking' ),
317
  'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
318
  'section' => 'customer_delivered_email',
319
  'type' => 'checkbox'
320
  )
321
  );
322
+
323
  // Display Shipment Provider image/thumbnail
324
+ $wp_customize->add_setting( 'wcast_show_shipping_address',
325
  array(
326
+ 'default' => $this->defaults['wcast_show_shipping_address'],
327
  'transport' => 'refresh',
328
  'sanitize_callback' => ''
329
  )
330
  );
331
+ $wp_customize->add_control( 'wcast_show_shipping_address',
332
  array(
333
+ 'label' => __( 'Display Shipping Address', 'woo-advanced-shipment-tracking' ),
334
  'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
335
  'section' => 'customer_delivered_email',
336
  'type' => 'checkbox'
338
  );
339
 
340
  // Display Shipment Provider image/thumbnail
341
+ $wp_customize->add_setting( 'wcast_show_billing_address',
342
  array(
343
+ 'default' => $this->defaults['wcast_show_billing_address'],
344
  'transport' => 'refresh',
345
  'sanitize_callback' => ''
346
  )
347
  );
348
+ $wp_customize->add_control( 'wcast_show_billing_address',
349
  array(
350
+ 'label' => __( 'Display Billing Address', 'woo-advanced-shipment-tracking' ),
351
  'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
352
  'section' => 'customer_delivered_email',
353
  'type' => 'checkbox'
354
  )
355
  );
356
+
357
+ // Display Shipment Provider image/thumbnail
358
+ $wp_customize->add_setting( 'wcast_enable_delivered_ga_tracking',
359
  array(
360
+ 'default' => '',
361
  'transport' => 'refresh',
362
+ 'sanitize_callback' => ''
363
  )
364
  );
365
+ $wp_customize->add_control( 'wcast_enable_delivered_ga_tracking',
366
  array(
367
+ 'label' => __( 'Enable Google Analytics tracking', 'woo-advanced-shipment-tracking' ),
368
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
369
  'section' => 'customer_delivered_email',
370
+ 'type' => 'checkbox'
 
 
 
371
  )
372
+ );
373
+
374
 
375
  $wp_customize->add_setting( 'wcast_delivered_analytics_link',
376
  array(
382
  $wp_customize->add_control( 'wcast_delivered_analytics_link',
383
  array(
384
  'label' => __( 'Google Analytics link tracking', 'woo-advanced-shipment-tracking' ),
385
+ 'description' => esc_html__( 'This will be appended to URL in the email content – e.g. utm_source=ast&utm_medium=email&utm_campaign=delivered', 'woo-advanced-shipment-tracking' ),
386
  'section' => 'customer_delivered_email',
387
  'type' => 'text',
388
  'input_attrs' => array(
includes/emails/class-shipment-delivered-email.php CHANGED
@@ -141,9 +141,10 @@ if ( ! class_exists( 'WC_Email_Customer_Delivered_Order', false ) ) :
141
 
142
  $message = wc_advanced_shipment_tracking_email_class()->email_content($email_content,$order_id,$order);
143
 
 
144
  $wcast_delivered_analytics_link = get_theme_mod('wcast_delivered_analytics_link');
145
 
146
- if($wcast_delivered_analytics_link){
147
  $regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
148
  $message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
149
  }
141
 
142
  $message = wc_advanced_shipment_tracking_email_class()->email_content($email_content,$order_id,$order);
143
 
144
+ $wcast_enable_delivered_ga_tracking = get_theme_mod('wcast_enable_delivered_ga_tracking');
145
  $wcast_delivered_analytics_link = get_theme_mod('wcast_delivered_analytics_link');
146
 
147
+ if($wcast_delivered_analytics_link && $wcast_enable_delivered_ga_tracking == 1){
148
  $regex = '#(<a href=")([^"]*)("[^>]*?>)#i';
149
  $message = preg_replace_callback($regex, array( $this, '_appendCampaignToString'), $message);
150
  }
includes/views/admin_options_bulk_upload.php CHANGED
@@ -33,7 +33,7 @@
33
  <hr>
34
  <p><?php _e('You can download an example of the csv file:', 'woo-advanced-shipment-tracking'); ?></p>
35
  <a class="button-primary btn_green2" href="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>/assets/tracking.csv"><?php _e('Download sample csv file', 'woo-advanced-shipment-tracking'); ?></a>
36
- <!--p><?php _e('For detailed instructions on how to upload tracking info in bulk, see our', 'woo-advanced-shipment-tracking'); ?> <a class="" href="https://www.zorem.com/docs/woocommerce-advanced-shipment-tracking/bulk-import-shipment-tracking/" target="blank"><?php _e('documentation', 'woo-advanced-shipment-tracking'); ?></a></p-->
37
  <div id="p1" class="mdl-progress mdl-js-progress" style="display:none;"></div>
38
  <h3 class="progress_title" style="display:none;"><?php _e('Upload Progress - ', 'woo-advanced-shipment-tracking'); ?><span class="progress_number"></span></h3>
39
  <ol class="csv_upload_status">
33
  <hr>
34
  <p><?php _e('You can download an example of the csv file:', 'woo-advanced-shipment-tracking'); ?></p>
35
  <a class="button-primary btn_green2" href="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>/assets/tracking.csv"><?php _e('Download sample csv file', 'woo-advanced-shipment-tracking'); ?></a>
36
+ <p><?php _e('For detailed instructions on how to upload tracking info in bulk, see our', 'woo-advanced-shipment-tracking'); ?> <a class="" href="https://www.zorem.com/docs/woocommerce-advanced-shipment-tracking/bulk-import-shipment-tracking/" target="blank"><?php _e('documentation', 'woo-advanced-shipment-tracking'); ?></a>.</p>
37
  <div id="p1" class="mdl-progress mdl-js-progress" style="display:none;"></div>
38
  <h3 class="progress_title" style="display:none;"><?php _e('Upload Progress - ', 'woo-advanced-shipment-tracking'); ?><span class="progress_number"></span></h3>
39
  <ol class="csv_upload_status">
includes/views/admin_options_settings (Eran Shor's conflicted copy 2019-08-07).php DELETED
@@ -1,34 +0,0 @@
1
- <section id="content2" class="tab_section">
2
- <div class="tab_inner_container">
3
- <form method="post" id="wc_ast_settings_form" action="" enctype="multipart/form-data">
4
- <?php #nonce?>
5
-
6
- <input id="tab9" type="radio" name="pagetabs" class="tab_input_1" checked>
7
- <label for="tab9"><?php _e( 'General', 'woo-advanced-shipment-tracking' ); ?></label>
8
- <span style="margin: 0 3px;">|</span>
9
- <input id="tab10" type="radio" class="tab_input_1" name="pagetabs" <?php if(isset($_GET['tab']) && $_GET['tab'] == 'delivered-order-status'){ echo 'checked'; } ?>>
10
- <label for="tab10"><?php _e( 'Delivered Order Status', 'woo-advanced-shipment-tracking' ); ?></label>
11
- <span style="margin: 0 3px;">|</span>
12
- <label style="vertical-align: top;"><a style="text-decoration: none;" href="<?php echo wcast_initialise_customizer_settings::get_customizer_url('default_controls_section','settings') ?>" class=""><?php _e( 'Tracking Info Display Designer', 'woo-advanced-shipment-tracking' ); ?> <span class="dashicons dashicons-welcome-view-site"></span> </a></label>
13
- <br class="clear">
14
- <section id="content9" class="tpage_section">
15
- <h3><?php _e( 'General Settings', 'woo-advanced-shipment-tracking' ); ?></h3>
16
- <?php $this->get_html( $this->get_settings_data() );?>
17
- </section>
18
- <section id="content10" class="tpage_section">
19
- <h3><?php _e( 'Delivered Order Status', 'woo-advanced-shipment-tracking' ); ?></h3>
20
- <?php $this->get_html( $this->get_delivered_data() );?>
21
- <p><?php echo sprintf(__('<strong>PLEASE NOTE</strong> - If you use the custom order status "Delivered", when you deactivate the plugin, you must register this order status in function.php in order to see these orders in the orders admin. You can find the <a href="%s" target="blank">snippet</a> to use in functions.php here or you can manually change all your "delivered" order to "completed" before deactivating the plugin.', 'woo-advanced-shipment-tracking'), 'https://gist.github.com/zorem/6f09162fe91eab180a76a621ce523441'); ?></p>
22
- </section>
23
- <div class="submit">
24
- <button name="save" class="button-primary woocommerce-save-button btn_green" type="submit" value="Save changes"><?php _e( 'Save', 'woo-advanced-shipment-tracking' ); ?></button>
25
- <div class="spinner" style="float:none"></div>
26
- <div class="success_msg" style="display:none;"><?php _e( 'Data saved successfully.', 'woo-advanced-shipment-tracking' ); ?></div>
27
- <div class="error_msg" style="display:none;"></div>
28
- <?php wp_nonce_field( 'wc_ast_settings_form', 'wc_ast_settings_form' );?>
29
- <input type="hidden" name="action" value="wc_ast_settings_form_update">
30
- </div>
31
- </form>
32
- </div>
33
- <?php include 'zorem_admin_sidebar.php';?>
34
- </section>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/views/admin_options_shipping_provider.php CHANGED
@@ -13,10 +13,8 @@
13
  <span class="dashicons dashicons-admin-generic dropdown_menu"></span>
14
  </div>
15
  <ul class="dropdown-content">
16
- <li><a href="javaScript:void(0);" class="add_custom_provider" id="add-custom">Add Custom Provider</a></li>
17
- <?php if($wc_ast_api_key){ ?>
18
- <li><a href="javaScript:void(0);" class="sync_providers">Sync Provider List</a></li>
19
- <?php } ?>
20
  <li>Reset <a href="javaScript:void(0);" class="reset_active">active</a> | <a href="javaScript:void(0);" class="reset_inactive">inactive</a></li>
21
  </ul>
22
  <div class="search_section">
13
  <span class="dashicons dashicons-admin-generic dropdown_menu"></span>
14
  </div>
15
  <ul class="dropdown-content">
16
+ <li><a href="javaScript:void(0);" class="add_custom_provider" id="add-custom">Add Custom Provider</a></li>
17
+ <li><a href="javaScript:void(0);" class="sync_providers">Sync Provider List</a></li>
 
 
18
  <li>Reset <a href="javaScript:void(0);" class="reset_active">active</a> | <a href="javaScript:void(0);" class="reset_inactive">inactive</a></li>
19
  </ul>
20
  <div class="search_section">
readme.txt CHANGED
@@ -12,20 +12,22 @@ Add shipment tracking information to your WooCommerce orders and provide your cu
12
 
13
  == Description ==
14
 
15
- Add shipment tracking information to your WooCommerce orders and provide your customers with an easy way to track their orders. This plugin provides a list of 100+ Shipping Providers and you can also add your own custom providers.
16
 
17
- Shop managers can add shipment provider, tracking number and date to orders, the customer will receive tracking info and track link in the orders email and in Customer accounts.
18
 
19
- Use WooCommerce Advanced Shipment Tracking to streamline your order management, add shipment tracking information to orders, auto track orders ([TracksShip](https://trackship.info/)) and provide superior post-purchase experience that your customers will love and appreciate!
20
 
21
  == Features ==
22
 
23
- * Add shipment tracking info to orders – Shipping provider, tracking number and ship date.
24
  * Add multiple tracking numbers to orders
25
- * List of more then 100 shipping providers (carriers)
 
26
  * Select shipping providers to use when adding tracking info to orders
27
  * Set the default provider when adding tracking info to orders
28
  * Add custom shipping providers
 
29
  * Display Shipment tracking info and tracking link on user accounts
30
  * Display Shipment tracking info and tracking link on customer emails
31
  * Customize and preview the Tracking info display on customer emails using email designer.
@@ -39,7 +41,17 @@ Use WooCommerce Advanced Shipment Tracking to streamline your order management,
39
 
40
  == TrackShip Integration==
41
 
42
- Auto-track all your WooCommerce shipments with [TracksShip](https://trackship.info/). Get real-time shipment updates and automate your order management flow to increase your customers satisfaction and further engage customers.
 
 
 
 
 
 
 
 
 
 
43
 
44
  == Localization ==
45
 
@@ -64,7 +76,7 @@ Hebrew, Hindi, Italian, Norwegian (Bokmål), Russian, Swedish, Turkish, Bulgaria
64
  * [WooCommerce PDF Invoices & Packing Slips plugin](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips).
65
 
66
 
67
- https://www.youtube.com/watch?v=sQc2kVnUL-o&t=2s
68
 
69
  == Frequently Asked Questions ==
70
 
@@ -106,6 +118,49 @@ http://a32694-tmp.s415.upress.link/wp-json/wc/v1/orders/<order-id>/shipment-trac
106
 
107
  == Changelog ==
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  = 2.3.8 =
110
  * Fixed - Trackship connection issue when trackship setting saved
111
 
12
 
13
  == Description ==
14
 
15
+ Add shipment tracking information to your WooCommerce orders and provide your customers with an easy way to track their orders.
16
 
17
+ This plugin provide Shop managers easy ways to add shipment tracking information to order, once the order is Completed (Shipped) the customer will receive the tracking details and a link to tracker their order in the order emails and on my account section.
18
 
19
+ AST provide a list of 100+ shipping providers with pre-set tracking link and image, you can add your own custom provider, customize the tracking display, created delivered order status, customize the emails and more.
20
 
21
  == Features ==
22
 
23
+ * Add shipment tracking info to orders – shipping provider, tracking number and shipping date
24
  * Add multiple tracking numbers to orders
25
+ * Add tracking info to orders from the orders admin (inline)
26
+ * List of 100+ default shipping providers (carriers)
27
  * Select shipping providers to use when adding tracking info to orders
28
  * Set the default provider when adding tracking info to orders
29
  * Add custom shipping providers
30
+ * Sync the Providers list with TrackShip
31
  * Display Shipment tracking info and tracking link on user accounts
32
  * Display Shipment tracking info and tracking link on customer emails
33
  * Customize and preview the Tracking info display on customer emails using email designer.
41
 
42
  == TrackShip Integration==
43
 
44
+ [TracksShip](https://trackship.info/) is a premium shipment tracking API flatform that fully integrates with WooCommerce with the Advanced Shipment Tracking. TrackShip automates the order management workflows, reduces customer inquiries, reduces time spent on customer service, and improves the post-purchase experience and satisfaction of your customers.
45
+
46
+ You must have account [TracksShip](https://trackship.info/) and connect your store in order to activate these advanced features:
47
+
48
+ * Automatically track your shipments with 100+ shipping providers.
49
+ * Display Shipment Status and latest shipment status, update date and est. delivery date on WooCommerce orders admin.
50
+ * Option to manually get shipment tracking updates for orders.
51
+ * Automatically change order status to Delivered once the shipment is delivered to your customers.
52
+ * Option to filter orders with invalid tracking numbers or by shipment status event in orders admin
53
+ * Send personalized emails to notify the customer when their shipments are In Transit, Out For Delivery, Delivered or have an exception.
54
+ * Direct customers to a Tracking page on your store.
55
 
56
  == Localization ==
57
 
76
  * [WooCommerce PDF Invoices & Packing Slips plugin](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips).
77
 
78
 
79
+ https://www.youtube.com/watch?v=Mw7laecPtyw
80
 
81
  == Frequently Asked Questions ==
82
 
118
 
119
  == Changelog ==
120
 
121
+ = 2.4.4 =
122
+ * Fixed PHP Notice: Undefined index: DHL uk in plugins\woo-advanced-shipment-tracking\includes\class-wc-advanced-shipment-tracking-install.php on line 1560
123
+ * Fixed - If Delivered Status is not enabled - do not change order status "Delivered" or to any other status (Pending right now)
124
+ * Updated html class of add tracking provider lightbox in orders listing page
125
+ * Updated - remove event grouping by status to display all events in trackship tracking page
126
+ * Added - limit bulk action Get Shipment Status to maximum 100 orders at one time
127
+ * Added description on select tracking page field
128
+
129
+ = 2.4.3 =
130
+ * Fixed issue with TranslatePress plugin
131
+ * Fixed issue in tracking page
132
+ * Fixed issue if ts_slug field not created in database
133
+ * Added compatibility with WP-Lister for eBay
134
+ * Added hook for order number in tracking page
135
+
136
+ = 2.4.2 =
137
+ * Fixed issue in tracking page for unknown status
138
+ * Added PostNL International 3S,GLS Europe and Yun Express Tracking provider
139
+ * In tracking url added two more parameter - %country_code% and %postal_code%
140
+ * Updated code for add tracking item programatically
141
+ * Updated tracking page endpoint
142
+ * Removed Tracking URL validation for add/edit custom shiping provider and if not added tracking url than not display track button
143
+
144
+ = 2.4.1 =
145
+ * Fixed Hermes World shipping provider issue
146
+ * Fixed warnings Undefined index: Hermes Germany
147
+ * Updated completed order status to shipped on "On which customer order status email to include tracking info?" is "Rename the “Completed” Order status to “Shipped”" enabled
148
+
149
+ = 2.4 =
150
+ * Fixed warnings in tracking page
151
+ * Fixed error from customizer if WooCommerce uninstalled
152
+ * Fixed date format issue in Bulk Upload
153
+ * Addes Sync Providers List functionality for all users
154
+ * Added Hermes World Shipping provider
155
+ * Added option for "mark as shipped" will be selected by default when adding tracking info to orders
156
+ * Added Shipment Status filter in order list panel
157
+ * Updated Delivered orderemail customizer layout and Google analytics tracking
158
+ * Updated tracking page design
159
+
160
+ = 2.3.9 =
161
+ * Added "DHL Freight" provider
162
+ * Added functionality when check connection store status if api key is not available in plugin than add it
163
+
164
  = 2.3.8 =
165
  * Fixed - Trackship connection issue when trackship setting saved
166
 
templates/emails/tracking-info.php CHANGED
@@ -105,7 +105,7 @@ if ( $tracking_items ) :
105
  </thead>
106
 
107
  <tbody><?php
108
- foreach ( $tracking_items as $tracking_item ) {
109
  ?><tr class="tracking">
110
  <td class="tracking-provider" data-title="<?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
111
  <?php
@@ -114,7 +114,7 @@ if ( $tracking_items ) :
114
  $shippment_provider = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE provider_name='".$tracking_item['formatted_tracking_provider']."'" );
115
  $custom_thumb_id = $shippment_provider['0']->custom_thumb_id;
116
  //echo $custom_thumb_id;
117
- if($custom_thumb_id == 0){
118
  $src = wc_advanced_shipment_tracking()->plugin_dir_url()."assets/shipment-provider-img/".sanitize_title($tracking_item['formatted_tracking_provider']).".png";
119
  } else{
120
  $image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array('60','60') );
@@ -147,8 +147,10 @@ if ( $tracking_items ) :
147
  } ?>
148
 
149
  <td class="order-actions" style="<?php echo $td_column_style; ?>">
150
- <?php $url = str_replace('%number%',$tracking_item['tracking_number'],$tracking_item['formatted_tracking_link']); ?>
151
- <a href="<?php echo esc_url( $url ); ?>" style="<?php echo $tracking_link_style; ?>" target="_blank"><?php _e( 'Track', 'woo-advanced-shipment-tracking' ); ?></a>
 
 
152
  </td>
153
  </tr><?php
154
  }
105
  </thead>
106
 
107
  <tbody><?php
108
+ foreach ( $tracking_items as $tracking_item ) {
109
  ?><tr class="tracking">
110
  <td class="tracking-provider" data-title="<?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
111
  <?php
114
  $shippment_provider = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE provider_name='".$tracking_item['formatted_tracking_provider']."'" );
115
  $custom_thumb_id = $shippment_provider['0']->custom_thumb_id;
116
  //echo $custom_thumb_id;
117
+ if($custom_thumb_id == 0 && $shippment_provider['0']->shipping_default == 1){
118
  $src = wc_advanced_shipment_tracking()->plugin_dir_url()."assets/shipment-provider-img/".sanitize_title($tracking_item['formatted_tracking_provider']).".png";
119
  } else{
120
  $image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array('60','60') );
147
  } ?>
148
 
149
  <td class="order-actions" style="<?php echo $td_column_style; ?>">
150
+ <?php if($tracking_item['formatted_tracking_link']){ ?>
151
+ <?php $url = str_replace('%number%',$tracking_item['tracking_number'],$tracking_item['formatted_tracking_link']); ?>
152
+ <a href="<?php echo esc_url( $url ); ?>" style="<?php echo $tracking_link_style; ?>" target="_blank"><?php _e( 'Track', 'woo-advanced-shipment-tracking' ); ?></a>
153
+ <?php } ?>
154
  </td>
155
  </tr><?php
156
  }
templates/myaccount/view-order.php CHANGED
@@ -94,7 +94,7 @@ if ( $tracking_items ) :
94
  $shippment_provider = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE provider_name='".$tracking_item['formatted_tracking_provider']."'" );
95
  $custom_thumb_id = $shippment_provider['0']->custom_thumb_id;
96
  //echo $custom_thumb_id;
97
- if($custom_thumb_id == 0){
98
  $src = wc_advanced_shipment_tracking()->plugin_dir_url()."assets/shipment-provider-img/".sanitize_title($tracking_item['formatted_tracking_provider']).".png";
99
  } else{
100
  $image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array('60','60') );
94
  $shippment_provider = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE provider_name='".$tracking_item['formatted_tracking_provider']."'" );
95
  $custom_thumb_id = $shippment_provider['0']->custom_thumb_id;
96
  //echo $custom_thumb_id;
97
+ if($custom_thumb_id == 0 && $shippment_provider['0']->shipping_default == 1){
98
  $src = wc_advanced_shipment_tracking()->plugin_dir_url()."assets/shipment-provider-img/".sanitize_title($tracking_item['formatted_tracking_provider']).".png";
99
  } else{
100
  $image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array('60','60') );
woocommerce-advanced-shipment-tracking.php CHANGED
@@ -4,14 +4,14 @@
4
  * Plugin Name: Advanced Shipment Tracking for WooCommerce
5
  * Plugin URI:
6
  * Description: Add shipment tracking information to your WooCommerce orders and provide customers with an easy way to track their orders. Shipment tracking Info will appear in customers accounts (in the order panel) and in WooCommerce order complete email.
7
- * Version: 2.3.8
8
  * Author: zorem
9
  * Author URI:
10
  * License: GPL-2.0+
11
  * License URI:
12
  * Text Domain: woo-advanced-shipment-tracking
13
  * Domain Path: /lang/
14
- * WC tested up to: 3.6.5
15
  */
16
 
17
 
@@ -22,7 +22,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
22
  *
23
  * @var string
24
  */
25
- public $version = '2.3.8';
26
 
27
  /**
28
  * Initialize the main plugin function
@@ -51,7 +51,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
51
  $this->table = $wpdb->prefix."woo_shippment_provider";
52
  }
53
 
54
- add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) );
55
 
56
  if ( $this->is_wc_active() ) {
57
  // Include required files.
@@ -68,6 +68,8 @@ class zorem_woocommerce_advanced_shipment_tracking {
68
 
69
  //plugin install class init
70
  $this->install->init();
 
 
71
  }
72
  add_action( 'admin_footer', array( $this, 'uninstall_notice') );
73
  //register_deactivation_hook( __FILE__, array( $this, 'uninstall' ) );
@@ -321,12 +323,12 @@ class zorem_woocommerce_advanced_shipment_tracking {
321
  WC()->api->WC_Advanced_Shipment_Tracking_REST_API_Controller->register_routes();
322
 
323
  }
324
- public function on_plugins_loaded() {
325
- require_once $this->get_plugin_path() . '/includes/customizer/class-wcast-customizer.php';
326
 
327
- require_once $this->get_plugin_path() . '/includes/customizer/class-wc-tracking-info-customizer.php';
328
 
329
- //require_once $this->get_plugin_path() . '/includes/customizer/class-wc-tracking-page-customizer.php';
330
 
331
  require_once $this->get_plugin_path() . '/includes/customizer/class-wc-email-customizer.php';
332
 
4
  * Plugin Name: Advanced Shipment Tracking for WooCommerce
5
  * Plugin URI:
6
  * Description: Add shipment tracking information to your WooCommerce orders and provide customers with an easy way to track their orders. Shipment tracking Info will appear in customers accounts (in the order panel) and in WooCommerce order complete email.
7
+ * Version: 2.4.4
8
  * Author: zorem
9
  * Author URI:
10
  * License: GPL-2.0+
11
  * License URI:
12
  * Text Domain: woo-advanced-shipment-tracking
13
  * Domain Path: /lang/
14
+ * WC tested up to: 3.7
15
  */
16
 
17
 
22
  *
23
  * @var string
24
  */
25
+ public $version = '2.4.4';
26
 
27
  /**
28
  * Initialize the main plugin function
51
  $this->table = $wpdb->prefix."woo_shippment_provider";
52
  }
53
 
54
+
55
 
56
  if ( $this->is_wc_active() ) {
57
  // Include required files.
68
 
69
  //plugin install class init
70
  $this->install->init();
71
+
72
+ add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) );
73
  }
74
  add_action( 'admin_footer', array( $this, 'uninstall_notice') );
75
  //register_deactivation_hook( __FILE__, array( $this, 'uninstall' ) );
323
  WC()->api->WC_Advanced_Shipment_Tracking_REST_API_Controller->register_routes();
324
 
325
  }
326
+ public function on_plugins_loaded() {
327
+ require_once $this->get_plugin_path() . '/includes/email-manager.php';
328
 
329
+ require_once $this->get_plugin_path() . '/includes/customizer/class-wcast-customizer.php';
330
 
331
+ require_once $this->get_plugin_path() . '/includes/customizer/class-wc-tracking-info-customizer.php';
332
 
333
  require_once $this->get_plugin_path() . '/includes/customizer/class-wc-email-customizer.php';
334