Advanced Shipment Tracking for WooCommerce - Version 2.9.9.2

Version Description

  • Fix - Fatal error: Uncaught Error: Call to a member function get() on null in /home/jh1ua38qa95m/public_html/store/wp-includes/query.php:28 Stack trace: woo-advanced-shipment-tracking/includes/class-wc-advanced-shipment-tracking-settings.php(444)
Download this release

Release Info

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

Code changes from version 2.9.6 to 2.9.9.2

Files changed (31) hide show
  1. assets/css/admin.css +32 -18
  2. assets/css/customizer-styles.css +9 -0
  3. assets/css/icons/shipped-o.png +0 -0
  4. assets/js/admin.js +17 -8
  5. assets/js/customizer-scripts.js +13 -0
  6. assets/js/settings.js +27 -0
  7. assets/shipment-provider-img/dai-post (Hitesh Patel's conflicted copy 2020-04-27).png +0 -0
  8. assets/shipment-provider-img/dawn-wing.png +0 -0
  9. assets/shipment-provider-img/mrw (Hitesh Patel's conflicted copy 2020-04-27).png +0 -0
  10. assets/shipment-provider-img/nacex (Hitesh Patel's conflicted copy 2020-04-27).png +0 -0
  11. assets/shipment-provider-img/shree-maruti-courier (Hitesh Patel's conflicted copy 2020-04-27).png +0 -0
  12. assets/shipment-provider-img/ubi-smart-parcel.png +0 -0
  13. includes/class-wc-advanced-shipment-tracking-admin.php +323 -36
  14. includes/class-wc-advanced-shipment-tracking-front.php +20 -1
  15. includes/class-wc-advanced-shipment-tracking-install.php +40 -2
  16. includes/class-wc-advanced-shipment-tracking-settings.php +258 -17
  17. includes/class-wc-advanced-shipment-tracking.php +129 -50
  18. includes/customizer/class-wc-shipped-email-customizer.php +430 -0
  19. includes/customizer/class-wcast-customizer.php +22 -1
  20. includes/customizer/preview/shipped_preview.php +30 -0
  21. includes/email-manager.php +6 -0
  22. includes/emails/class-shipment-delivered-email.php +4 -5
  23. includes/emails/class-shipment-shipped-email.php +184 -0
  24. includes/views/admin_options_settings.php +40 -3
  25. includes/views/admin_trackship_dashboard.php +16 -29
  26. includes/views/zorem_admin_sidebar.php +23 -26
  27. readme.txt +30 -1
  28. templates/emails/customer-shipped-order.php +85 -0
  29. templates/emails/tracking-info.php +4 -4
  30. templates/myaccount/tracking-info.php +5 -5
  31. woocommerce-advanced-shipment-tracking.php +20 -3
assets/css/admin.css CHANGED
@@ -194,8 +194,7 @@ input.tab_input_1:checked + label{
194
  padding: 0 0 10px;
195
  }
196
  .zorem_admin_layout .zorem_admin_sidebar h3.top-border{
197
- padding: 10px 0 10px;
198
- border-top: 1px solid #eee;
199
  }
200
  .zorem_admin_layout .zorem_admin_sidebar p,.zorem_admin_layout .zorem_admin_sidebar a{
201
  margin: 0px 10px 0 0;
@@ -274,6 +273,17 @@ input.tab_input_1:checked + label{
274
  .ast_admin_content .form-table th.titledesc {
275
  width: 40%;
276
  }
 
 
 
 
 
 
 
 
 
 
 
277
  .woocommerce .ast_admin_content table.form-table th label .woocommerce-help-tip{
278
  margin: -4px 0 0 5px;
279
  position: relative;
@@ -293,7 +303,7 @@ input.tab_input_1:checked + label{
293
  .ast_admin_content .form-table .wp-color-result.button {
294
  margin: 0 6px 0px 0;
295
  }
296
- #wc_ast_status_label_color,#wc_ast_status_partial_shipped_label_color,#wc_ast_status_updated_tracking_label_color,#wc_ast_select_primary_color,#wc_ast_select_border_color {
297
  width: 80px;
298
  }
299
  .color_field input[type=text] {
@@ -440,6 +450,12 @@ thead .mdl-list__item-secondary-action {
440
  }
441
  #wc_ast_settings_form .form-table tr:first-child,#wc_ast_trackship_form .form-table tr:first-child,#wc_ast_upload_csv_form .form-table tr:first-child,#wc_ast_addons_form .form-table tr:first-child{
442
  border-top: 1px solid #eee;
 
 
 
 
 
 
443
  }
444
  #wc_ast_settings_form .form-table tr.multiple_checkbox_title_tr{
445
  border-bottom: 0;
@@ -450,17 +466,13 @@ thead .mdl-list__item-secondary-action {
450
  input#wc_ast_api_key {
451
  width: 260px;
452
  }
453
- span.api_connected {
454
- color: #fff;
455
- line-height: 33px;
456
- background: #83bd31;
457
- padding: 12px 26px;
458
- font-size: 15px;
459
- border-radius: 5px;
460
  }
461
- span.api_connected .dashicons.dashicons-yes {
462
- font-size: 30px;
463
- line-height: 33px;
464
  }
465
  .ac-container {
466
  margin: 0 auto 30px auto;
@@ -1412,7 +1424,7 @@ p.delivered_message {
1412
  border: 0;
1413
  background: #fafeff;
1414
  }
1415
- #wc_ast_settings_form table.form-table.heading-table tr,#wc_ast_trackship_form table.form-table.heading-table tr,#wc_ast_upload_csv_form table.form-table.heading-table tr{
1416
  border-bottom: 0;
1417
  }
1418
  .woocommerce.zorem_admin_layout table.form-table.heading-table td{
@@ -1444,6 +1456,12 @@ p.delivered_message {
1444
  .woocommerce.zorem_admin_layout table.form-table th{
1445
  padding: 20px 24px 20px 15px;
1446
  }
 
 
 
 
 
 
1447
  .woocommerce.zorem_admin_layout table.form-table td{
1448
  padding: 15px 15px;
1449
  }
@@ -1932,10 +1950,6 @@ span.tracking_product_list {
1932
  .order-status-table tr td.status-label-column{
1933
  width:130px;
1934
  }
1935
- .form-table .multiple_checkbox {
1936
- display: inline-block;
1937
- padding-right: 20px;
1938
- }
1939
  .order-status-table .wp-picker-container,.tracking_page_table .wp-picker-container {
1940
  display: inline-block;
1941
  vertical-align: middle;
194
  padding: 0 0 10px;
195
  }
196
  .zorem_admin_layout .zorem_admin_sidebar h3.top-border{
197
+ padding: 10px 0 10px;
 
198
  }
199
  .zorem_admin_layout .zorem_admin_sidebar p,.zorem_admin_layout .zorem_admin_sidebar a{
200
  margin: 0px 10px 0 0;
273
  .ast_admin_content .form-table th.titledesc {
274
  width: 40%;
275
  }
276
+ .ast_admin_content .form-table.table-layout-2 th.titledesc {
277
+ width: 2.5%;
278
+ border-right:1px solid #eee;
279
+ }
280
+ .ast_admin_content .trackship_status_section .form-table th.titledesc{
281
+ width: 20%;
282
+ padding: 10px 24px 10px 15px;
283
+ }
284
+ .woocommerce.zorem_admin_layout .trackship_status_section table.form-table td {
285
+ padding: 10px 15px;
286
+ }
287
  .woocommerce .ast_admin_content table.form-table th label .woocommerce-help-tip{
288
  margin: -4px 0 0 5px;
289
  position: relative;
303
  .ast_admin_content .form-table .wp-color-result.button {
304
  margin: 0 6px 0px 0;
305
  }
306
+ #wc_ast_status_label_color,#wc_ast_status_partial_shipped_label_color,#wc_ast_status_updated_tracking_label_color,#wc_ast_select_primary_color,#wc_ast_select_border_color,#wc_ast_shipped_status_label_color {
307
  width: 80px;
308
  }
309
  .color_field input[type=text] {
450
  }
451
  #wc_ast_settings_form .form-table tr:first-child,#wc_ast_trackship_form .form-table tr:first-child,#wc_ast_upload_csv_form .form-table tr:first-child,#wc_ast_addons_form .form-table tr:first-child{
452
  border-top: 1px solid #eee;
453
+ }
454
+ #wc_ast_trackship_form .trackship_status_section .form-table tr{
455
+ border-bottom: 0;
456
+ }
457
+ #wc_ast_trackship_form .trackship_status_section .form-table tr:nth-last-child(2) {
458
+ border-bottom: 1px solid #eee;
459
  }
460
  #wc_ast_settings_form .form-table tr.multiple_checkbox_title_tr{
461
  border-bottom: 0;
466
  input#wc_ast_api_key {
467
  width: 260px;
468
  }
469
+ .api_connected {
470
+ color: #83bd31;
471
+ text-decoration:none;
 
 
 
 
472
  }
473
+ .api_connected .dashicons{
474
+ height: 18px;
475
+ width: 18px;
476
  }
477
  .ac-container {
478
  margin: 0 auto 30px auto;
1424
  border: 0;
1425
  background: #fafeff;
1426
  }
1427
+ #wc_ast_trackship_form table.form-table.heading-table tr,#wc_ast_upload_csv_form table.form-table.heading-table tr{
1428
  border-bottom: 0;
1429
  }
1430
  .woocommerce.zorem_admin_layout table.form-table.heading-table td{
1456
  .woocommerce.zorem_admin_layout table.form-table th{
1457
  padding: 20px 24px 20px 15px;
1458
  }
1459
+ .woocommerce.zorem_admin_layout table.form-table.table-layout-2 th.titledesc{
1460
+ padding: 20px 15px 20px 15px;
1461
+ }
1462
+ .woocommerce.zorem_admin_layout table.form-table.table-single-column td fieldset{
1463
+ margin-top: 10px;
1464
+ }
1465
  .woocommerce.zorem_admin_layout table.form-table td{
1466
  padding: 15px 15px;
1467
  }
1950
  .order-status-table tr td.status-label-column{
1951
  width:130px;
1952
  }
 
 
 
 
1953
  .order-status-table .wp-picker-container,.tracking_page_table .wp-picker-container {
1954
  display: inline-block;
1955
  vertical-align: middle;
assets/css/customizer-styles.css CHANGED
@@ -59,6 +59,15 @@
59
  display: inline-block;
60
  vertical-align: middle;
61
  }
 
 
 
 
 
 
 
 
 
62
  #accordion-section-customer_failure_email>h3:before{
63
  content: ' ';
64
  background-image: url(icons/failure-v4.png);
59
  display: inline-block;
60
  vertical-align: middle;
61
  }
62
+ #accordion-section-customer_shipped_email>h3:before{
63
+ content: ' ';
64
+ background-image: url(icons/shipped-o.png);
65
+ width: 20px;
66
+ height: 20px;
67
+ background-size: cover;
68
+ display: inline-block;
69
+ vertical-align: middle;
70
+ }
71
  #accordion-section-customer_failure_email>h3:before{
72
  content: ' ';
73
  background-image: url(icons/failure-v4.png);
assets/css/icons/shipped-o.png ADDED
Binary file
assets/js/admin.js CHANGED
@@ -12,14 +12,15 @@ jQuery( function( $ ) {
12
 
13
  // When a user enters a new tracking item
14
  save_form: function () {
15
- var error;
16
  var tracking_number = jQuery("#tracking_number");
17
  var tracking_provider = jQuery("#tracking_provider");
 
18
 
19
  if( tracking_number.val() === '' ){
20
  showerror( tracking_number );error = true;
21
  } else{
22
- var pattern = /^[0-9a-zA-Z-_ \b]+$/;
23
  if(!pattern.test(tracking_number.val())){
24
  showerror( tracking_number );
25
  error = true;
@@ -127,7 +128,7 @@ jQuery( function( $ ) {
127
  $( 'input#tracking_number' ).val( '' );
128
  $( 'input#date_shipped' ).val( '' );
129
  if(checked == 'change_order_to_shipped'){
130
- jQuery('#order_status').val('wc-completed');
131
  jQuery('#order_status').select2().trigger('change');
132
  jQuery('#post').before('<div id="order_updated_message" class="updated notice notice-success is-dismissible"><p>Order updated.</p><button type="button" class="notice-dismiss update-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>');
133
  } else if(checked == 'change_order_to_partial_shipped'){
@@ -148,6 +149,7 @@ jQuery( function( $ ) {
148
  show_form: function () {
149
  $( '#woocommerce-advanced-shipment-tracking #advanced-shipment-tracking-form' ).show();
150
  $( '#woocommerce-advanced-shipment-tracking .button-show-tracking-form' ).hide();
 
151
  },
152
 
153
  // Delete a tracking item
@@ -298,8 +300,14 @@ jQuery(document).on("click", ".add_inline_tracking", function(){
298
  type: 'POST',
299
  success: function(response) {
300
  jQuery( ".add_tracking_popup" ).remove();
301
- jQuery("body").append(response);
302
  jQuery('.add_tracking_popup').show();
 
 
 
 
 
 
303
  var selected_provider = jQuery("#tracking_provider").val();
304
 
305
  if(selected_provider == 'nz-couriers' || selected_provider == 'post-haste' || selected_provider == 'castle-parcels' || selected_provider == 'dx-mail' || selected_provider == 'now-couriers'){
@@ -337,17 +345,18 @@ jQuery(document).on("submit", "#add_tracking_number_form", function(){
337
 
338
 
339
  if( tracking_provider.val() === '' ){
340
- showerror(tracking_provider);
341
  error = true;
342
- } else{
 
343
  hideerror(tracking_provider);
344
- }
345
 
346
  if( tracking_number.val() === '' ){
347
  showerror(tracking_number);
348
  error = true;
349
  } else{
350
- var pattern = /^[0-9a-zA-Z-_ \b]+$/;
351
  if(!pattern.test(tracking_number.val())){
352
  showerror(tracking_number);
353
  error = true;
12
 
13
  // When a user enters a new tracking item
14
  save_form: function () {
15
+ var error;
16
  var tracking_number = jQuery("#tracking_number");
17
  var tracking_provider = jQuery("#tracking_provider");
18
+ var change_order_status = jQuery("#change_order_status").val();
19
 
20
  if( tracking_number.val() === '' ){
21
  showerror( tracking_number );error = true;
22
  } else{
23
+ var pattern = /^[0-9a-zA-Z-_. \b]+$/;
24
  if(!pattern.test(tracking_number.val())){
25
  showerror( tracking_number );
26
  error = true;
128
  $( 'input#tracking_number' ).val( '' );
129
  $( 'input#date_shipped' ).val( '' );
130
  if(checked == 'change_order_to_shipped'){
131
+ jQuery('#order_status').val(change_order_status);
132
  jQuery('#order_status').select2().trigger('change');
133
  jQuery('#post').before('<div id="order_updated_message" class="updated notice notice-success is-dismissible"><p>Order updated.</p><button type="button" class="notice-dismiss update-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>');
134
  } else if(checked == 'change_order_to_partial_shipped'){
149
  show_form: function () {
150
  $( '#woocommerce-advanced-shipment-tracking #advanced-shipment-tracking-form' ).show();
151
  $( '#woocommerce-advanced-shipment-tracking .button-show-tracking-form' ).hide();
152
+ $( "#woocommerce-advanced-shipment-tracking #advanced-shipment-tracking-form #tracking_number" ).focus();
153
  },
154
 
155
  // Delete a tracking item
300
  type: 'POST',
301
  success: function(response) {
302
  jQuery( ".add_tracking_popup" ).remove();
303
+ jQuery("body").append(response);
304
  jQuery('.add_tracking_popup').show();
305
+ jQuery( "#add_tracking_number_form #tracking_number" ).focus();
306
+
307
+ jQuery('#tracking_provider').select2({
308
+ matcher: modelMatcher
309
+ });
310
+
311
  var selected_provider = jQuery("#tracking_provider").val();
312
 
313
  if(selected_provider == 'nz-couriers' || selected_provider == 'post-haste' || selected_provider == 'castle-parcels' || selected_provider == 'dx-mail' || selected_provider == 'now-couriers'){
345
 
346
 
347
  if( tracking_provider.val() === '' ){
348
+ jQuery("#tracking_provider").siblings('.select2-container').find('.select2-selection').css('border-color','red');
349
  error = true;
350
+ } else{
351
+ jQuery("#tracking_provider").siblings('.select2-container').find('.select2-selection').css('border-color','#ddd');
352
  hideerror(tracking_provider);
353
+ }
354
 
355
  if( tracking_number.val() === '' ){
356
  showerror(tracking_number);
357
  error = true;
358
  } else{
359
+ var pattern = /^[0-9a-zA-Z-_. \b]+$/;
360
  if(!pattern.test(tracking_number.val())){
361
  showerror(tracking_number);
362
  error = true;
assets/js/customizer-scripts.js CHANGED
@@ -332,6 +332,19 @@ jQuery(document).on("change", "#_customize-input-customizer_delivered_order_sett
332
  } );
333
  } ( wp.customize ) );
334
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
  (function ( api ) {
336
  api.section( 'customer_updated_tracking_email', function( section ) {
337
  section.expanded.bind( function( isExpanded ) {
332
  } );
333
  } ( wp.customize ) );
334
 
335
+ (function ( api ) {
336
+ api.section( 'customer_shipped_email', function( section ) {
337
+ section.expanded.bind( function( isExpanded ) {
338
+ var url;
339
+ if ( isExpanded ) {
340
+ jQuery('#save').trigger('click');
341
+ url = wcast_customizer.shipped_email_preview_url;
342
+ api.previewer.previewUrl.set( url );
343
+ }
344
+ } );
345
+ } );
346
+ } ( wp.customize ) );
347
+
348
  (function ( api ) {
349
  api.section( 'customer_updated_tracking_email', function( section ) {
350
  section.expanded.bind( function( isExpanded ) {
assets/js/settings.js CHANGED
@@ -6,6 +6,14 @@ jQuery(document).on("click", "#wc_ast_status_delivered", function(){
6
  }
7
  });
8
 
 
 
 
 
 
 
 
 
9
  jQuery(document).on("click", "#wc_ast_status_partial_shipped", function(){
10
  if(jQuery(this).prop("checked") == true){
11
  jQuery(this).closest('tr').removeClass('disable_row');
@@ -42,6 +50,12 @@ jQuery( document ).ready(function() {
42
  jQuery('.order-status-table .order-label.wc-delivered').css('background',color);
43
  },
44
  });
 
 
 
 
 
 
45
  jQuery('#wc_ast_status_partial_shipped_label_color').wpColorPicker({
46
  change: function(e, ui) {
47
  var color = ui.color.toString();
@@ -82,6 +96,10 @@ jQuery(document).on("change", "#wc_ast_status_label_font_color", function(){
82
  var font_color = jQuery(this).val();
83
  jQuery('.order-status-table .order-label.wc-delivered').css('color',font_color);
84
  });
 
 
 
 
85
  jQuery(document).on("change", "#wc_ast_status_partial_shipped_label_font_color", function(){
86
  var font_color = jQuery(this).val();
87
  jQuery('.order-status-table .order-label.wc-partially-shipped').css('color',font_color);
@@ -89,4 +107,13 @@ jQuery(document).on("change", "#wc_ast_status_partial_shipped_label_font_color",
89
  jQuery(document).on("change", "#wc_ast_status_updated_tracking_label_font_color", function(){
90
  var font_color = jQuery(this).val();
91
  jQuery('.order-status-table .order-label.wc-updated-tracking').css('color',font_color);
 
 
 
 
 
 
 
 
 
92
  });
6
  }
7
  });
8
 
9
+ jQuery(document).on("click", "#wc_ast_status_shipped_active", function(){
10
+ if(jQuery(this).prop("checked") == true){
11
+ jQuery(this).closest('tr').removeClass('disable_row');
12
+ } else{
13
+ jQuery(this).closest('tr').addClass('disable_row');
14
+ }
15
+ });
16
+
17
  jQuery(document).on("click", "#wc_ast_status_partial_shipped", function(){
18
  if(jQuery(this).prop("checked") == true){
19
  jQuery(this).closest('tr').removeClass('disable_row');
50
  jQuery('.order-status-table .order-label.wc-delivered').css('background',color);
51
  },
52
  });
53
+ jQuery('#wc_ast_shipped_status_label_color').wpColorPicker({
54
+ change: function(e, ui) {
55
+ var color = ui.color.toString();
56
+ jQuery('.order-status-table .order-label.wc-shipped').css('background',color);
57
+ },
58
+ });
59
  jQuery('#wc_ast_status_partial_shipped_label_color').wpColorPicker({
60
  change: function(e, ui) {
61
  var color = ui.color.toString();
96
  var font_color = jQuery(this).val();
97
  jQuery('.order-status-table .order-label.wc-delivered').css('color',font_color);
98
  });
99
+ jQuery(document).on("change", "#wc_ast_shipped_status_label_font_color", function(){
100
+ var font_color = jQuery(this).val();
101
+ jQuery('.order-status-table .order-label.wc-shipped').css('color',font_color);
102
+ });
103
  jQuery(document).on("change", "#wc_ast_status_partial_shipped_label_font_color", function(){
104
  var font_color = jQuery(this).val();
105
  jQuery('.order-status-table .order-label.wc-partially-shipped').css('color',font_color);
107
  jQuery(document).on("change", "#wc_ast_status_updated_tracking_label_font_color", function(){
108
  var font_color = jQuery(this).val();
109
  jQuery('.order-status-table .order-label.wc-updated-tracking').css('color',font_color);
110
+ });
111
+
112
+ jQuery(document).on("change", ".wc_ast_completed_to_shipped", function(){
113
+ var wc_ast_completed_to_shipped = jQuery(this).val();
114
+ if(wc_ast_completed_to_shipped == 'wc_ast_create_shipped'){
115
+ jQuery('.shipped_order_status_tr').show();
116
+ } else{
117
+ jQuery('.shipped_order_status_tr').hide();
118
+ }
119
  });
assets/shipment-provider-img/dai-post (Hitesh Patel's conflicted copy 2020-04-27).png DELETED
File without changes
assets/shipment-provider-img/dawn-wing.png ADDED
Binary file
assets/shipment-provider-img/mrw (Hitesh Patel's conflicted copy 2020-04-27).png DELETED
File without changes
assets/shipment-provider-img/nacex (Hitesh Patel's conflicted copy 2020-04-27).png DELETED
File without changes
assets/shipment-provider-img/shree-maruti-courier (Hitesh Patel's conflicted copy 2020-04-27).png DELETED
File without changes
assets/shipment-provider-img/ubi-smart-parcel.png ADDED
Binary file
includes/class-wc-advanced-shipment-tracking-admin.php CHANGED
@@ -634,9 +634,9 @@ class WC_Advanced_Shipment_Tracking_Admin {
634
  }?>
635
  <span class=" multiple_checkbox">
636
  <label class="" for="<?php echo $key?>">
637
- <span class="multiple_label"><?php echo $val['status']; ?></span>
638
  <input type="hidden" name="<?php echo $id?>[<?php echo $key?>]" value="0"/>
639
  <input type="checkbox" id="<?php echo $key?>" name="<?php echo $id?>[<?php echo $key?>]" class="" <?php echo $checked; ?> value="1"/>
 
640
  </br>
641
  </label>
642
  </span>
@@ -659,9 +659,9 @@ class WC_Advanced_Shipment_Tracking_Admin {
659
  <?php } ?>
660
  <span class="multiple_checkbox">
661
  <label class="" for="<?php echo $key?>">
662
- <span class="multiple_label"><?php echo $val['status']; ?></span>
663
  <input type="hidden" name="<?php echo $id?>[<?php echo $key?>]" value="0"/>
664
- <input type="checkbox" id="<?php echo $key?>" name="<?php echo $id?>[<?php echo $key?>]" class="" <?php echo $checked; ?> value="1"/>
 
665
  </br>
666
  </label>
667
  </span>
@@ -746,9 +746,21 @@ class WC_Advanced_Shipment_Tracking_Admin {
746
  <?php } ?>
747
  </select>
748
  </fieldset>
749
- <?php } elseif( $array['type'] == 'title' ){?>
750
- <?php }
751
- elseif( $array['type'] == 'key_field' ){ ?>
 
 
 
 
 
 
 
 
 
 
 
 
752
  <fieldset>
753
  <?php if($array['connected'] == true){ ?>
754
  <a href="https://my.trackship.info/" target="_blank">
@@ -788,6 +800,165 @@ class WC_Advanced_Shipment_Tracking_Admin {
788
  </table>
789
  <?php
790
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
791
 
792
  /*
793
  * get trackship bulk actions tab array data
@@ -873,9 +1044,9 @@ class WC_Advanced_Shipment_Tracking_Admin {
873
  $show_bulk_sync_do_connection = false;
874
  }
875
 
876
- $wc_ast_status_shipped = get_option('wc_ast_status_shipped');
877
 
878
- if($wc_ast_status_shipped == 1){
879
  $completed_order_label = '<span class="shipped_label">shipped</span>';
880
  } else{
881
  $completed_order_label = '<span class="shipped_label">completed</span>';
@@ -1137,8 +1308,8 @@ class WC_Advanced_Shipment_Tracking_Admin {
1137
  */
1138
  function get_settings_data(){
1139
 
1140
- $wc_ast_status_shipped = get_option('wc_ast_status_shipped');
1141
- if($wc_ast_status_shipped == 1){
1142
  $completed_order_label = __( 'Shipped', 'woo-advanced-shipment-tracking' );
1143
  $mark_as_shipped_label = __( 'Default "mark as <span class="shipped_label">shipped</span>"', 'woo-advanced-shipment-tracking' );
1144
  $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' );
@@ -1155,11 +1326,12 @@ class WC_Advanced_Shipment_Tracking_Admin {
1155
  'wc-processing' => 'Processing',
1156
  'wc-on-hold' => 'On hold',
1157
  'wc-completed' => 'Completed',
1158
- 'wc-delivered' => 'Delivered',
1159
- //'wc-partial-shipped' => 'Partially Shipped',
1160
  'wc-cancelled' => 'Cancelled',
1161
  'wc-refunded' => 'Refunded',
1162
- 'wc-failed' => 'Failed'
 
 
1163
  );
1164
  foreach($default_order_status as $key=>$value){
1165
  unset($all_order_status[$key]);
@@ -1200,21 +1372,15 @@ class WC_Advanced_Shipment_Tracking_Admin {
1200
  'type' => 'default',
1201
  ),
1202
  );
1203
- $order_status_array = array_merge($order_status,$custom_order_status);
1204
-
1205
  if ( is_plugin_active( 'woocommerce-pdf-invoices-packing-slips/woocommerce-pdf-invoices-packingslips.php' ) ) {
1206
  $show_invoice_field = true;
1207
  } else{
1208
  $show_invoice_field = false;
1209
  }
1210
 
1211
- $form_data = array(
1212
- 'wc_ast_status_shipped' => array(
1213
- 'type' => 'checkbox',
1214
- 'title' => __( 'Rename the “Completed” Order status to “Shipped”', 'woo-advanced-shipment-tracking' ),
1215
- 'show' => true,
1216
- 'class' => '',
1217
- ),
1218
  'wc_ast_default_mark_shipped' => array(
1219
  'type' => 'checkbox',
1220
  'title' => $mark_as_shipped_label,
@@ -1224,7 +1390,8 @@ class WC_Advanced_Shipment_Tracking_Admin {
1224
  ),
1225
  'wc_ast_unclude_tracking_info' => array(
1226
  'type' => 'multiple_checkbox',
1227
- 'title' => __( 'On which order status email to include the shipment tracking info?', 'woo-advanced-shipment-tracking' ),'options' => $order_status_array,
 
1228
  'show' => true,
1229
  'class' => '',
1230
  ),
@@ -1244,6 +1411,29 @@ class WC_Advanced_Shipment_Tracking_Admin {
1244
  return $form_data;
1245
 
1246
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1247
 
1248
  /*
1249
  * get settings tab array data
@@ -1286,6 +1476,47 @@ class WC_Advanced_Shipment_Tracking_Admin {
1286
 
1287
  }
1288
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1289
  /*
1290
  * get updated tracking status settings array data
1291
  * return array
@@ -1382,6 +1613,14 @@ class WC_Advanced_Shipment_Tracking_Admin {
1382
  }
1383
  }
1384
 
 
 
 
 
 
 
 
 
1385
  $data = $this->get_delivered_data();
1386
 
1387
  foreach( $data as $key => $val ){
@@ -1410,6 +1649,35 @@ class WC_Advanced_Shipment_Tracking_Admin {
1410
  }
1411
  }
1412
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1413
  $data = $this->get_partial_shipped_data();
1414
 
1415
  foreach( $data as $key => $val ){
@@ -1480,6 +1748,9 @@ class WC_Advanced_Shipment_Tracking_Admin {
1480
  $bg_color = get_option('wc_ast_status_label_color','#212c42');
1481
  $color = get_option('wc_ast_status_label_font_color','#fff');
1482
 
 
 
 
1483
  $ps_bg_color = get_option('wc_ast_status_partial_shipped_label_color','#0c0c0c');
1484
  $ps_color = get_option('wc_ast_status_partial_shipped_label_font_color','#fff');
1485
 
@@ -1490,7 +1761,11 @@ class WC_Advanced_Shipment_Tracking_Admin {
1490
  .order-status.status-delivered,.order-status-table .order-label.wc-delivered{
1491
  background: <?php echo $bg_color; ?>;
1492
  color: <?php echo $color; ?>;
1493
- }
 
 
 
 
1494
  .order-status.status-partial-shipped,.order-status-table .order-label.wc-partially-shipped{
1495
  background: <?php echo $ps_bg_color; ?>;
1496
  color: <?php echo $ps_color; ?>;
@@ -1545,7 +1820,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
1545
  if(empty($tracking_number)){
1546
  echo '<li class="error">Failed - Empty Tracking Number for Order Id - '.$_POST['order_id'].'</li>';exit;
1547
  }
1548
- if(preg_match('/[^a-z0-9- \b]+/i', $tracking_number)){
1549
  echo '<li class="error">Failed - Special character not allowd in tracking number for Order Id - '.$_POST['order_id'].'</li>';exit;
1550
  }
1551
  if(empty($date_shipped)){
@@ -1709,7 +1984,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
1709
  public static function bulk_shipment_status_from_settings_fun(){
1710
  $args = array(
1711
  'status' => 'wc-completed',
1712
- 'limit' => -1,
1713
  'date_created' => '>' . ( time() - 2592000 ),
1714
  );
1715
  $orders = wc_get_orders( $args );
@@ -1737,7 +2012,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
1737
  public static function bulk_shipment_status_for_empty_balance_from_settings_fun(){
1738
  $args = array(
1739
  'status' => 'wc-completed',
1740
- 'limit' => -1,
1741
  'date_created' => '>' . ( time() - 2592000 ),
1742
  );
1743
  $orders = wc_get_orders( $args );
@@ -1767,7 +2042,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
1767
  public static function bulk_shipment_status_for_do_connection_from_settings_fun(){
1768
  $args = array(
1769
  'status' => 'wc-completed',
1770
- 'limit' => -1,
1771
  'date_created' => '>' . ( time() - 2592000 ),
1772
  );
1773
  $orders = wc_get_orders( $args );
@@ -1991,9 +2266,9 @@ class WC_Advanced_Shipment_Tracking_Admin {
1991
  * Change completed order email title to Shipped Order
1992
  */
1993
  public function change_completed_woocommerce_email_title($email_title, $email){
1994
- $wc_ast_status_shipped = get_option('wc_ast_status_shipped');
1995
  // Only on backend Woocommerce Settings "Emails" tab
1996
- if($wc_ast_status_shipped == 1){
1997
  if( isset($_GET['page']) && $_GET['page'] == 'wc-settings' && isset($_GET['tab']) && $_GET['tab'] == 'email' ) {
1998
  switch ($email->id) {
1999
  case 'customer_completed_order':
@@ -2015,7 +2290,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
2015
 
2016
  $wc_ast_status_delivered = get_option('wc_ast_status_delivered');
2017
  if($wc_ast_status_delivered){
2018
- if ( $order->has_status( array( 'completed' ) ) ) {
2019
  // Get Order ID (compatibility all WC versions)
2020
  $order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
2021
  // Set the action button
@@ -2026,11 +2301,23 @@ class WC_Advanced_Shipment_Tracking_Admin {
2026
  );
2027
  }
2028
  }
2029
- $actions['add_tracking'] = array(
2030
- 'url' => "#".$order->get_id(),
2031
- 'name' => __( 'Add Tracking', 'woo-advanced-shipment-tracking' ),
2032
- 'action' => "add_inline_tracking", // keep "view" class for a clean button CSS
2033
- );
 
 
 
 
 
 
 
 
 
 
 
 
2034
  return $actions;
2035
  }
2036
 
634
  }?>
635
  <span class=" multiple_checkbox">
636
  <label class="" for="<?php echo $key?>">
 
637
  <input type="hidden" name="<?php echo $id?>[<?php echo $key?>]" value="0"/>
638
  <input type="checkbox" id="<?php echo $key?>" name="<?php echo $id?>[<?php echo $key?>]" class="" <?php echo $checked; ?> value="1"/>
639
+ <span class="multiple_label"><?php echo $val['status']; ?></span>
640
  </br>
641
  </label>
642
  </span>
659
  <?php } ?>
660
  <span class="multiple_checkbox">
661
  <label class="" for="<?php echo $key?>">
 
662
  <input type="hidden" name="<?php echo $id?>[<?php echo $key?>]" value="0"/>
663
+ <input type="checkbox" id="<?php echo $key?>" name="<?php echo $id?>[<?php echo $key?>]" class="" <?php echo $checked; ?> value="1"/>
664
+ <span class="multiple_label"><?php echo $val['status']; ?></span>
665
  </br>
666
  </label>
667
  </span>
746
  <?php } ?>
747
  </select>
748
  </fieldset>
749
+ <?php } elseif( isset( $array['type'] ) && $array['type'] == 'radio' ){ ?>
750
+ <fieldset>
751
+ <?php foreach((array)$array['options'] as $key => $val ){
752
+ $selected = '';
753
+ if( get_option($id,$array['default']) == (string)$key )$selected = 'checked'; ?>
754
+ <span class="radio_section">
755
+ <label class="" for="<?php echo $id?>_<?php echo $key?>">
756
+ <input type="radio" id="<?php echo $id?>_<?php echo $key?>" name="<?php echo $id?>" class="<?php echo $id?>" value="<?php echo $key?>" <?php echo $selected?>/>
757
+ <span class=""><?php echo $val; ?></span>
758
+ </br>
759
+ </label>
760
+ </span></br>
761
+ <?php } ?>
762
+ </fieldset>
763
+ <?php } elseif( $array['type'] == 'key_field' ){ ?>
764
  <fieldset>
765
  <?php if($array['connected'] == true){ ?>
766
  <a href="https://my.trackship.info/" target="_blank">
800
  </table>
801
  <?php
802
  }
803
+
804
+ /*
805
+ * get html of fields
806
+ */
807
+ public function get_single_column_html( $arrays ){ ?>
808
+ <table class="form-table table-single-column">
809
+ <tbody>
810
+ <?php foreach( (array)$arrays as $id => $array ){
811
+ if($array['show']){ ?>
812
+ <tr valign="top" class="<?php echo $array['class']; ?>">
813
+ <td scope="row">
814
+ <label for=""><strong><?php echo $array['title']?>
815
+ <?php if( isset($array['tooltip']) ){?>
816
+ <span class="woocommerce-help-tip tipTip" title="<?php echo $array['tooltip']?>"></span>
817
+ <?php } ?>
818
+ </strong></label>
819
+ <?php if( isset( $array['type'] ) && $array['type'] == 'radio' ){ ?>
820
+ <fieldset>
821
+ <?php foreach((array)$array['options'] as $key => $val ){
822
+ $selected = '';
823
+ if( get_option($id,$array['default']) == (string)$key )$selected = 'checked'; ?>
824
+ <span class="radio_section">
825
+ <label class="" for="<?php echo $id?>_<?php echo $key?>">
826
+ <input type="radio" id="<?php echo $id?>_<?php echo $key?>" name="<?php echo $id?>" class="<?php echo $id?>" value="<?php echo $key?>" <?php echo $selected?>/>
827
+ <span class=""><?php echo $val; ?></span>
828
+ </br>
829
+ </label>
830
+ </span></br>
831
+ <?php } ?>
832
+ </fieldset>
833
+ <?php } ?>
834
+ </td>
835
+ </tr>
836
+ <?php } } ?>
837
+ </tbody>
838
+ </table>
839
+ <?php }
840
+
841
+ /*
842
+ * get html of fields
843
+ */
844
+ public function get_html_2( $arrays ){
845
+
846
+ $checked = '';
847
+ ?>
848
+ <table class="form-table table-layout-2">
849
+ <tbody>
850
+ <?php foreach( (array)$arrays as $id => $array ){
851
+
852
+ if($array['show']){ ?>
853
+ <tr valign="top" class="<?php echo $array['class']; ?>">
854
+
855
+ <th scope="row" class="titledesc" <?php if($array['type'] == 'desc'){ ?> colspan=2 <?php } ?>>
856
+ <?php if( $array['type'] == 'checkbox' ){
857
+ if($id === 'wcast_enable_delivered_email'){
858
+ $wcast_enable_delivered_email = get_option('woocommerce_customer_delivered_order_settings');
859
+
860
+ if($wcast_enable_delivered_email['enabled'] == 'yes' || $wcast_enable_delivered_email['enabled'] == 1){
861
+ $checked = 'checked';
862
+ } else{
863
+ $checked = '';
864
+ }
865
+
866
+ } elseif($id === 'wcast_enable_partial_shipped_email'){
867
+ $wcast_enable_partial_shipped_email = get_option('woocommerce_customer_partial_shipped_order_settings');
868
+
869
+ if($wcast_enable_partial_shipped_email['enabled'] == 'yes' || $wcast_enable_partial_shipped_email['enabled'] == 1){
870
+ $checked = 'checked';
871
+ } else{
872
+ $checked = '';
873
+ }
874
+ } else{
875
+ if(get_option($id)){
876
+ $checked = 'checked';
877
+ } else{
878
+ $checked = '';
879
+ }
880
+ }
881
+
882
+ if(isset($array['disabled']) && $array['disabled'] == true){
883
+ $disabled = 'disabled';
884
+ $checked = '';
885
+ } else{
886
+ $disabled = '';
887
+ }
888
+ ?>
889
+ <span class="mdl-list__item-secondary-action">
890
+ <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="<?php echo $id?>">
891
+ <input type="hidden" name="<?php echo $id?>" value="0"/>
892
+ <input type="checkbox" id="<?php echo $id?>" name="<?php echo $id?>" class="mdl-switch__input" <?php echo $checked ?> value="1" <?php echo $disabled; ?>/>
893
+ </label>
894
+ </span>
895
+ <?php } elseif( isset( $array['type'] ) && $array['type'] == 'dropdown' ){?>
896
+ <?php
897
+ if( isset($array['multiple']) ){
898
+ $multiple = 'multiple';
899
+ $field_id = $array['multiple'];
900
+ } else {
901
+ $multiple = '';
902
+ $field_id = $id;
903
+ }
904
+ ?>
905
+ <fieldset>
906
+ <select class="select select2" id="<?php echo $field_id?>" name="<?php echo $id?>" <?php echo $multiple;?>> <?php foreach((array)$array['options'] as $key => $val ){?>
907
+ <?php
908
+ $selected = '';
909
+ if( isset($array['multiple']) ){
910
+ if (in_array($key, (array)$this->data->$field_id ))$selected = 'selected';
911
+ } else {
912
+ if( get_option($id) == (string)$key )$selected = 'selected';
913
+ }
914
+
915
+ ?>
916
+ <option value="<?php echo $key?>" <?php echo $selected?> ><?php echo $val?></option>
917
+ <?php } ?>
918
+ </select>
919
+ </fieldset>
920
+ <?php }
921
+ elseif( $array['type'] == 'label' ){ ?>
922
+ <fieldset>
923
+ <label><?php echo $array['value']; ?></label>
924
+ </fieldset>
925
+ <?php }
926
+ elseif( $array['type'] == 'tooltip_button' ){ ?>
927
+ <fieldset>
928
+ <a href="<?php echo $array['link']; ?>" class="button-primary" target="<?php echo $array['target'];?>"><?php echo $array['link_label'];?></a>
929
+ </fieldset>
930
+ <?php }
931
+ elseif( $array['type'] == 'button' ){ ?>
932
+ <fieldset>
933
+ <button class="button-primary btn_green2 <?php echo $array['button_class'];?>" <?php if($array['disable'] == 1){ echo 'disabled'; }?>><?php echo $array['label'];?></button>
934
+ </fieldset>
935
+ <?php }
936
+ else { ?>
937
+
938
+ <fieldset>
939
+ <input class="input-text regular-input " type="text" name="<?php echo $id?>" id="<?php echo $id?>" style="" value="<?php echo get_option($id)?>" placeholder="<?php if(!empty($array['placeholder'])){echo $array['placeholder'];} ?>">
940
+ </fieldset>
941
+ <?php } ?>
942
+
943
+ </th>
944
+ <?php if($array['type'] != 'desc'){ ?>
945
+ <th class="forminp">
946
+ <label for=""><?php echo $array['title']?><?php if(isset($array['title_link'])){ echo $array['title_link']; } ?>
947
+ <?php if( isset($array['tooltip']) ){?>
948
+ <span class="woocommerce-help-tip tipTip" title="<?php echo $array['tooltip']?>"></span>
949
+ <?php } ?>
950
+ </label>
951
+ </th>
952
+ <?php } ?>
953
+ </tr>
954
+ <?php if(isset($array['desc']) && $array['desc'] != ''){ ?>
955
+ <tr class="<?php echo $array['class']; ?>"><td colspan="2" style=""><p class="description"><?php echo (isset($array['desc']))? $array['desc']: ''?></p></td></tr>
956
+ <?php } ?>
957
+ <?php } } ?>
958
+ </tbody>
959
+ </table>
960
+ <?php
961
+ }
962
 
963
  /*
964
  * get trackship bulk actions tab array data
1044
  $show_bulk_sync_do_connection = false;
1045
  }
1046
 
1047
+ $wc_ast_completed_to_shipped = get_option('wc_ast_completed_to_shipped');
1048
 
1049
+ if($wc_ast_completed_to_shipped == 'wc_ast_rename_to_shipped'){
1050
  $completed_order_label = '<span class="shipped_label">shipped</span>';
1051
  } else{
1052
  $completed_order_label = '<span class="shipped_label">completed</span>';
1308
  */
1309
  function get_settings_data(){
1310
 
1311
+ $wc_ast_completed_to_shipped = get_option('wc_ast_completed_to_shipped');
1312
+ if($wc_ast_completed_to_shipped == 'wc_ast_rename_to_shipped'){
1313
  $completed_order_label = __( 'Shipped', 'woo-advanced-shipment-tracking' );
1314
  $mark_as_shipped_label = __( 'Default "mark as <span class="shipped_label">shipped</span>"', 'woo-advanced-shipment-tracking' );
1315
  $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' );
1326
  'wc-processing' => 'Processing',
1327
  'wc-on-hold' => 'On hold',
1328
  'wc-completed' => 'Completed',
1329
+ 'wc-delivered' => 'Delivered',
 
1330
  'wc-cancelled' => 'Cancelled',
1331
  'wc-refunded' => 'Refunded',
1332
+ 'wc-failed' => 'Failed',
1333
+ 'wc-ready-pickup' => 'Ready for Pickup',
1334
+ 'wc-pickup' => 'Picked up'
1335
  );
1336
  foreach($default_order_status as $key=>$value){
1337
  unset($all_order_status[$key]);
1372
  'type' => 'default',
1373
  ),
1374
  );
1375
+ $order_status_array = array_merge($order_status,$custom_order_status);
1376
+
1377
  if ( is_plugin_active( 'woocommerce-pdf-invoices-packing-slips/woocommerce-pdf-invoices-packingslips.php' ) ) {
1378
  $show_invoice_field = true;
1379
  } else{
1380
  $show_invoice_field = false;
1381
  }
1382
 
1383
+ $form_data = array(
 
 
 
 
 
 
1384
  'wc_ast_default_mark_shipped' => array(
1385
  'type' => 'checkbox',
1386
  'title' => $mark_as_shipped_label,
1390
  ),
1391
  'wc_ast_unclude_tracking_info' => array(
1392
  'type' => 'multiple_checkbox',
1393
+ 'title' => __( 'On which order status email to include the shipment tracking info?', 'woo-advanced-shipment-tracking' ),
1394
+ 'options' => $order_status_array,
1395
  'show' => true,
1396
  'class' => '',
1397
  ),
1411
  return $form_data;
1412
 
1413
  }
1414
+
1415
+ /*
1416
+ * get settings tab array data
1417
+ * return array
1418
+ */
1419
+ function get_rename_order_status_data(){
1420
+ $form_data = array(
1421
+ 'wc_ast_completed_to_shipped' => array(
1422
+ 'type' => 'radio',
1423
+ 'title' => __( 'Rename the “Completed” Order status to “Shipped” or create new order status "Shipped"', 'woo-advanced-shipment-tracking' ),
1424
+ 'show' => true,
1425
+ 'options' => array(
1426
+ "wc_ast_rename_to_shipped" =>__( 'Rename the “Completed” Order status to “Shipped”', 'woo-advanced-shipment-tracking' ),
1427
+ "wc_ast_create_shipped" =>__( 'Create new order status “Shipped”', 'woo-advanced-shipment-tracking' ),
1428
+ "none" =>__( 'None of the above', 'woo-advanced-shipment-tracking' ),
1429
+ ),
1430
+ 'default' => 'wc_ast_rename_to_shipped',
1431
+ 'class' => '',
1432
+ )
1433
+ );
1434
+ return $form_data;
1435
+
1436
+ }
1437
 
1438
  /*
1439
  * get settings tab array data
1476
 
1477
  }
1478
 
1479
+ /*
1480
+ * get settings tab array data
1481
+ * return array
1482
+ */
1483
+ function get_shipped_data(){
1484
+ $form_data = array(
1485
+ 'wc_ast_status_shipped_active' => array(
1486
+ 'type' => 'checkbox',
1487
+ 'title' => __( 'Enable custom order status “Delivered"', '' ),
1488
+ 'show' => true,
1489
+ 'class' => '',
1490
+ ),
1491
+ 'wc_ast_shipped_status_label_color' => array(
1492
+ 'type' => 'color',
1493
+ 'title' => __( 'Delivered Label color', '' ),
1494
+ 'class' => 'status_label_color_th',
1495
+ 'show' => true,
1496
+ ),
1497
+ 'wc_ast_shipped_status_label_font_color' => array(
1498
+ 'type' => 'dropdown',
1499
+ 'title' => __( 'Shipped Label font color', '' ),
1500
+ 'options' => array(
1501
+ "" =>__( 'Select', 'woocommerce' ),
1502
+ "#fff" =>__( 'Light', '' ),
1503
+ "#000" =>__( 'Dark', '' ),
1504
+ ),
1505
+ 'class' => 'status_label_color_th',
1506
+ 'show' => true,
1507
+ ),
1508
+ 'wcast_enable_shipped_email' => array(
1509
+ 'type' => 'checkbox',
1510
+ 'title' => __( 'Enable the Delivered order status email', '' ),
1511
+ 'title_link'=> "<a class='settings_edit' href='".wcast_initialise_customizer_email::get_customizer_url('customer_shipped_email')."'>".__( 'Edit', 'woocommerce' )."</a>",
1512
+ 'class' => 'status_label_color_th',
1513
+ 'show' => true,
1514
+ ),
1515
+ );
1516
+ return $form_data;
1517
+
1518
+ }
1519
+
1520
  /*
1521
  * get updated tracking status settings array data
1522
  * return array
1613
  }
1614
  }
1615
 
1616
+ $data = $this->get_rename_order_status_data();
1617
+
1618
+ foreach( $data as $key => $val ){
1619
+ if(isset($_POST[ $key ])){
1620
+ update_option( $key, $_POST[ $key ] );
1621
+ }
1622
+ }
1623
+
1624
  $data = $this->get_delivered_data();
1625
 
1626
  foreach( $data as $key => $val ){
1649
  }
1650
  }
1651
 
1652
+ $data = $this->get_shipped_data();
1653
+
1654
+ foreach( $data as $key => $val ){
1655
+ if($key == 'wcast_enable_shipped_email'){
1656
+ if(isset($_POST['wcast_enable_shipped_email'])){
1657
+ $wcast_enable_shipped_email = get_option('woocommerce_customer_shipped_order_settings');
1658
+ if($_POST['wcast_enable_shipped_email'] == 1){
1659
+ update_option( 'customizer_shipped_order_settings_enabled',$_POST['wcast_enable_shipped_email']);
1660
+ $enabled = 'yes';
1661
+ } else{
1662
+ update_option( 'customizer_shipped_order_settings_enabled','');
1663
+ $enabled = 'no';
1664
+ }
1665
+ $opt = array(
1666
+ 'enabled' => $enabled,
1667
+ 'subject' => $wcast_enable_shipped_email['subject'],
1668
+ 'heading' => $wcast_enable_shipped_email['heading'],
1669
+ 'recipient' => $wcast_enable_shipped_email['recipient'],
1670
+ 'email_type' => $wcast_enable_shipped_email['email_type'],
1671
+ );
1672
+ update_option( 'woocommerce_customer_shipped_order_settings', $opt );
1673
+ }
1674
+ }
1675
+
1676
+ if(isset($_POST[ $key ])){
1677
+ update_option( $key, $_POST[ $key ] );
1678
+ }
1679
+ }
1680
+
1681
  $data = $this->get_partial_shipped_data();
1682
 
1683
  foreach( $data as $key => $val ){
1748
  $bg_color = get_option('wc_ast_status_label_color','#212c42');
1749
  $color = get_option('wc_ast_status_label_font_color','#fff');
1750
 
1751
+ $shipped_bg_color = get_option('wc_ast_shipped_status_label_color','#b7b7b7');
1752
+ $shipped_color = get_option('wc_ast_shipped_status_label_font_color','#fff');
1753
+
1754
  $ps_bg_color = get_option('wc_ast_status_partial_shipped_label_color','#0c0c0c');
1755
  $ps_color = get_option('wc_ast_status_partial_shipped_label_font_color','#fff');
1756
 
1761
  .order-status.status-delivered,.order-status-table .order-label.wc-delivered{
1762
  background: <?php echo $bg_color; ?>;
1763
  color: <?php echo $color; ?>;
1764
+ }
1765
+ .order-status.status-shipped,.order-status-table .order-label.wc-shipped{
1766
+ background: <?php echo $shipped_bg_color; ?>;
1767
+ color: <?php echo $shipped_color; ?>;
1768
+ }
1769
  .order-status.status-partial-shipped,.order-status-table .order-label.wc-partially-shipped{
1770
  background: <?php echo $ps_bg_color; ?>;
1771
  color: <?php echo $ps_color; ?>;
1820
  if(empty($tracking_number)){
1821
  echo '<li class="error">Failed - Empty Tracking Number for Order Id - '.$_POST['order_id'].'</li>';exit;
1822
  }
1823
+ if(preg_match('/[^a-z0-9-_. \b]+/i', $tracking_number)){
1824
  echo '<li class="error">Failed - Special character not allowd in tracking number for Order Id - '.$_POST['order_id'].'</li>';exit;
1825
  }
1826
  if(empty($date_shipped)){
1984
  public static function bulk_shipment_status_from_settings_fun(){
1985
  $args = array(
1986
  'status' => 'wc-completed',
1987
+ 'limit' => 100,
1988
  'date_created' => '>' . ( time() - 2592000 ),
1989
  );
1990
  $orders = wc_get_orders( $args );
2012
  public static function bulk_shipment_status_for_empty_balance_from_settings_fun(){
2013
  $args = array(
2014
  'status' => 'wc-completed',
2015
+ 'limit' => 100,
2016
  'date_created' => '>' . ( time() - 2592000 ),
2017
  );
2018
  $orders = wc_get_orders( $args );
2042
  public static function bulk_shipment_status_for_do_connection_from_settings_fun(){
2043
  $args = array(
2044
  'status' => 'wc-completed',
2045
+ 'limit' => 100,
2046
  'date_created' => '>' . ( time() - 2592000 ),
2047
  );
2048
  $orders = wc_get_orders( $args );
2266
  * Change completed order email title to Shipped Order
2267
  */
2268
  public function change_completed_woocommerce_email_title($email_title, $email){
2269
+ $wc_ast_completed_to_shipped = get_option('wc_ast_completed_to_shipped');
2270
  // Only on backend Woocommerce Settings "Emails" tab
2271
+ if($wc_ast_completed_to_shipped == 'wc_ast_rename_to_shipped'){
2272
  if( isset($_GET['page']) && $_GET['page'] == 'wc-settings' && isset($_GET['tab']) && $_GET['tab'] == 'email' ) {
2273
  switch ($email->id) {
2274
  case 'customer_completed_order':
2290
 
2291
  $wc_ast_status_delivered = get_option('wc_ast_status_delivered');
2292
  if($wc_ast_status_delivered){
2293
+ if ( $order->has_status( array( 'completed' ) ) || $order->has_status( array( 'shipped' ) )) {
2294
  // Get Order ID (compatibility all WC versions)
2295
  $order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
2296
  // Set the action button
2301
  );
2302
  }
2303
  }
2304
+
2305
+ $wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
2306
+ $check_if_virtual = $wast->check_if_virtual_order($order->get_id());
2307
+ if($check_if_virtual)return $actions;
2308
+
2309
+ //foreach( $order->get_items( 'shipping' ) as $item_id => $shipping_item_obj ){
2310
+ // $shipping_method = $shipping_item_obj->get_method_id();
2311
+ //}
2312
+ //if( isset($shipping_method ) && $shipping_method == 'local_pickup' ) return $actions;
2313
+
2314
+ if ( !$order->has_status( array( 'pickup','ready-pickup','on-hold','delivered','cancelled','failed' ) ) ) {
2315
+ $actions['add_tracking'] = array(
2316
+ 'url' => "#".$order->get_id(),
2317
+ 'name' => __( 'Add Tracking', 'woo-advanced-shipment-tracking' ),
2318
+ 'action' => "add_inline_tracking", // keep "view" class for a clean button CSS
2319
+ );
2320
+ }
2321
  return $actions;
2322
  }
2323
 
includes/class-wc-advanced-shipment-tracking-front.php CHANGED
@@ -346,6 +346,9 @@ class WC_Advanced_Shipment_Tracking_Front {
346
  $order_id = $_POST['order_id'];
347
  $email = $_POST['order_email'];
348
 
 
 
 
349
  $order = wc_get_order( $order_id );
350
  if(empty($order)){
351
  ob_start();
@@ -400,7 +403,23 @@ class WC_Advanced_Shipment_Tracking_Front {
400
  }
401
  $shipment_status = get_post_meta( $order_id, "shipment_status", true);
402
  if(!$tracking_items){
403
- echo 'tracking_items_not_found';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
  exit;
405
  }
406
 
346
  $order_id = $_POST['order_id'];
347
  $email = $_POST['order_email'];
348
 
349
+ $wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
350
+ $order_id = $wast->get_formated_order_id($order_id);
351
+
352
  $order = wc_get_order( $order_id );
353
  if(empty($order)){
354
  ob_start();
403
  }
404
  $shipment_status = get_post_meta( $order_id, "shipment_status", true);
405
  if(!$tracking_items){
406
+ ob_start();
407
+ ?>
408
+ <div class="track-order-section">
409
+ <form method="post" class="order_track_form">
410
+ <p><?php echo apply_filters( 'ast_tracking_page_front_text', __( 'To track your order please enter your Order ID in the box below and press the "Track" button. This was given to you on your receipt and in the confirmation email you should have received.', 'woo-advanced-shipment-tracking' ) ); ?></p>
411
+ <p class="form-row form-row-first"><label for="order_id"><?php echo apply_filters( 'ast_tracking_page_front_order_label', __( 'Order ID', 'woocommerce' ) ); ?></label> <input class="input-text" type="text" name="order_id" id="order_id" value="" placeholder="<?php _e( 'Found in your order confirmation email.', 'woo-advanced-shipment-tracking' ); ?>"></p>
412
+ <p class="form-row form-row-last"><label for="order_email"><?php echo apply_filters( 'ast_tracking_page_front_order_email_label', __( 'Order Email', 'woo-advanced-shipment-tracking' ) ); ?></label> <input class="input-text" type="text" name="order_email" id="order_email" value="" placeholder="<?php _e( 'Found in your order confirmation email.', 'woo-advanced-shipment-tracking' ); ?>"></p>
413
+ <div class="clear"></div>
414
+ <input type="hidden" name="action" value="get_tracking_info">
415
+ <p class="form-row"><button type="submit" class="button" name="track" value="Track"><?php echo apply_filters( 'ast_tracking_page_front_track_label', __( 'Track', 'woo-advanced-shipment-tracking' ) ); ?></button></p>
416
+ <div class="track_fail_msg" style="display:block;color: red;"><?php _e( 'Tracking details not found.', 'woo-advanced-shipment-tracking' ); ?></div>
417
+ </form>
418
+ </div>
419
+ <?php
420
+
421
+ $form = ob_get_clean();
422
+ echo $form;exit;
423
  exit;
424
  }
425
 
includes/class-wc-advanced-shipment-tracking-install.php CHANGED
@@ -1721,6 +1721,39 @@ class WC_Advanced_Shipment_Tracking_Install {
1721
  update_option( 'late_shipments_email_settings', $late_shipments_email_opt );
1722
 
1723
  update_option( 'wc_advanced_shipment_tracking', '3.8');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1724
  }
1725
  }
1726
  }
@@ -1755,16 +1788,20 @@ class WC_Advanced_Shipment_Tracking_Install {
1755
  $provider_url = $provider['provider_url'];
1756
  $shipping_country = $provider['shipping_country'];
1757
  $ts_slug = $provider['shipping_provider_slug'];
 
1758
 
1759
  if(isset($shippment_providers[$provider_name])){
1760
  $db_provider_url = $shippment_providers[$provider_name]->provider_url;
1761
  $db_shipping_country = $shippment_providers[$provider_name]->shipping_country;
1762
  $db_ts_slug = $shippment_providers[$provider_name]->ts_slug;
1763
- if(($db_provider_url != $provider_url) || ($db_shipping_country != $shipping_country) || ($db_ts_slug != $ts_slug)){
 
 
1764
  $data_array = array(
1765
  'ts_slug' => $ts_slug,
1766
  'provider_url' => $provider_url,
1767
- 'shipping_country' => $shipping_country,
 
1768
  );
1769
  $where_array = array(
1770
  'provider_name' => $provider_name,
@@ -1795,6 +1832,7 @@ class WC_Advanced_Shipment_Tracking_Install {
1795
  'provider_url' => sanitize_text_field($provider_url),
1796
  'display_in_order' => 0,
1797
  'shipping_default' => 1,
 
1798
  );
1799
  $result = $wpdb->insert( $this->table, $data_array );
1800
  }
1721
  update_option( 'late_shipments_email_settings', $late_shipments_email_opt );
1722
 
1723
  update_option( 'wc_advanced_shipment_tracking', '3.8');
1724
+ }
1725
+
1726
+ if(version_compare(get_option( 'wc_advanced_shipment_tracking' ),'3.10', '<') ){
1727
+ global $wpdb;
1728
+ $results = $wpdb->get_row( "SELECT * FROM {$this->table} LIMIT 1");
1729
+
1730
+ if(!isset($results->trackship_supported)) {
1731
+ $res = $wpdb->query( sprintf( "ALTER TABLE %s ADD trackship_supported int(11) NOT NULL DEFAULT '0'", $this->table) );
1732
+ }
1733
+
1734
+ $url = 'https://trackship.info/wp-json/WCAST/v1/Provider';
1735
+ $resp = wp_remote_get( $url );
1736
+ if ( is_array( $resp ) && ! is_wp_error( $resp ) ) {
1737
+ $providers = json_decode($resp['body'],true);
1738
+ }
1739
+ foreach($providers as $provider){
1740
+ $data_array = array(
1741
+ 'trackship_supported' => $provider['trackship_supported'],
1742
+ );
1743
+ $where_array = array(
1744
+ 'provider_name' => $provider['shipping_provider'],
1745
+ );
1746
+ $wpdb->update( $this->table, $data_array, $where_array);
1747
+ }
1748
+ update_option( 'wc_advanced_shipment_tracking', '3.10');
1749
+ }
1750
+ if(version_compare(get_option( 'wc_advanced_shipment_tracking' ),'3.11', '<') ){
1751
+ $wc_ast_status_shipped = get_option('wc_ast_status_shipped',0);
1752
+ if( $wc_ast_status_shipped == 1 ){
1753
+ update_option( 'wc_ast_completed_to_shipped', 'wc_ast_rename_to_shipped');
1754
+ }
1755
+ update_option( 'wc_ast_status_shipped_active', 1);
1756
+ update_option( 'wc_advanced_shipment_tracking', '3.11');
1757
  }
1758
  }
1759
  }
1788
  $provider_url = $provider['provider_url'];
1789
  $shipping_country = $provider['shipping_country'];
1790
  $ts_slug = $provider['shipping_provider_slug'];
1791
+ $trackship_supported = $provider['trackship_supported'];
1792
 
1793
  if(isset($shippment_providers[$provider_name])){
1794
  $db_provider_url = $shippment_providers[$provider_name]->provider_url;
1795
  $db_shipping_country = $shippment_providers[$provider_name]->shipping_country;
1796
  $db_ts_slug = $shippment_providers[$provider_name]->ts_slug;
1797
+ $db_trackship_supported = $shippment_providers[$provider_name]->trackship_supported;
1798
+
1799
+ if(($db_provider_url != $provider_url) || ($db_shipping_country != $shipping_country) || ($db_ts_slug != $ts_slug) || ($db_trackship_supported != $trackship_supported)){
1800
  $data_array = array(
1801
  'ts_slug' => $ts_slug,
1802
  'provider_url' => $provider_url,
1803
+ 'shipping_country' => $shipping_country,
1804
+ 'trackship_supported' => $trackship_supported,
1805
  );
1806
  $where_array = array(
1807
  'provider_name' => $provider_name,
1832
  'provider_url' => sanitize_text_field($provider_url),
1833
  'display_in_order' => 0,
1834
  'shipping_default' => 1,
1835
+ 'trackship_supported' => $provider['trackship_supported'],
1836
  );
1837
  $result = $wpdb->insert( $this->table, $data_array );
1838
  }
includes/class-wc-advanced-shipment-tracking-settings.php CHANGED
@@ -55,6 +55,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
55
 
56
  //rename order status + rename bulk action + rename filter
57
  add_filter( 'wc_order_statuses', array( $this, 'wc_renaming_order_status') );
 
58
  add_filter( 'woocommerce_register_shop_order_post_statuses', array( $this, 'filter_woocommerce_register_shop_order_post_statuses'), 10, 1 );
59
  add_filter( 'bulk_actions-edit-shop_order', array( $this, 'modify_bulk_actions'), 50, 1 );
60
 
@@ -77,6 +78,22 @@ class WC_Advanced_Shipment_Tracking_Settings {
77
  add_filter( 'bulk_actions-edit-shop_order', array( $this, 'add_bulk_actions'), 50, 1 );
78
  }
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  //new order status
81
  $updated_tracking_status = get_option( "wc_ast_status_updated_tracking", 0);
82
  if( $updated_tracking_status == true ){
@@ -132,7 +149,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
132
  /**
133
  * Register new status : Delivered
134
  **/
135
- function register_order_status() {
136
  register_post_status( 'wc-delivered', array(
137
  'label' => __( 'Delivered', 'woo-advanced-shipment-tracking' ),
138
  'public' => true,
@@ -143,6 +160,22 @@ class WC_Advanced_Shipment_Tracking_Settings {
143
  ) );
144
  }
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  /**
147
  * Register new status : Updated Tracking
148
  **/
@@ -175,6 +208,23 @@ class WC_Advanced_Shipment_Tracking_Settings {
175
  * add status after completed
176
  */
177
  function add_delivered_to_order_statuses( $order_statuses ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  $new_order_statuses = array();
179
  foreach ( $order_statuses as $key => $status ) {
180
  $new_order_statuses[ $key ] = $status;
@@ -186,10 +236,59 @@ class WC_Advanced_Shipment_Tracking_Settings {
186
  return $new_order_statuses;
187
  }
188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  /*
190
  * add status after completed
191
  */
192
  function add_updated_tracking_to_order_statuses( $order_statuses ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  $new_order_statuses = array();
194
  foreach ( $order_statuses as $key => $status ) {
195
  $new_order_statuses[ $key ] = $status;
@@ -204,6 +303,23 @@ class WC_Advanced_Shipment_Tracking_Settings {
204
  * add status after completed
205
  */
206
  function add_partial_shipped_to_order_statuses( $order_statuses ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  $new_order_statuses = array();
208
  foreach ( $order_statuses as $key => $status ) {
209
  $new_order_statuses[ $key ] = $status;
@@ -222,6 +338,14 @@ class WC_Advanced_Shipment_Tracking_Settings {
222
  return $statuses;
223
  }
224
 
 
 
 
 
 
 
 
 
225
  /*
226
  * Adding the updated-tracking order status to the default woocommerce order statuses
227
  */
@@ -246,6 +370,14 @@ class WC_Advanced_Shipment_Tracking_Settings {
246
  return $statuses;
247
  }
248
 
 
 
 
 
 
 
 
 
249
  /*
250
  * mark status as a paid.
251
  */
@@ -272,6 +404,16 @@ class WC_Advanced_Shipment_Tracking_Settings {
272
  return $bulk_actions;
273
  }
274
 
 
 
 
 
 
 
 
 
 
 
275
  /*
276
  * add bulk action
277
  * Change order status to Updated Tracking
@@ -297,8 +439,56 @@ class WC_Advanced_Shipment_Tracking_Settings {
297
  */
298
  function wc_renaming_order_status( $order_statuses ) {
299
 
300
- $enable = get_option( "wc_ast_status_shipped", 0);
301
- if( $enable == false )return $order_statuses;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
 
303
  foreach ( $order_statuses as $key => $status ) {
304
  $new_order_statuses[ $key ] = $status;
@@ -309,6 +499,30 @@ class WC_Advanced_Shipment_Tracking_Settings {
309
  return $order_statuses;
310
  }
311
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  /*
313
  * define the woocommerce_register_shop_order_post_statuses callback
314
  * rename filter
@@ -316,8 +530,8 @@ class WC_Advanced_Shipment_Tracking_Settings {
316
  */
317
  function filter_woocommerce_register_shop_order_post_statuses( $array ) {
318
 
319
- $enable = get_option( "wc_ast_status_shipped", 0);
320
- if( $enable == false )return $array;
321
 
322
  if( isset( $array[ 'wc-completed' ] ) ){
323
  $array[ 'wc-completed' ]['label_count'] = _n_noop( 'Shipped <span class="count">(%s)</span>', 'Shipped <span class="count">(%s)</span>', 'woo-advanced-shipment-tracking' );
@@ -330,8 +544,8 @@ class WC_Advanced_Shipment_Tracking_Settings {
330
  */
331
  function modify_bulk_actions($bulk_actions) {
332
 
333
- $enable = get_option( "wc_ast_status_shipped", 0);
334
- if( $enable == false )return $bulk_actions;
335
 
336
  if( isset( $bulk_actions['mark_completed'] ) ){
337
  $bulk_actions['mark_completed'] = __( 'Change status to shipped', 'woo-advanced-shipment-tracking' );
@@ -410,6 +624,14 @@ class WC_Advanced_Shipment_Tracking_Settings {
410
 
411
  public function ast_open_inline_tracking_form_fun(){
412
  $order_id = wc_clean($_POST['order_id']);
 
 
 
 
 
 
 
 
413
  global $wpdb;
414
  $WC_Countries = new WC_Countries();
415
  $countries = $WC_Countries->get_countries();
@@ -429,6 +651,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
429
  } else{
430
  $woo_shippment_table_name = $wpdb->prefix."woo_shippment_provider";
431
  }
 
432
  $shippment_countries = $wpdb->get_results( "SELECT shipping_country FROM $woo_shippment_table_name WHERE display_in_order = 1 GROUP BY shipping_country" );
433
 
434
  $shippment_providers = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name" );
@@ -436,8 +659,11 @@ class WC_Advanced_Shipment_Tracking_Settings {
436
  $default_provider = get_option("wc_ast_default_provider" );
437
  $wc_ast_default_mark_shipped = get_option("wc_ast_default_mark_shipped" );
438
 
439
- $wc_ast_status_shipped = get_option('wc_ast_status_shipped');
440
- if($wc_ast_status_shipped == 1){
 
 
 
441
  $change_order_status_label = __( 'Mark as Shipped?', 'woo-advanced-shipment-tracking' );
442
  $shipped_label = __( 'Shipped', 'woo-advanced-shipment-tracking' );
443
  } else{
@@ -450,9 +676,9 @@ class WC_Advanced_Shipment_Tracking_Settings {
450
  ?>
451
  <div id="" class="trackingpopup_wrapper add_tracking_popup" style="display:none;">
452
  <div class="trackingpopup_row">
453
- <h3 class="popup_title"><?php _e( 'Add Tracking Number', 'woo-advanced-shipment-tracking'); ?></h2>
454
  <form id="add_tracking_number_form" method="POST" class="add_tracking_number_form">
455
- <p class="form-field">
456
  <label for="tracking_number"><?php _e( 'Shipping Provider:', 'woo-advanced-shipment-tracking'); ?></label>
457
  <select class="chosen_select" id="tracking_provider" name="tracking_provider" style="width: 100%;max-width:100%;">
458
  <option value=""><?php _e( 'Shipping Provider:', 'woo-advanced-shipment-tracking' ); ?></option>
@@ -476,11 +702,11 @@ class WC_Advanced_Shipment_Tracking_Settings {
476
  </p>
477
  <p class="form-field tracking_number_field">
478
  <label for="tracking_number"><?php _e( 'Tracking number:', 'woo-advanced-shipment-tracking'); ?></label>
479
- <input type="text" class="short" style="" name="tracking_number" id="tracking_number" value="" placeholder="">
480
  </p>
481
  <p class="form-field tracking_product_code_field">
482
  <label for="tracking_product_code"><?php _e( 'Product Code:', 'woo-advanced-shipment-tracking'); ?></label>
483
- <input type="text" class="short" style="" name="tracking_product_code" id="tracking_product_code" value="" placeholder="">
484
  </p>
485
  <p class="form-field date_shipped_field">
486
  <label for="date_shipped"><?php _e( 'Date shipped:', 'woo-advanced-shipment-tracking'); ?></label>
@@ -507,7 +733,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
507
  <p class="" style="text-align:left;">
508
  <input type="hidden" name="action" value="add_inline_tracking_number">
509
  <input type="hidden" name="order_id" id="order_id" value="<?php echo $order_id; ?>">
510
- <input type="submit" name="Submit" value="Save Tracking" class="button-primary btn_green">
511
  </p>
512
  </form>
513
  </div>
@@ -521,7 +747,22 @@ class WC_Advanced_Shipment_Tracking_Settings {
521
  /*
522
  * define the item in the meta box by adding an item to the $actions array
523
  */
524
- function add_order_meta_box_actions( $actions ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
  $actions['resend_delivered_order_notification'] = __( 'Resend delivered order notification', 'woo-advanced-shipment-tracking' );
526
  return $actions;
527
  }
@@ -773,7 +1014,7 @@ class WC_Advanced_Shipment_Tracking_Settings {
773
 
774
  </div>
775
  <div class="widget_footer">
776
- <a class="" href="https://my.trackship.info/analytics/" target="blank"><?php _e( 'View more on TrackShip','woo-advanced-shipment-tracking' ); ?></a>
777
  </div>
778
  <?php }
779
 
@@ -959,4 +1200,4 @@ class WC_Advanced_Shipment_Tracking_Settings {
959
  <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>
960
  <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>
961
  <?php }
962
- }
55
 
56
  //rename order status + rename bulk action + rename filter
57
  add_filter( 'wc_order_statuses', array( $this, 'wc_renaming_order_status') );
58
+ add_action( 'woocommerce_my_account_my_orders_column_order-status', array( $this, 'wc_change_shipped_to_complete_in_orders') );
59
  add_filter( 'woocommerce_register_shop_order_post_statuses', array( $this, 'filter_woocommerce_register_shop_order_post_statuses'), 10, 1 );
60
  add_filter( 'bulk_actions-edit-shop_order', array( $this, 'modify_bulk_actions'), 50, 1 );
61
 
78
  add_filter( 'bulk_actions-edit-shop_order', array( $this, 'add_bulk_actions'), 50, 1 );
79
  }
80
 
81
+ //new order status
82
+ $completed_to_shipped = get_option( "wc_ast_completed_to_shipped", '');
83
+ $wc_ast_status_shipped_active = get_option( "wc_ast_status_shipped_active", 0);
84
+ if($completed_to_shipped == 'wc_ast_create_shipped' && $wc_ast_status_shipped_active == true ){
85
+ //register order status
86
+ add_action( 'init', array( $this, 'register_shipped_order_status') );
87
+ //add status after completed
88
+ add_filter( 'wc_order_statuses', array( $this, 'add_shipped_to_order_statuses') );
89
+ //Custom Statuses in admin reports
90
+ add_filter( 'woocommerce_reports_order_statuses', array( $this, 'include_shipped_order_status_to_reports'), 20, 1 );
91
+ // for automate woo to check order is paid
92
+ add_filter( 'woocommerce_order_is_paid_statuses', array( $this, 'shipped_woocommerce_order_is_paid_statuses' ) );
93
+ //add bulk action
94
+ add_filter( 'bulk_actions-edit-shop_order', array( $this, 'add_shipped_bulk_actions'), 50, 1 );
95
+ }
96
+
97
  //new order status
98
  $updated_tracking_status = get_option( "wc_ast_status_updated_tracking", 0);
99
  if( $updated_tracking_status == true ){
149
  /**
150
  * Register new status : Delivered
151
  **/
152
+ function register_order_status() {
153
  register_post_status( 'wc-delivered', array(
154
  'label' => __( 'Delivered', 'woo-advanced-shipment-tracking' ),
155
  'public' => true,
160
  ) );
161
  }
162
 
163
+ /**
164
+ * Register new status : Shipped
165
+ **/
166
+ function register_shipped_order_status() {
167
+ register_post_status( 'wc-shipped', array(
168
+ 'label' => __( 'Shipped', 'woo-advanced-shipment-tracking' ),
169
+ 'public' => true,
170
+ 'show_in_admin_status_list' => true,
171
+ 'show_in_admin_all_list' => true,
172
+ 'exclude_from_search' => false,
173
+ 'label_count' => _n_noop( 'Shipped <span class="count">(%s)</span>', 'Shipped <span class="count">(%s)</span>', 'woo-advanced-shipment-tracking' )
174
+ ) );
175
+ }
176
+
177
+
178
+
179
  /**
180
  * Register new status : Updated Tracking
181
  **/
208
  * add status after completed
209
  */
210
  function add_delivered_to_order_statuses( $order_statuses ) {
211
+
212
+ global $woocommerce, $post;
213
+ $wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
214
+ if(isset($post->ID)){
215
+ $check_if_virtual = $wast->check_if_virtual_order($post->ID);
216
+ if($check_if_virtual)return $order_statuses;
217
+
218
+ //$order = wc_get_order($post->ID);
219
+ //if(!empty($order)){
220
+ // // Iterating through order shipping items
221
+ // foreach( $order->get_items( 'shipping' ) as $item_id => $shipping_item_obj ){
222
+ // $shipping_method = $shipping_item_obj->get_method_id();
223
+ // }
224
+ // if( isset($shipping_method ) && $shipping_method == 'local_pickup' ) return $order_statuses;
225
+ //}
226
+ }
227
+
228
  $new_order_statuses = array();
229
  foreach ( $order_statuses as $key => $status ) {
230
  $new_order_statuses[ $key ] = $status;
236
  return $new_order_statuses;
237
  }
238
 
239
+ /*
240
+ * add status after completed
241
+ */
242
+ function add_shipped_to_order_statuses( $order_statuses ) {
243
+
244
+ global $woocommerce, $post;
245
+ $wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
246
+ if(isset($post->ID)){
247
+ $check_if_virtual = $wast->check_if_virtual_order($post->ID);
248
+ if($check_if_virtual)return $order_statuses;
249
+
250
+ //$order = wc_get_order($post->ID);
251
+ //if(!empty($order)){
252
+ // // Iterating through order shipping items
253
+ // foreach( $order->get_items( 'shipping' ) as $item_id => $shipping_item_obj ){
254
+ // $shipping_method = $shipping_item_obj->get_method_id();
255
+ // }
256
+ // if( isset($shipping_method ) && $shipping_method == 'local_pickup' ) return $order_statuses;
257
+ //}
258
+ }
259
+
260
+ $new_order_statuses = array();
261
+ foreach ( $order_statuses as $key => $status ) {
262
+ $new_order_statuses[ $key ] = $status;
263
+ if ( 'wc-completed' === $key ) {
264
+ $new_order_statuses['wc-shipped'] = __( 'Shipped', 'woo-advanced-shipment-tracking' );
265
+ }
266
+ }
267
+
268
+ return $new_order_statuses;
269
+ }
270
+
271
  /*
272
  * add status after completed
273
  */
274
  function add_updated_tracking_to_order_statuses( $order_statuses ) {
275
+
276
+ global $woocommerce, $post;
277
+ $wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
278
+ if(isset($post->ID)){
279
+ $check_if_virtual = $wast->check_if_virtual_order($post->ID);
280
+ if($check_if_virtual)return $order_statuses;
281
+
282
+ //$order = wc_get_order($post->ID);
283
+ //if(!empty($order)){
284
+ // // Iterating through order shipping items
285
+ // foreach( $order->get_items( 'shipping' ) as $item_id => $shipping_item_obj ){
286
+ // $shipping_method = $shipping_item_obj->get_method_id();
287
+ // }
288
+ // if( isset($shipping_method ) && $shipping_method == 'local_pickup' ) return $order_statuses;
289
+ //}
290
+ }
291
+
292
  $new_order_statuses = array();
293
  foreach ( $order_statuses as $key => $status ) {
294
  $new_order_statuses[ $key ] = $status;
303
  * add status after completed
304
  */
305
  function add_partial_shipped_to_order_statuses( $order_statuses ) {
306
+
307
+ global $woocommerce, $post;
308
+ $wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
309
+ if(isset($post->ID)){
310
+ $check_if_virtual = $wast->check_if_virtual_order($post->ID);
311
+ if($check_if_virtual)return $order_statuses;
312
+
313
+ //$order = wc_get_order($post->ID);
314
+ //if(!empty($order)){
315
+ // // Iterating through order shipping items
316
+ // foreach( $order->get_items( 'shipping' ) as $item_id => $shipping_item_obj ){
317
+ // $shipping_method = $shipping_item_obj->get_method_id();
318
+ // }
319
+ // if( isset($shipping_method ) && $shipping_method == 'local_pickup' ) return $order_statuses;
320
+ //}
321
+ }
322
+
323
  $new_order_statuses = array();
324
  foreach ( $order_statuses as $key => $status ) {
325
  $new_order_statuses[ $key ] = $status;
338
  return $statuses;
339
  }
340
 
341
+ /*
342
+ * Adding the shipped to the default woocommerce order statuses
343
+ */
344
+ function include_shipped_order_status_to_reports( $statuses ){
345
+ if($statuses)$statuses[] = 'shipped';
346
+ return $statuses;
347
+ }
348
+
349
  /*
350
  * Adding the updated-tracking order status to the default woocommerce order statuses
351
  */
370
  return $statuses;
371
  }
372
 
373
+ /*
374
+ * mark shipped status as a paid.
375
+ */
376
+ function shipped_woocommerce_order_is_paid_statuses( $statuses ) {
377
+ $statuses[] = 'shipped';
378
+ return $statuses;
379
+ }
380
+
381
  /*
382
  * mark status as a paid.
383
  */
404
  return $bulk_actions;
405
  }
406
 
407
+ /*
408
+ * add bulk action
409
+ * Change order status to shipped
410
+ */
411
+ function add_shipped_bulk_actions( $bulk_actions ){
412
+ $lable = wc_get_order_status_name( 'delivered' );
413
+ $bulk_actions['mark_delivered'] = __( 'Change status to Shipped', 'woo-advanced-shipment-tracking' );
414
+ return $bulk_actions;
415
+ }
416
+
417
  /*
418
  * add bulk action
419
  * Change order status to Updated Tracking
439
  */
440
  function wc_renaming_order_status( $order_statuses ) {
441
 
442
+ global $woocommerce, $post, $order;
443
+ $wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
444
+ /*
445
+ if(get_query_var('view-order')){
446
+ $order_id = get_query_var('view-order');
447
+ $check_if_virtual = $wast->check_if_virtual_order($order_id);
448
+ if($check_if_virtual)return $order_statuses;
449
+
450
+ $order = wc_get_order($order_id);
451
+ if(!empty($order)){
452
+ // Iterating through order shipping items
453
+ foreach( $order->get_items( 'shipping' ) as $item_id => $shipping_item_obj ){
454
+ $shipping_method = $shipping_item_obj->get_method_id();
455
+ }
456
+ if( isset($shipping_method ) && $shipping_method == 'local_pickup' ) return $order_statuses;
457
+ }
458
+ }
459
+
460
+ if(get_query_var('order-received')){
461
+ $order_id = get_query_var('order-received');
462
+ $check_if_virtual = $wast->check_if_virtual_order($order_id);
463
+ if($check_if_virtual)return $order_statuses;
464
+
465
+ $order = wc_get_order($order_id);
466
+ if(!empty($order)){
467
+ // Iterating through order shipping items
468
+ foreach( $order->get_items( 'shipping' ) as $item_id => $shipping_item_obj ){
469
+ $shipping_method = $shipping_item_obj->get_method_id();
470
+ }
471
+ if( isset($shipping_method ) && $shipping_method == 'local_pickup' ) return $order_statuses;
472
+ }
473
+ }
474
+
475
+ if(isset($post->ID)){
476
+ $check_if_virtual = $wast->check_if_virtual_order($post->ID);
477
+ if($check_if_virtual)return $order_statuses;
478
+
479
+ $order = wc_get_order($post->ID);
480
+ if(!empty($order)){
481
+ // Iterating through order shipping items
482
+ foreach( $order->get_items( 'shipping' ) as $item_id => $shipping_item_obj ){
483
+ $shipping_method = $shipping_item_obj->get_method_id();
484
+ }
485
+ if( isset($shipping_method ) && $shipping_method == 'local_pickup' ) return $order_statuses;
486
+ }
487
+ } */
488
+
489
+ $wc_ast_completed_to_shipped = get_option( "wc_ast_completed_to_shipped" , '');
490
+
491
+ if( $wc_ast_completed_to_shipped != 'wc_ast_rename_to_shipped' )return $order_statuses;
492
 
493
  foreach ( $order_statuses as $key => $status ) {
494
  $new_order_statuses[ $key ] = $status;
499
  return $order_statuses;
500
  }
501
 
502
+ function wc_change_shipped_to_complete_in_orders($order){
503
+
504
+ $wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
505
+ if($order->get_id()){
506
+ $check_if_virtual = $wast->check_if_virtual_order($order->get_id());
507
+ if($check_if_virtual){
508
+ remove_filter( 'wc_order_statuses', array( $this, 'wc_renaming_order_status') );
509
+ } else{
510
+ add_filter( 'wc_order_statuses', array( $this, 'wc_renaming_order_status') );
511
+ }
512
+ // Iterating through order shipping items
513
+
514
+ //foreach( $order->get_items( 'shipping' ) as $item_id => $shipping_item_obj ){
515
+ // $shipping_method = $shipping_item_obj->get_method_id();
516
+ //}
517
+ //if( isset($shipping_method ) && $shipping_method == 'local_pickup' ){
518
+ // remove_filter( 'wc_order_statuses', array( $this, 'wc_renaming_order_status') );
519
+ //} else{
520
+ // add_filter( 'wc_order_statuses', array( $this, 'wc_renaming_order_status') );
521
+ //}
522
+ }
523
+ echo esc_html( wc_get_order_status_name( $order->get_status() ) );
524
+ }
525
+
526
  /*
527
  * define the woocommerce_register_shop_order_post_statuses callback
528
  * rename filter
530
  */
531
  function filter_woocommerce_register_shop_order_post_statuses( $array ) {
532
 
533
+ $wc_ast_completed_to_shipped = get_option( "wc_ast_completed_to_shipped", '');
534
+ if($wc_ast_completed_to_shipped != 'wc_ast_rename_to_shipped')return $array;
535
 
536
  if( isset( $array[ 'wc-completed' ] ) ){
537
  $array[ 'wc-completed' ]['label_count'] = _n_noop( 'Shipped <span class="count">(%s)</span>', 'Shipped <span class="count">(%s)</span>', 'woo-advanced-shipment-tracking' );
544
  */
545
  function modify_bulk_actions($bulk_actions) {
546
 
547
+ $wc_ast_completed_to_shipped = get_option('wc_ast_completed_to_shipped');
548
+ if($wc_ast_completed_to_shipped == 'wc_ast_rename_to_shipped')return $bulk_actions;
549
 
550
  if( isset( $bulk_actions['mark_completed'] ) ){
551
  $bulk_actions['mark_completed'] = __( 'Change status to shipped', 'woo-advanced-shipment-tracking' );
624
 
625
  public function ast_open_inline_tracking_form_fun(){
626
  $order_id = wc_clean($_POST['order_id']);
627
+
628
+ $wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
629
+ $custom_order_number = $wast->get_custom_order_number($order_id);
630
+
631
+ if(empty($custom_order_number)){
632
+ $custom_order_number = $order_id;
633
+ }
634
+
635
  global $wpdb;
636
  $WC_Countries = new WC_Countries();
637
  $countries = $WC_Countries->get_countries();
651
  } else{
652
  $woo_shippment_table_name = $wpdb->prefix."woo_shippment_provider";
653
  }
654
+
655
  $shippment_countries = $wpdb->get_results( "SELECT shipping_country FROM $woo_shippment_table_name WHERE display_in_order = 1 GROUP BY shipping_country" );
656
 
657
  $shippment_providers = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name" );
659
  $default_provider = get_option("wc_ast_default_provider" );
660
  $wc_ast_default_mark_shipped = get_option("wc_ast_default_mark_shipped" );
661
 
662
+ $wc_ast_completed_to_shipped = get_option('wc_ast_completed_to_shipped','');
663
+ if($wc_ast_completed_to_shipped == 'wc_ast_rename_to_shipped'){
664
+ $change_order_status_label = __( 'Mark as Shipped?', 'woo-advanced-shipment-tracking' );
665
+ $shipped_label = __( 'Shipped', 'woo-advanced-shipment-tracking' );
666
+ } else if($wc_ast_completed_to_shipped == 'wc_ast_create_shipped' && get_option('wc_ast_status_shipped_active')){
667
  $change_order_status_label = __( 'Mark as Shipped?', 'woo-advanced-shipment-tracking' );
668
  $shipped_label = __( 'Shipped', 'woo-advanced-shipment-tracking' );
669
  } else{
676
  ?>
677
  <div id="" class="trackingpopup_wrapper add_tracking_popup" style="display:none;">
678
  <div class="trackingpopup_row">
679
+ <h3 class="popup_title"><?php _e( 'Add Tracking Number', 'woo-advanced-shipment-tracking'); ?> - #<?php echo $custom_order_number; ?></h2>
680
  <form id="add_tracking_number_form" method="POST" class="add_tracking_number_form">
681
+ <p class="form-field" style="margin-bottom: 10px;">
682
  <label for="tracking_number"><?php _e( 'Shipping Provider:', 'woo-advanced-shipment-tracking'); ?></label>
683
  <select class="chosen_select" id="tracking_provider" name="tracking_provider" style="width: 100%;max-width:100%;">
684
  <option value=""><?php _e( 'Shipping Provider:', 'woo-advanced-shipment-tracking' ); ?></option>
702
  </p>
703
  <p class="form-field tracking_number_field">
704
  <label for="tracking_number"><?php _e( 'Tracking number:', 'woo-advanced-shipment-tracking'); ?></label>
705
+ <input type="text" class="short" style="" name="tracking_number" id="tracking_number" value="">
706
  </p>
707
  <p class="form-field tracking_product_code_field">
708
  <label for="tracking_product_code"><?php _e( 'Product Code:', 'woo-advanced-shipment-tracking'); ?></label>
709
+ <input type="text" class="short" style="" name="tracking_product_code" id="tracking_product_code" value="">
710
  </p>
711
  <p class="form-field date_shipped_field">
712
  <label for="date_shipped"><?php _e( 'Date shipped:', 'woo-advanced-shipment-tracking'); ?></label>
733
  <p class="" style="text-align:left;">
734
  <input type="hidden" name="action" value="add_inline_tracking_number">
735
  <input type="hidden" name="order_id" id="order_id" value="<?php echo $order_id; ?>">
736
+ <input type="submit" name="Submit" value="<?php _e( 'Save Tracking', 'woo-advanced-shipment-tracking'); ?>" class="button-primary btn_green">
737
  </p>
738
  </form>
739
  </div>
747
  /*
748
  * define the item in the meta box by adding an item to the $actions array
749
  */
750
+ function add_order_meta_box_actions( $actions ) {
751
+ global $woocommerce, $post;
752
+ $wast = WC_Advanced_Shipment_Tracking_Actions::get_instance();
753
+ if(isset($post->ID)){
754
+ $check_if_virtual = $wast->check_if_virtual_order($post->ID);
755
+ if($check_if_virtual)return $actions;
756
+
757
+ //$order = wc_get_order($post->ID);
758
+ //
759
+ //// Iterating through order shipping items
760
+ //foreach( $order->get_items( 'shipping' ) as $item_id => $shipping_item_obj ){
761
+ // $shipping_method = $shipping_item_obj->get_method_id();
762
+ //}
763
+ //if( isset($shipping_method ) && $shipping_method == 'local_pickup' ) return $actions;
764
+ }
765
+
766
  $actions['resend_delivered_order_notification'] = __( 'Resend delivered order notification', 'woo-advanced-shipment-tracking' );
767
  return $actions;
768
  }
1014
 
1015
  </div>
1016
  <div class="widget_footer">
1017
+ <a class="" href="https://trackship.info/my-account/analytics/" target="blank"><?php _e( 'View more on TrackShip','woo-advanced-shipment-tracking' ); ?></a>
1018
  </div>
1019
  <?php }
1020
 
1200
  <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>
1201
  <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>
1202
  <?php }
1203
+ }
includes/class-wc-advanced-shipment-tracking.php CHANGED
@@ -62,7 +62,8 @@ class WC_Advanced_Shipment_Tracking_Actions {
62
  foreach ( $results as $row ) {
63
  $shippment_providers[ $row->ts_slug ] = array(
64
  'provider_name'=> $row->provider_name,
65
- 'provider_url' => $row->provider_url,
 
66
  );
67
  }
68
 
@@ -236,8 +237,8 @@ class WC_Advanced_Shipment_Tracking_Actions {
236
  $default_provider = get_option("wc_ast_default_provider" );
237
  $wc_ast_default_mark_shipped = get_option("wc_ast_default_mark_shipped" );
238
 
239
- $wc_ast_status_shipped = get_option('wc_ast_status_shipped');
240
- if($wc_ast_status_shipped == 1){
241
  $change_order_status_label = __( 'Mark as Shipped?', 'woo-advanced-shipment-tracking' );
242
  $shipped_label = __( 'Shipped', 'woo-advanced-shipment-tracking' );
243
  } else{
@@ -319,6 +320,16 @@ class WC_Advanced_Shipment_Tracking_Actions {
319
  * Add the meta box for shipment info on the order page
320
  */
321
  public function add_meta_box() {
 
 
 
 
 
 
 
 
 
 
322
  add_meta_box( 'woocommerce-advanced-shipment-tracking', __( 'Shipment Tracking', 'woo-advanced-shipment-tracking' ), array( $this, 'meta_box' ), 'shop_order', 'side', 'high' );
323
  }
324
 
@@ -403,7 +414,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
403
  */
404
  public function meta_box() {
405
  global $post;
406
- global $wpdb;
407
 
408
  $WC_Countries = new WC_Countries();
409
  $countries = $WC_Countries->get_countries();
@@ -442,14 +453,20 @@ class WC_Advanced_Shipment_Tracking_Actions {
442
  $cbvalue = 1;
443
  }
444
  }
445
-
446
- $wc_ast_status_shipped = get_option('wc_ast_status_shipped');
447
- if($wc_ast_status_shipped == 1){
448
  $change_order_status_label = __( 'Mark as Shipped?', 'woo-advanced-shipment-tracking' );
449
  $shipped_label = 'Shipped';
 
 
 
 
 
450
  } else{
451
  $change_order_status_label = __( 'Mark as Completed?', 'woo-advanced-shipment-tracking' );
452
  $shipped_label = 'Completed';
 
453
  }
454
 
455
 
@@ -465,7 +482,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
465
  echo '<button class="button button-show-tracking-form" type="button">' . __( 'Add Tracking Info', 'woo-advanced-shipment-tracking' ) . '</button>';
466
 
467
  echo '<div id="advanced-shipment-tracking-form">';
468
-
469
  echo '<p class="form-field tracking_provider_field"><label for="tracking_provider">' . __( 'Shipping Provider:', 'woo-advanced-shipment-tracking' ) . '</label><br/><select id="tracking_provider" name="tracking_provider" class="chosen_select" style="width:100%;">';
470
  echo '<option value="">'.__( 'Select Provider', 'woo-advanced-shipment-tracking' ).'</option>';
471
  foreach($shippment_countries as $s_c){
@@ -508,6 +525,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
508
  'placeholder' => '',
509
  'description' => '',
510
  'value' => '',
 
511
  ) );
512
 
513
  woocommerce_wp_text_input( array(
@@ -685,13 +703,20 @@ class WC_Advanced_Shipment_Tracking_Actions {
685
 
686
  $tracking_item = $this->add_tracking_item( $order_id, $args );
687
 
688
- if($_POST['change_order_to_shipped'] == 'change_order_to_shipped'){
689
-
690
- if('completed' == $order->get_status()){
691
- WC()->mailer()->emails['WC_Email_Customer_Completed_Order']->trigger( $order_id, $order );
692
- $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
 
 
 
693
  } else{
694
- $order->update_status('completed');
 
 
 
 
695
  }
696
  } elseif($_POST['change_order_to_shipped'] == 'change_order_to_partial_shipped'){
697
  $previous_order_status = $order->get_status();
@@ -727,19 +752,24 @@ class WC_Advanced_Shipment_Tracking_Actions {
727
  );
728
 
729
  $tracking_item = $this->add_tracking_item( $order_id, $args );
730
-
731
- if($_POST['change_order_to_shipped'] == 'change_order_to_shipped' || $_POST['change_order_to_shipped'] == 'yes'){
732
- $order = new WC_Order($order_id);
733
- if('completed' == $order->get_status()){
734
- $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
 
 
 
 
735
  } else{
736
- $order->update_status('completed');
 
 
 
 
737
  }
738
- } elseif($_POST['change_order_to_shipped'] == 'change_order_to_partial_shipped'){
739
- $order = new WC_Order($order_id);
740
-
741
- $previous_order_status = $order->get_status();
742
-
743
  if('partial-shipped' == $previous_order_status){
744
  WC()->mailer()->emails['WC_Email_Customer_Partial_Shipped_Order']->trigger( $order_id, $order );
745
  }
@@ -1028,6 +1058,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
1028
  foreach ( $this->get_providers() as $provider => $format ) {
1029
  if ( $provider === $tracking_item['tracking_provider'] ) {
1030
  $link_format = $format['provider_url'];
 
1031
  $formatted['formatted_tracking_provider'] = $format['provider_name'];
1032
  break;
1033
  }
@@ -1036,12 +1067,12 @@ class WC_Advanced_Shipment_Tracking_Actions {
1036
  break;
1037
  }
1038
  }
1039
-
1040
  $tracking_page = get_option('wc_ast_trackship_page_id');
1041
  $wc_ast_api_key = get_option('wc_ast_api_key');
1042
  $use_tracking_page = get_option('wc_ast_use_tracking_page');
1043
 
1044
- if( $wc_ast_api_key && $use_tracking_page && $status != 'carrier_unsupported'){
1045
  $order_key = $order->get_order_key();
1046
  $formatted['formatted_tracking_link'] = get_permalink( $tracking_page ).'?order_id='.$order_id.'&order_key='.$order_key;
1047
  } else {
@@ -1201,36 +1232,40 @@ class WC_Advanced_Shipment_Tracking_Actions {
1201
  }
1202
  } else{
1203
  $tracking_items[] = $tracking_item;
1204
- }
1205
- //echo '<pre>';print_r($args['products_list']);echo '</pre>';
1206
- //echo '<pre>';print_r($tracking_items);echo '</pre>';exit;
1207
 
1208
  $this->save_tracking_items( $order_id, $tracking_items );
1209
 
1210
  $status_shipped = (isset($tracking_item["status_shipped"])?$tracking_item["status_shipped"]:"");
1211
  $ast_admin = WC_Advanced_Shipment_Tracking_Admin::get_instance();
1212
- if( $status_shipped == 1){
1213
- $order = new WC_Order( $order_id );
1214
- if('completed' == $order->get_status()){
1215
- $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
 
 
 
 
 
1216
  } else{
1217
- $order->update_status('completed');
1218
- }
 
 
 
 
1219
  }
1220
 
1221
  if( $status_shipped == 2){
1222
  $wc_ast_status_partial_shipped = get_option('wc_ast_status_partial_shipped');
1223
- if($wc_ast_status_partial_shipped){
1224
- $order = new WC_Order( $order_id );
1225
  $order->update_status('partial-shipped');
1226
  $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
1227
  }
1228
  }
1229
 
1230
  $formated_tracking_item = $this->get_formatted_tracking_item( $order_id, $tracking_item );
1231
- $tracking_provider = $formated_tracking_item['formatted_tracking_provider'];
1232
-
1233
- $order = wc_get_order( $order_id );
1234
 
1235
  // The text for the note
1236
  $note = sprintf(__("Order was shipped with %s and tracking number is: %s", 'woo-advanced-shipment-tracking'), $tracking_provider, $tracking_item['tracking_number'] );
@@ -1299,20 +1334,38 @@ class WC_Advanced_Shipment_Tracking_Actions {
1299
 
1300
  $status_shipped = (isset($tracking_item["status_shipped"])?$tracking_item["status_shipped"]:"");
1301
  $ast_admin = WC_Advanced_Shipment_Tracking_Admin::get_instance();
1302
- if( $status_shipped == 1){
1303
- $order = new WC_Order( $order_id );
1304
- if('completed' == $order->get_status()){
1305
- $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
 
 
 
 
 
1306
  } else{
1307
- $order->update_status('completed');
1308
- }
 
 
 
 
1309
  }
1310
 
1311
- if( $status_shipped == 2){
1312
- $order = new WC_Order( $order_id );
1313
  $order->update_status('partial-shipped');
1314
  $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
1315
  }
 
 
 
 
 
 
 
 
 
 
1316
  return $tracking_item;
1317
  }
1318
 
@@ -1508,6 +1561,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
1508
  $alg_wc_custom_order_numbers_enabled = get_option('alg_wc_custom_order_numbers_enabled');
1509
  $alg_wc_custom_order_numbers_prefix = get_option('alg_wc_custom_order_numbers_prefix');
1510
  $new_order_id = str_replace($alg_wc_custom_order_numbers_prefix,'',$order_id);
 
1511
  if($alg_wc_custom_order_numbers_enabled == 'yes'){
1512
  $args = array(
1513
  'post_type' => 'shop_order',
@@ -1519,7 +1573,7 @@ class WC_Advanced_Shipment_Tracking_Actions {
1519
  'value' => $new_order_id,
1520
  ),
1521
  ),
1522
- 'post_status' => array('wc-pending', 'wc-processing', 'wc-on-hold', 'wc-completed', 'wc-delivered', 'wc-cancelled', 'wc-refunded', 'wc-failed','wc-bit-payment') ,
1523
  );
1524
  $posts = get_posts( $args );
1525
  $my_query = new WP_Query( $args );
@@ -1710,4 +1764,29 @@ class WC_Advanced_Shipment_Tracking_Actions {
1710
  }
1711
  return $value;
1712
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1713
  }
62
  foreach ( $results as $row ) {
63
  $shippment_providers[ $row->ts_slug ] = array(
64
  'provider_name'=> $row->provider_name,
65
+ 'provider_url' => $row->provider_url,
66
+ 'trackship_supported' => $row->trackship_supported,
67
  );
68
  }
69
 
237
  $default_provider = get_option("wc_ast_default_provider" );
238
  $wc_ast_default_mark_shipped = get_option("wc_ast_default_mark_shipped" );
239
 
240
+ $wc_ast_completed_to_shipped = get_option('wc_ast_completed_to_shipped','wc_ast_rename_to_shipped');
241
+ if($wc_ast_completed_to_shipped == 'wc_ast_rename_to_shipped'){
242
  $change_order_status_label = __( 'Mark as Shipped?', 'woo-advanced-shipment-tracking' );
243
  $shipped_label = __( 'Shipped', 'woo-advanced-shipment-tracking' );
244
  } else{
320
  * Add the meta box for shipment info on the order page
321
  */
322
  public function add_meta_box() {
323
+ global $post;
324
+ $check_if_virtual = $this->check_if_virtual_order($post->ID);
325
+ if($check_if_virtual)return;
326
+
327
+ //$order = wc_get_order($post->ID);
328
+ //foreach( $order->get_items( 'shipping' ) as $item_id => $shipping_item_obj ){
329
+ // $shipping_method = $shipping_item_obj->get_method_id();
330
+ //}
331
+ //if( isset($shipping_method ) && $shipping_method == 'local_pickup' ) return;
332
+
333
  add_meta_box( 'woocommerce-advanced-shipment-tracking', __( 'Shipment Tracking', 'woo-advanced-shipment-tracking' ), array( $this, 'meta_box' ), 'shop_order', 'side', 'high' );
334
  }
335
 
414
  */
415
  public function meta_box() {
416
  global $post;
417
+ global $wpdb;
418
 
419
  $WC_Countries = new WC_Countries();
420
  $countries = $WC_Countries->get_countries();
453
  $cbvalue = 1;
454
  }
455
  }
456
+ $change_order_status = '';
457
+ $wc_ast_completed_to_shipped = get_option('wc_ast_completed_to_shipped','');
458
+ if($wc_ast_completed_to_shipped == 'wc_ast_rename_to_shipped'){
459
  $change_order_status_label = __( 'Mark as Shipped?', 'woo-advanced-shipment-tracking' );
460
  $shipped_label = 'Shipped';
461
+ $change_order_status = 'wc-completed';
462
+ } else if($wc_ast_completed_to_shipped == 'wc_ast_create_shipped' && get_option('wc_ast_status_shipped_active')){
463
+ $change_order_status_label = __( 'Mark as Shipped?', 'woo-advanced-shipment-tracking' );
464
+ $shipped_label = __( 'Shipped', 'woo-advanced-shipment-tracking' );
465
+ $change_order_status = 'wc-shipped';
466
  } else{
467
  $change_order_status_label = __( 'Mark as Completed?', 'woo-advanced-shipment-tracking' );
468
  $shipped_label = 'Completed';
469
+ $change_order_status = 'wc-completed';
470
  }
471
 
472
 
482
  echo '<button class="button button-show-tracking-form" type="button">' . __( 'Add Tracking Info', 'woo-advanced-shipment-tracking' ) . '</button>';
483
 
484
  echo '<div id="advanced-shipment-tracking-form">';
485
+ echo '<input type="hidden" name="change_order_status" id="change_order_status" value="'.$change_order_status.'">';
486
  echo '<p class="form-field tracking_provider_field"><label for="tracking_provider">' . __( 'Shipping Provider:', 'woo-advanced-shipment-tracking' ) . '</label><br/><select id="tracking_provider" name="tracking_provider" class="chosen_select" style="width:100%;">';
487
  echo '<option value="">'.__( 'Select Provider', 'woo-advanced-shipment-tracking' ).'</option>';
488
  foreach($shippment_countries as $s_c){
525
  'placeholder' => '',
526
  'description' => '',
527
  'value' => '',
528
+ 'autofocus' => true,
529
  ) );
530
 
531
  woocommerce_wp_text_input( array(
703
 
704
  $tracking_item = $this->add_tracking_item( $order_id, $args );
705
 
706
+ if($_POST['change_order_to_shipped'] == 'change_order_to_shipped'){
707
+ $wc_ast_completed_to_shipped = get_option('wc_ast_completed_to_shipped','wc_ast_rename_to_shipped');
708
+ if($wc_ast_completed_to_shipped == 'wc_ast_create_shipped' && get_option('wc_ast_status_shipped_active')){
709
+ if('shipped' == $order->get_status()){
710
+ $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
711
+ } else{
712
+ $order->update_status('shipped');
713
+ }
714
  } else{
715
+ if('completed' == $order->get_status()){
716
+ $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
717
+ } else{
718
+ $order->update_status('completed');
719
+ }
720
  }
721
  } elseif($_POST['change_order_to_shipped'] == 'change_order_to_partial_shipped'){
722
  $previous_order_status = $order->get_status();
752
  );
753
 
754
  $tracking_item = $this->add_tracking_item( $order_id, $args );
755
+ $order = new WC_Order($order_id);
756
+ if($_POST['change_order_to_shipped'] == 'change_order_to_shipped' || $_POST['change_order_to_shipped'] == 'yes'){
757
+ $wc_ast_completed_to_shipped = get_option('wc_ast_completed_to_shipped','wc_ast_rename_to_shipped');
758
+ if($wc_ast_completed_to_shipped == 'wc_ast_create_shipped' && get_option('wc_ast_status_shipped_active')){
759
+ if('shipped' == $order->get_status()){
760
+ $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
761
+ } else{
762
+ $order->update_status('shipped');
763
+ }
764
  } else{
765
+ if('completed' == $order->get_status()){
766
+ $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
767
+ } else{
768
+ $order->update_status('completed');
769
+ }
770
  }
771
+ } elseif($_POST['change_order_to_shipped'] == 'change_order_to_partial_shipped'){
772
+ $previous_order_status = $order->get_status();
 
 
 
773
  if('partial-shipped' == $previous_order_status){
774
  WC()->mailer()->emails['WC_Email_Customer_Partial_Shipped_Order']->trigger( $order_id, $order );
775
  }
1058
  foreach ( $this->get_providers() as $provider => $format ) {
1059
  if ( $provider === $tracking_item['tracking_provider'] ) {
1060
  $link_format = $format['provider_url'];
1061
+ $trackship_supported = $format['trackship_supported'];
1062
  $formatted['formatted_tracking_provider'] = $format['provider_name'];
1063
  break;
1064
  }
1067
  break;
1068
  }
1069
  }
1070
+
1071
  $tracking_page = get_option('wc_ast_trackship_page_id');
1072
  $wc_ast_api_key = get_option('wc_ast_api_key');
1073
  $use_tracking_page = get_option('wc_ast_use_tracking_page');
1074
 
1075
+ if( $wc_ast_api_key && $use_tracking_page && $trackship_supported == 1 && $status != 'carrier_unsupported'){
1076
  $order_key = $order->get_order_key();
1077
  $formatted['formatted_tracking_link'] = get_permalink( $tracking_page ).'?order_id='.$order_id.'&order_key='.$order_key;
1078
  } else {
1232
  }
1233
  } else{
1234
  $tracking_items[] = $tracking_item;
1235
+ }
 
 
1236
 
1237
  $this->save_tracking_items( $order_id, $tracking_items );
1238
 
1239
  $status_shipped = (isset($tracking_item["status_shipped"])?$tracking_item["status_shipped"]:"");
1240
  $ast_admin = WC_Advanced_Shipment_Tracking_Admin::get_instance();
1241
+ $order = new WC_Order( $order_id );
1242
+ if( $status_shipped == 1){
1243
+ $wc_ast_completed_to_shipped = get_option('wc_ast_completed_to_shipped','wc_ast_rename_to_shipped');
1244
+ if($wc_ast_completed_to_shipped == 'wc_ast_create_shipped' && get_option('wc_ast_status_shipped_active')){
1245
+ if('shipped' == $order->get_status()){
1246
+ $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
1247
+ } else{
1248
+ $order->update_status('shipped');
1249
+ }
1250
  } else{
1251
+ if('completed' == $order->get_status()){
1252
+ $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
1253
+ } else{
1254
+ $order->update_status('completed');
1255
+ }
1256
+ }
1257
  }
1258
 
1259
  if( $status_shipped == 2){
1260
  $wc_ast_status_partial_shipped = get_option('wc_ast_status_partial_shipped');
1261
+ if($wc_ast_status_partial_shipped){
 
1262
  $order->update_status('partial-shipped');
1263
  $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
1264
  }
1265
  }
1266
 
1267
  $formated_tracking_item = $this->get_formatted_tracking_item( $order_id, $tracking_item );
1268
+ $tracking_provider = $formated_tracking_item['formatted_tracking_provider'];
 
 
1269
 
1270
  // The text for the note
1271
  $note = sprintf(__("Order was shipped with %s and tracking number is: %s", 'woo-advanced-shipment-tracking'), $tracking_provider, $tracking_item['tracking_number'] );
1334
 
1335
  $status_shipped = (isset($tracking_item["status_shipped"])?$tracking_item["status_shipped"]:"");
1336
  $ast_admin = WC_Advanced_Shipment_Tracking_Admin::get_instance();
1337
+ $order = new WC_Order( $order_id );
1338
+ if( $status_shipped == 1){
1339
+ $wc_ast_completed_to_shipped = get_option('wc_ast_completed_to_shipped','wc_ast_rename_to_shipped');
1340
+ if($wc_ast_completed_to_shipped == 'wc_ast_create_shipped' && get_option('wc_ast_status_shipped_active')){
1341
+ if('shipped' == $order->get_status()){
1342
+ $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
1343
+ } else{
1344
+ $order->update_status('shipped');
1345
+ }
1346
  } else{
1347
+ if('completed' == $order->get_status()){
1348
+ $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
1349
+ } else{
1350
+ $order->update_status('completed');
1351
+ }
1352
+ }
1353
  }
1354
 
1355
+ if( $status_shipped == 2){
 
1356
  $order->update_status('partial-shipped');
1357
  $ast_admin->trigger_woocommerce_order_status_completed( $order_id );
1358
  }
1359
+
1360
+ $formated_tracking_item = $this->get_formatted_tracking_item( $order_id, $tracking_item );
1361
+ $tracking_provider = $formated_tracking_item['formatted_tracking_provider'];
1362
+
1363
+ // The text for the note
1364
+ $note = sprintf(__("Order was shipped with %s and tracking number is: %s", 'woo-advanced-shipment-tracking'), $tracking_provider, $tracking_item['tracking_number'] );
1365
+
1366
+ // Add the note
1367
+ $order->add_order_note( $note );
1368
+
1369
  return $tracking_item;
1370
  }
1371
 
1561
  $alg_wc_custom_order_numbers_enabled = get_option('alg_wc_custom_order_numbers_enabled');
1562
  $alg_wc_custom_order_numbers_prefix = get_option('alg_wc_custom_order_numbers_prefix');
1563
  $new_order_id = str_replace($alg_wc_custom_order_numbers_prefix,'',$order_id);
1564
+
1565
  if($alg_wc_custom_order_numbers_enabled == 'yes'){
1566
  $args = array(
1567
  'post_type' => 'shop_order',
1573
  'value' => $new_order_id,
1574
  ),
1575
  ),
1576
+ 'post_status' => array_keys( wc_get_order_statuses() ) ,
1577
  );
1578
  $posts = get_posts( $args );
1579
  $my_query = new WP_Query( $args );
1764
  }
1765
  return $value;
1766
  }
1767
+
1768
+ public function check_if_virtual_order($order_id){
1769
+
1770
+ $order = wc_get_order( $order_id );
1771
+
1772
+ if( is_a( $order, 'WC_Order' ) ) {
1773
+
1774
+ $order_items = $order->get_items();
1775
+
1776
+ foreach( $order_items as $order_item_id => $order_item ) {
1777
+
1778
+ $product = wc_get_product( $order_item['product_id'] );
1779
+
1780
+ if ( $order_item->get_variation_id() ) {
1781
+ if ( 'product_variation' === get_post_type( $order_item->get_variation_id() ) )
1782
+ $product = wc_get_product( $order_item->get_variation_id() );
1783
+ }
1784
+
1785
+ if( $product ) {
1786
+ if( $product->is_virtual() || $product->is_downloadable()) return true;
1787
+ }
1788
+ }
1789
+ }
1790
+ return false;
1791
+ }
1792
  }
includes/customizer/class-wc-shipped-email-customizer.php ADDED
@@ -0,0 +1,430 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customizer Setup and Custom Controls
4
+ *
5
+ */
6
+
7
+ /**
8
+ * Adds the individual sections, settings, and controls to the theme customizer
9
+ */
10
+ class wcast_shipped_customizer_email {
11
+ // Get our default values
12
+ public function __construct() {
13
+ // Get our Customizer defaults
14
+ $this->defaults = $this->wcast_generate_defaults();
15
+
16
+ // Register our sample default controls
17
+ add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
18
+
19
+ // Only proceed if this is own request.
20
+ if ( ! wcast_shipped_customizer_email::is_own_customizer_request() && ! wcast_shipped_customizer_email::is_own_preview_request() ) {
21
+ return;
22
+ }
23
+ add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_panels' ) );
24
+ // Register our sections
25
+ add_action( 'customize_register', array( wcast_customizer(), 'wcast_add_customizer_sections' ) );
26
+
27
+ // Remove unrelated components.
28
+ add_filter( 'customize_loaded_components', array( wcast_customizer(), 'remove_unrelated_components' ), 99, 2 );
29
+
30
+ // Remove unrelated sections.
31
+ add_filter( 'customize_section_active', array( wcast_customizer(), 'remove_unrelated_sections' ), 10, 2 );
32
+
33
+ // Unhook divi front end.
34
+ add_action( 'woomail_footer', array( wcast_customizer(), 'unhook_divi' ), 10 );
35
+
36
+ // Unhook Flatsome js
37
+ add_action( 'customize_preview_init', array( wcast_customizer(), 'unhook_flatsome' ), 50 );
38
+
39
+ add_filter( 'customize_controls_enqueue_scripts', array( wcast_customizer(), 'enqueue_customizer_scripts' ) );
40
+
41
+ add_action( 'parse_request', array( $this, 'set_up_preview' ) );
42
+
43
+ add_action( 'customize_preview_init', array( $this, 'enqueue_preview_scripts' ) );
44
+ }
45
+
46
+ public function enqueue_preview_scripts() {
47
+ wp_enqueue_script('wcast-email-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
48
+ wp_enqueue_style('wcast-preview-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/preview-styles.css', array(), wc_advanced_shipment_tracking()->version );
49
+ // Send variables to Javascript
50
+ $preview_id = get_theme_mod('wcast_shipped_preview_order_id');
51
+ wp_localize_script('wcast-email-preview-scripts', 'wcast_preview', array(
52
+ 'site_title' => $this->get_blogname(),
53
+ 'order_number' => $preview_id,
54
+ ));
55
+ }
56
+
57
+ /**
58
+ * Get blog name formatted for emails.
59
+ *
60
+ * @return string
61
+ */
62
+ public function get_blogname() {
63
+ return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
64
+ }
65
+
66
+ /**
67
+ * Checks to see if we are opening our custom customizer preview
68
+ *
69
+ * @access public
70
+ * @return bool
71
+ */
72
+ public static function is_own_preview_request() {
73
+ return isset( $_REQUEST['wcast-shipped-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-shipped-email-customizer-preview'];
74
+ }
75
+
76
+ /**
77
+ * Checks to see if we are opening our custom customizer controls
78
+ *
79
+ * @access public
80
+ * @return bool
81
+ */
82
+ public static function is_own_customizer_request() {
83
+ return isset( $_REQUEST['email'] ) && $_REQUEST['email'] === 'customer_shipped_email';
84
+ }
85
+
86
+ /**
87
+ * Get Customizer URL
88
+ *
89
+ */
90
+ public static function get_customizer_url($email) {
91
+ $customizer_url = add_query_arg( array(
92
+ 'wcast-customizer' => '1',
93
+ 'email' => $email,
94
+ 'url' => urlencode( add_query_arg( array( 'wcast-shipped-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
95
+ 'return' => urlencode( wcast_shipped_customizer_email::get_email_settings_page_url() ),
96
+ ), admin_url( 'customize.php' ) );
97
+
98
+ return $customizer_url;
99
+ }
100
+
101
+ /**
102
+ * Get WooCommerce email settings page URL
103
+ *
104
+ * @access public
105
+ * @return string
106
+ */
107
+ public static function get_email_settings_page_url() {
108
+ return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking' );
109
+ }
110
+
111
+ /**
112
+ * code for initialize default value for customizer
113
+ */
114
+ public function wcast_generate_defaults() {
115
+ $customizer_defaults = array(
116
+ 'wcast_shipped_email_subject' => __( 'Your {site_title} order is now shipped', 'woo-advanced-shipment-tracking' ),
117
+ 'wcast_shipped_email_heading' => __( 'Your Order is Shipped', 'woocommerce' ),
118
+ 'wcast_shipped_email_content' => __( "Hi there. we thought you'd like to know that your recent order from {site_title} has been shipped.", 'woo-advanced-shipment-tracking' ),
119
+ 'wcast_enable_shipped_email' => 'no',
120
+ );
121
+
122
+ return apply_filters( 'skyrocket_customizer_defaults', $customizer_defaults );
123
+ }
124
+
125
+ /**
126
+ * Register our sample default controls
127
+ */
128
+ public function wcast_register_sample_default_controls( $wp_customize ) {
129
+ /**
130
+ * Load all our Customizer Custom Controls
131
+ */
132
+ require_once trailingslashit( dirname(__FILE__) ) . 'custom-controls.php';
133
+
134
+ $wp_customize->add_setting( 'shipped_order_email_heading',
135
+ array(
136
+ 'default' => '',
137
+ 'transport' => 'postMessage',
138
+ 'sanitize_callback' => ''
139
+ )
140
+ );
141
+ $wp_customize->add_control( new WP_Customize_Heading_Control( $wp_customize, 'shipped_order_email_heading',
142
+ array(
143
+ 'label' => __( 'Shipped status email', 'woo-advanced-shipment-tracking' ),
144
+ 'description' => __( 'This section lets you customize the Email Content.', 'woo-advanced-shipment-tracking' ),
145
+ 'section' => 'customer_shipped_email'
146
+ )
147
+ ) );
148
+ // Display Shipment Provider image/thumbnail
149
+ $wp_customize->add_setting( 'customizer_shipped_order_settings_enabled',
150
+ array(
151
+ 'default' => $this->defaults['wcast_enable_shipped_email'],
152
+ 'transport' => 'postMessage',
153
+ 'type' => 'option',
154
+ 'sanitize_callback' => ''
155
+ )
156
+ );
157
+ $wp_customize->add_control( 'customizer_shipped_order_settings_enabled',
158
+ array(
159
+ 'label' => __( 'Enable Shipped order status email', 'woo-advanced-shipment-tracking' ),
160
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
161
+ 'section' => 'customer_shipped_email',
162
+ 'type' => 'checkbox',
163
+
164
+ )
165
+ );
166
+
167
+ // Preview Order
168
+ $wp_customize->add_setting( 'wcast_shipped_preview_order_id',
169
+ array(
170
+ 'default' => 'mockup',
171
+ 'transport' => 'refresh',
172
+ 'sanitize_callback' => ''
173
+ )
174
+ );
175
+ $wp_customize->add_control( new Skyrocket_Dropdown_Select_Custom_Control( $wp_customize, 'wcast_shipped_preview_order_id',
176
+ array(
177
+ 'label' => __( 'Preview order', 'woo-advanced-shipment-tracking' ),
178
+ 'description' => '',
179
+ 'section' => 'customer_shipped_email',
180
+ 'input_attrs' => array(
181
+ 'placeholder' => __( 'Please select a order...', 'woo-advanced-shipment-tracking' ),
182
+ 'class' => 'preview_order_select',
183
+ ),
184
+ 'choices' => wcast_customizer()->get_order_ids(),
185
+ )
186
+ ) );
187
+
188
+ // Header Text
189
+ $wp_customize->add_setting( 'woocommerce_customer_shipped_order_settings[subject]',
190
+ array(
191
+ 'default' => $this->defaults['wcast_shipped_email_subject'],
192
+ 'transport' => 'postMessage',
193
+ 'type' => 'option',
194
+ 'sanitize_callback' => ''
195
+ )
196
+ );
197
+ $wp_customize->add_control( 'woocommerce_customer_shipped_order_settings[subject]',
198
+ array(
199
+ 'label' => __( 'Subject', 'woocommerce' ),
200
+ 'description' => esc_html__( 'Available variables:', 'woo-advanced-shipment-tracking' ).' {site_title}, {order_number}',
201
+ 'section' => 'customer_shipped_email',
202
+ 'type' => 'text',
203
+ 'input_attrs' => array(
204
+ 'class' => '',
205
+ 'style' => '',
206
+ 'placeholder' => __( $this->defaults['wcast_shipped_email_subject'], 'woo-advanced-shipment-tracking' ),
207
+ ),
208
+ )
209
+ );
210
+
211
+ // Header Text
212
+ $wp_customize->add_setting( 'woocommerce_customer_shipped_order_settings[heading]',
213
+ array(
214
+ 'default' => $this->defaults['wcast_shipped_email_heading'],
215
+ 'transport' => 'postMessage',
216
+ 'type' => 'option',
217
+ 'sanitize_callback' => ''
218
+ )
219
+ );
220
+ $wp_customize->add_control( 'woocommerce_customer_shipped_order_settings[heading]',
221
+ array(
222
+ 'label' => __( 'Email heading', 'woocommerce' ),
223
+ 'description' => esc_html__( 'Available variables:', 'woo-advanced-shipment-tracking' ).' {site_title}, {order_number}',
224
+ 'section' => 'customer_shipped_email',
225
+ 'type' => 'text',
226
+ 'input_attrs' => array(
227
+ 'class' => '',
228
+ 'style' => '',
229
+ 'placeholder' => __( $this->defaults['wcast_shipped_email_heading'], 'woo-advanced-shipment-tracking' ),
230
+ ),
231
+ )
232
+ );
233
+
234
+
235
+ // Test of TinyMCE control
236
+ $wp_customize->add_setting( 'woocommerce_customer_shipped_order_settings[wcast_shipped_email_content]',
237
+ array(
238
+ 'default' => $this->defaults['wcast_shipped_email_content'],
239
+ 'transport' => 'refresh',
240
+ 'sanitize_callback' => 'wp_kses_post',
241
+ 'type' => 'option',
242
+ )
243
+ );
244
+ $wp_customize->add_control( new Skyrocket_TinyMCE_Custom_control( $wp_customize, 'woocommerce_customer_shipped_order_settings[wcast_shipped_email_content]',
245
+ array(
246
+ 'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
247
+ 'description' => __( 'Available variables:', 'woo-advanced-shipment-tracking' ).' {site_title}, {customer_email}, {customer_first_name}, {customer_last_name}, {customer_username}, {order_number}',
248
+ 'section' => 'customer_shipped_email',
249
+ 'input_attrs' => array(
250
+ 'toolbar1' => 'bold italic bullist numlist alignleft aligncenter alignright link',
251
+ 'mediaButtons' => true,
252
+ 'placeholder' => __( $this->defaults['wcast_shipped_email_content'], 'woo-advanced-shipment-tracking' ),
253
+ )
254
+ )
255
+ ) );
256
+
257
+ $wp_customize->add_setting( 'wcast_shipped_code_block',
258
+ array(
259
+ 'default' => '',
260
+ 'transport' => 'postMessage',
261
+ 'sanitize_callback' => ''
262
+ )
263
+ );
264
+ $wp_customize->add_control( new WP_Customize_codeinfoblock_Control( $wp_customize, 'wcast_shipped_code_block',
265
+ array(
266
+ 'label' => __( 'Available variables:', 'woo-advanced-shipment-tracking' ),
267
+ 'description' => '<code>{site_title}<br>{customer_email}<br>{customer_first_name}<br>{customer_last_name}<br>{customer_company_name}<br>{customer_username}<br>{order_number}</code>',
268
+ 'section' => 'customer_shipped_email',
269
+ )
270
+ ) );
271
+ }
272
+
273
+ /**
274
+ * Set up preview
275
+ *
276
+ * @access public
277
+ * @return void
278
+ */
279
+ public function set_up_preview() {
280
+ wcast_shipped_customizer_email::is_own_preview_request();
281
+ // Make sure this is own preview request.
282
+ if ( ! wcast_shipped_customizer_email::is_own_preview_request() ) {
283
+ return;
284
+ }
285
+ include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview/shipped_preview.php';
286
+ exit;
287
+ }
288
+
289
+ /**
290
+ * code for preview of delivered order status email
291
+ */
292
+ public function preview_shipped_email(){
293
+ // Load WooCommerce emails.
294
+ $wc_emails = WC_Emails::instance();
295
+ $emails = $wc_emails->get_emails();
296
+ $preview_id = get_theme_mod('wcast_shipped_preview_order_id');
297
+
298
+ if($preview_id == '' || $preview_id == 'mockup') {
299
+ $content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
300
+ echo $content;
301
+ return;
302
+ }
303
+
304
+ $order = wc_get_order( $preview_id );
305
+
306
+ if(!$order){
307
+ $content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select order to preview.', 'woo-advanced-shipment-tracking' ) . '</div>';
308
+ echo $content;
309
+ return;
310
+ }
311
+
312
+ $email_type = 'WC_Email_Customer_Shipped_Order';
313
+
314
+ if ( false === $email_type ) {
315
+ return false;
316
+ }
317
+
318
+
319
+
320
+ // Reference email.
321
+ if ( isset( $emails[ $email_type ] ) && is_object( $emails[ $email_type ] ) ) {
322
+ $email = $emails[ $email_type ];
323
+ }
324
+ $order_status = 'partial-shipped';
325
+ // Get an order
326
+ $order = self::get_wc_order_for_preview( $order_status, $preview_id );
327
+
328
+ // Make sure gateways are running in case the email needs to input content from them.
329
+ WC()->payment_gateways();
330
+ // Make sure shipping is running in case the email needs to input content from it.
331
+ WC()->shipping();
332
+
333
+ $email->object = $order;
334
+ $email->find['order-date'] = '{order_date}';
335
+ $email->find['order-number'] = '{order_number}';
336
+ if ( is_object( $order ) ) {
337
+ $email->replace['order-date'] = wc_format_datetime( $email->object->get_date_created() );
338
+ $email->replace['order-number'] = $email->object->get_order_number();
339
+ // Other properties
340
+ $email->recipient = $email->object->get_billing_email();
341
+ }
342
+
343
+ // Get email content and apply styles.
344
+ $content = $email->get_content();
345
+
346
+ $content = $email->style_inline( $content );
347
+ $content = apply_filters( 'woocommerce_mail_content', $content );
348
+
349
+ echo $content;
350
+ }
351
+
352
+ /**
353
+ * Get WooCommerce order for preview
354
+ *
355
+ * @access public
356
+ * @param string $order_status
357
+ * @return object
358
+ */
359
+ public static function get_wc_order_for_preview( $order_status = null, $order_id = null ) {
360
+ if ( ! empty( $order_id ) && 'mockup' != $order_id ) {
361
+ return wc_get_order( $order_id );
362
+ } else {
363
+ // Use mockup order
364
+
365
+ // Instantiate order object
366
+ $order = new WC_Order();
367
+
368
+ // Other order properties
369
+ $order->set_props( array(
370
+ 'id' => 1,
371
+ 'status' => ( null === $order_status ? 'processing' : $order_status ),
372
+ 'billing_first_name' => 'Sherlock',
373
+ 'billing_last_name' => 'Holmes',
374
+ 'billing_company' => 'Detectives Ltd.',
375
+ 'billing_address_1' => '221B Baker Street',
376
+ 'billing_city' => 'London',
377
+ 'billing_postcode' => 'NW1 6XE',
378
+ 'billing_country' => 'GB',
379
+ 'billing_email' => 'sherlock@holmes.co.uk',
380
+ 'billing_phone' => '02079304832',
381
+ 'date_created' => date( 'Y-m-d H:i:s' ),
382
+ 'total' => 24.90,
383
+ ) );
384
+
385
+ // Item #1
386
+ $order_item = new WC_Order_Item_Product();
387
+ $order_item->set_props( array(
388
+ 'name' => 'A Study in Scarlet',
389
+ 'subtotal' => '9.95',
390
+ 'sku' => 'kwd_ex_1',
391
+ ) );
392
+ $order->add_item( $order_item );
393
+
394
+ // Item #2
395
+ $order_item = new WC_Order_Item_Product();
396
+ $order_item->set_props( array(
397
+ 'name' => 'The Hound of the Baskervilles',
398
+ 'subtotal' => '14.95',
399
+ 'sku' => 'kwd_ex_2',
400
+ ) );
401
+ $order->add_item( $order_item );
402
+
403
+ // Return mockup order
404
+ return $order;
405
+ }
406
+
407
+ }
408
+ }
409
+ /**
410
+ * Initialise our Customizer settings
411
+ */
412
+
413
+ $wcast_shipped_customizer_settings = new wcast_shipped_customizer_email();
414
+ add_action( 'customize_save_customizer_shipped_order_settings_enabled', 'woocommerce_customer_shipped_order_settings_fun', 100, 1 );
415
+
416
+ /**
417
+ * Update Delivered order email enable/disable
418
+ *
419
+ */
420
+ function woocommerce_customer_shipped_order_settings_fun($data){
421
+ $post_values = json_decode( wp_unslash( $_POST['customized'] ), true );
422
+ $shipped_order_settings = get_option( 'woocommerce_customer_shipped_order_settings');
423
+
424
+ if(isset($post_values['customizer_shipped_order_settings_enabled']) && ($post_values['customizer_shipped_order_settings_enabled'] == 1)){
425
+ $shipped_order_settings['enabled'] = 'yes';
426
+ } else{
427
+ $shipped_order_settings['enabled'] = 'no';
428
+ }
429
+ update_option( 'woocommerce_customer_shipped_order_settings',$shipped_order_settings);
430
+ }
includes/customizer/class-wcast-customizer.php CHANGED
@@ -106,6 +106,14 @@ class WC_Advanced_Shipment_Tracking_Customizer {
106
  )
107
  );
108
 
 
 
 
 
 
 
 
 
109
  $wp_customize->add_section( 'customer_delivered_email',
110
  array(
111
  'title' => __( 'Delivered order status email', 'woo-advanced-shipment-tracking' ),
@@ -208,6 +216,7 @@ class WC_Advanced_Shipment_Tracking_Customizer {
208
  'ajax_url' => admin_url('admin-ajax.php'),
209
  'email_preview_url' => $this->get_email_preview_url(),
210
  'partial_shipped_email_preview_url' => $this->get_partial_shipped_email_preview_url(),
 
211
  'updated_tracking_email_preview_url' => $this->get_updated_tracking_email_preview_url(),
212
  'tracking_preview_url' => $this->get_tracking_preview_url(),
213
  'customer_failure_preview_url' => $this->get_customer_failure_preview_url(),
@@ -247,6 +256,18 @@ class WC_Advanced_Shipment_Tracking_Customizer {
247
  return $email_preview_url;
248
  }
249
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  /**
251
  * Get Customizer URL
252
  *
@@ -430,7 +451,7 @@ class WC_Advanced_Shipment_Tracking_Customizer {
430
  */
431
  public static function is_own_section( $key ) {
432
 
433
- if ($key === 'wcast_naviation_panel' || $key === 'ast_tracking_general_section' || $key === 'ast_tracking_per_item' || $key === 'ast_tracking_simple_section' || $key === 'ast_tracking_table_section' || $key === 'default_controls_section' || $key === 'tracking_page_section' || $key === 'customer_delivered_email' || $key === 'customer_partial_shipped_email' || $key === 'customer_updated_tracking_email' || $key === 'customer_failure_email' || $key === 'customer_intransit_email' || $key === 'customer_outfordelivery_email' || $key === 'customer_delivered_status_email' || $key === 'customer_returntosender_email' || $key === 'customer_availableforpickup_email' || $key === 'admin_late_shipments_email') {
434
  return true;
435
  }
436
 
106
  )
107
  );
108
 
109
+ $wp_customize->add_section( 'customer_shipped_email',
110
+ array(
111
+ 'title' => __( 'Shipped status email', 'woo-advanced-shipment-tracking' ),
112
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
113
+ 'panel' => 'wcast_naviation_panel'
114
+ )
115
+ );
116
+
117
  $wp_customize->add_section( 'customer_delivered_email',
118
  array(
119
  'title' => __( 'Delivered order status email', 'woo-advanced-shipment-tracking' ),
216
  'ajax_url' => admin_url('admin-ajax.php'),
217
  'email_preview_url' => $this->get_email_preview_url(),
218
  'partial_shipped_email_preview_url' => $this->get_partial_shipped_email_preview_url(),
219
+ 'shipped_email_preview_url' => $this->get_shipped_email_preview_url(),
220
  'updated_tracking_email_preview_url' => $this->get_updated_tracking_email_preview_url(),
221
  'tracking_preview_url' => $this->get_tracking_preview_url(),
222
  'customer_failure_preview_url' => $this->get_customer_failure_preview_url(),
256
  return $email_preview_url;
257
  }
258
 
259
+ /**
260
+ * Get Customizer URL
261
+ *
262
+ */
263
+ public static function get_shipped_email_preview_url() {
264
+ $email_preview_url = add_query_arg( array(
265
+ 'wcast-shipped-email-customizer-preview' => '1',
266
+ ), home_url( '' ) );
267
+
268
+ return $email_preview_url;
269
+ }
270
+
271
  /**
272
  * Get Customizer URL
273
  *
451
  */
452
  public static function is_own_section( $key ) {
453
 
454
+ if ($key === 'wcast_naviation_panel' || $key === 'ast_tracking_general_section' || $key === 'ast_tracking_per_item' || $key === 'ast_tracking_simple_section' || $key === 'ast_tracking_table_section' || $key === 'default_controls_section' || $key === 'tracking_page_section' || $key === 'customer_delivered_email' || $key === 'customer_partial_shipped_email' || $key === 'customer_shipped_email' || $key === 'customer_updated_tracking_email' || $key === 'customer_failure_email' || $key === 'customer_intransit_email' || $key === 'customer_outfordelivery_email' || $key === 'customer_delivered_status_email' || $key === 'customer_returntosender_email' || $key === 'customer_availableforpickup_email' || $key === 'admin_late_shipments_email') {
455
  return true;
456
  }
457
 
includes/customizer/preview/shipped_preview.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Exit if accessed directly
3
+ if (!defined('ABSPATH')) {
4
+ exit;
5
+ }
6
+
7
+ ?>
8
+
9
+ <head>
10
+
11
+ <meta charset="<?php bloginfo('charset'); ?>" />
12
+ <meta name="viewport" content="width=device-width" />
13
+ <style type="text/css" id="ast_designer_custom_css">.woocommerce-store-notice.demo_store, .mfp-hide {display: none;}</style>
14
+ </head>
15
+
16
+ <body class="ast_preview_body">
17
+ <div id="overlay"></div>
18
+ <div id="ast_preview_wrapper" style="display: block;">
19
+
20
+ <?php wcast_shipped_customizer_email::preview_shipped_email(); ?>
21
+
22
+ </div>
23
+
24
+ <?php
25
+ do_action( 'woomail_footer' );
26
+ wp_footer(); ?>
27
+
28
+ </body>
29
+
30
+ </html>
includes/email-manager.php CHANGED
@@ -32,6 +32,12 @@ class WC_Advanced_Shipment_Tracking_Email_Manager {
32
 
33
  if ( ! isset( $emails[ 'WC_Email_Customer_Updated_Tracking_Order' ] ) ) {
34
  $emails[ 'WC_Email_Customer_Updated_Tracking_Order' ] = include_once( 'emails/class-shipment-updated-tracking-email.php' );
 
 
 
 
 
 
35
  }
36
  return $emails;
37
  }
32
 
33
  if ( ! isset( $emails[ 'WC_Email_Customer_Updated_Tracking_Order' ] ) ) {
34
  $emails[ 'WC_Email_Customer_Updated_Tracking_Order' ] = include_once( 'emails/class-shipment-updated-tracking-email.php' );
35
+ }
36
+
37
+ if(get_option('wc_ast_completed_to_shipped') == 'wc_ast_create_shipped' && get_option('wc_ast_status_shipped_active')){
38
+ if ( ! isset( $emails[ 'WC_Email_Customer_Shipped_Order' ] ) ) {
39
+ $emails[ 'WC_Email_Customer_Shipped_Order' ] = include_once( 'emails/class-shipment-shipped-email.php' );
40
+ }
41
  }
42
  return $emails;
43
  }
includes/emails/class-shipment-delivered-email.php CHANGED
@@ -136,14 +136,13 @@ if ( ! class_exists( 'WC_Email_Customer_Delivered_Order', false ) ) :
136
  //ob_start();
137
  $woocommerce_customer_delivered_order_settings = get_option('woocommerce_customer_delivered_order_settings');
138
 
 
139
  $email_content = $ast->get_option_value_from_array('woocommerce_customer_delivered_order_settings','wcast_delivered_email_content',$wcast_initialise_customizer_email->defaults['wcast_delivered_email_content']);
140
 
141
  $wcast_show_tracking_details = $woocommerce_customer_delivered_order_settings['wcast_show_tracking_details'];
142
  $wcast_show_order_details = $woocommerce_customer_delivered_order_settings['wcast_show_order_details'];
143
  $wcast_show_billing_address = $woocommerce_customer_delivered_order_settings['wcast_show_billing_address'];
144
- $wcast_show_shipping_address = $woocommerce_customer_delivered_order_settings['wcast_show_shipping_address'];
145
-
146
-
147
 
148
  $message = wc_advanced_shipment_tracking_email_class()->email_content($email_content,$order_id,$order);
149
 
@@ -223,13 +222,13 @@ if ( ! class_exists( 'WC_Email_Customer_Delivered_Order', false ) ) :
223
  ob_start();
224
  do_action( 'wcast_email_after_email_content', $order, $sent_to_admin, $plain_text, $this );
225
  $message .= ob_get_clean();
 
226
  // create a new email
227
  $email = new WC_Email();
228
  $email->id = 'WC_Delivered_email';
229
 
230
  // wrap the content with the email template and then add styles
231
- $message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
232
-
233
  return $message;
234
  }
235
  }
136
  //ob_start();
137
  $woocommerce_customer_delivered_order_settings = get_option('woocommerce_customer_delivered_order_settings');
138
 
139
+
140
  $email_content = $ast->get_option_value_from_array('woocommerce_customer_delivered_order_settings','wcast_delivered_email_content',$wcast_initialise_customizer_email->defaults['wcast_delivered_email_content']);
141
 
142
  $wcast_show_tracking_details = $woocommerce_customer_delivered_order_settings['wcast_show_tracking_details'];
143
  $wcast_show_order_details = $woocommerce_customer_delivered_order_settings['wcast_show_order_details'];
144
  $wcast_show_billing_address = $woocommerce_customer_delivered_order_settings['wcast_show_billing_address'];
145
+ $wcast_show_shipping_address = $woocommerce_customer_delivered_order_settings['wcast_show_shipping_address'];
 
 
146
 
147
  $message = wc_advanced_shipment_tracking_email_class()->email_content($email_content,$order_id,$order);
148
 
222
  ob_start();
223
  do_action( 'wcast_email_after_email_content', $order, $sent_to_admin, $plain_text, $this );
224
  $message .= ob_get_clean();
225
+
226
  // create a new email
227
  $email = new WC_Email();
228
  $email->id = 'WC_Delivered_email';
229
 
230
  // wrap the content with the email template and then add styles
231
+ $message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
 
232
  return $message;
233
  }
234
  }
includes/emails/class-shipment-shipped-email.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class WC_Email_Customer_Shipped_Order file.
4
+ *
5
+ * @package WooCommerce\Emails
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Exit if accessed directly.
10
+ }
11
+
12
+ if ( ! class_exists( 'WC_Email_Customer_Shipped_Order', false ) ) :
13
+
14
+ /**
15
+ * Customer Completed Order Email.
16
+ *
17
+ * Order complete emails are sent to the customer when the order is marked complete and usual indicates that the order has been shipped.
18
+ *
19
+ * @class WC_Email_Customer_Shipped_Order
20
+ * @version 2.0.0
21
+ * @package WooCommerce/Classes/Emails
22
+ * @extends WC_Email
23
+ */
24
+ class WC_Email_Customer_Shipped_Order extends WC_Email {
25
+
26
+ /**
27
+ * Constructor.
28
+ */
29
+ public function __construct() {
30
+ $this->id = 'customer_shipped_order';
31
+ $this->customer_email = true;
32
+ $this->title = __( 'Shipped order', 'woocommerce' );
33
+ $this->description = __( 'Order shipped emails are sent to customers when their orders are marked shipped and usually indicate that their orders have been shipped.', 'woo-advanced-shipment-tracking' );
34
+ $this->template_html = 'emails/customer-shipped-order.php';
35
+ $this->template_plain = 'emails/plain/customer-shipped-order.php';
36
+ $this->placeholders = array(
37
+ '{order_date}' => '',
38
+ '{order_number}' => '',
39
+ );
40
+ $this->template_base = AST_TEMPLATE_PATH;
41
+ // Triggers for this email.
42
+ //add_action( 'woocommerce_order_status_completed_notification', array( $this, 'trigger' ), 10, 2 );
43
+
44
+ // Call parent constructor.
45
+ parent::__construct();
46
+ }
47
+
48
+ /**
49
+ * Trigger the sending of this email.
50
+ *
51
+ * @param int $order_id The order ID.
52
+ * @param WC_Order|false $order Order object.
53
+ */
54
+ public function trigger( $order_id, $order = false ) {
55
+ $this->setup_locale();
56
+
57
+ if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
58
+ $order = wc_get_order( $order_id );
59
+ }
60
+
61
+ if ( is_a( $order, 'WC_Order' ) ) {
62
+ $this->object = $order;
63
+ $this->recipient = $this->object->get_billing_email();
64
+ $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
65
+ $this->placeholders['{order_number}'] = $this->object->get_order_number();
66
+ }
67
+
68
+ if ( $this->is_enabled() && $this->get_recipient() ) {
69
+ $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
70
+ }
71
+
72
+ $this->restore_locale();
73
+ }
74
+
75
+ /**
76
+ * Get email subject.
77
+ *
78
+ * @since 3.1.0
79
+ * @return string
80
+ */
81
+ public function get_default_subject() {
82
+ return __( 'Your {site_title} order is now shipped', 'woo-advanced-shipment-tracking' );
83
+ }
84
+
85
+ /**
86
+ * Get email heading.
87
+ *
88
+ * @since 3.1.0
89
+ * @return string
90
+ */
91
+ public function get_default_heading() {
92
+ return __( 'Your Order is Shipped', 'woo-advanced-shipment-tracking' );
93
+ }
94
+
95
+ /**
96
+ * Get content html.
97
+ *
98
+ * @return string
99
+ */
100
+ public function get_content_html() {
101
+ $template = $this->get_template( 'template_html' );
102
+ $local_file = $this->get_theme_template_file( $template );
103
+ if ( file_exists( $local_file ) && is_writable( $local_file )){
104
+ //echo $local_file;exit;
105
+ return wc_get_template_html(
106
+ $this->template_html,
107
+ array(
108
+ 'order' => $this->object,
109
+ 'email_heading' => $this->get_heading(),
110
+ 'additional_content' => $this->get_additional_content(),
111
+ 'sent_to_admin' => false,
112
+ 'plain_text' => false,
113
+ 'email' => $this,
114
+ )
115
+ );
116
+ } else{
117
+ return wc_get_template_html(
118
+ 'emails/customer-shipped-order.php',
119
+ array(
120
+ 'order' => $this->object,
121
+ 'email_heading' => $this->get_heading(),
122
+ 'additional_content' => $this->get_additional_content(),
123
+ 'sent_to_admin' => false,
124
+ 'plain_text' => false,
125
+ 'email' => $this,
126
+ ),
127
+ 'woocommerce-advanced-shipment-tracking/',
128
+ wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
129
+ );
130
+ }
131
+ }
132
+
133
+ /**
134
+ * Get content plain.
135
+ *
136
+ * @return string
137
+ */
138
+ public function get_content_plain() {
139
+ $template = $this->get_template( 'template_html' );
140
+ $local_file = $this->get_theme_template_file( $template );
141
+ if ( file_exists( $local_file ) && is_writable( $local_file )){
142
+ //echo $local_file;exit;
143
+ return wc_get_template_html(
144
+ $this->template_html,
145
+ array(
146
+ 'order' => $this->object,
147
+ 'email_heading' => $this->get_heading(),
148
+ 'additional_content' => $this->get_additional_content(),
149
+ 'sent_to_admin' => false,
150
+ 'plain_text' => false,
151
+ 'email' => $this,
152
+ )
153
+ );
154
+ } else{
155
+ return wc_get_template_html(
156
+ 'emails/customer-shipped-order.php',
157
+ array(
158
+ 'order' => $this->object,
159
+ 'email_heading' => $this->get_heading(),
160
+ 'additional_content' => $this->get_additional_content(),
161
+ 'sent_to_admin' => false,
162
+ 'plain_text' => false,
163
+ 'email' => $this,
164
+ ),
165
+ 'woocommerce-advanced-shipment-tracking/',
166
+ wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
167
+ );
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Default content to show below main email content.
173
+ *
174
+ * @since 3.7.0
175
+ * @return string
176
+ */
177
+ public function get_default_additional_content() {
178
+ return __( 'Thanks for shopping with us.', 'woocommerce' );
179
+ }
180
+ }
181
+
182
+ endif;
183
+
184
+ return new WC_Email_Customer_Shipped_Order();
includes/views/admin_options_settings.php CHANGED
@@ -61,14 +61,51 @@
61
  <tbody>
62
  <tr valign="top">
63
  <td>
64
- <h3 style=""><?php _e( 'Custom Order Statuses', 'woo-advanced-shipment-tracking' ); ?></h3>
65
  </td>
66
  </tr>
67
  </tbody>
68
  </table>
69
-
70
  <table class="form-table order-status-table">
71
- <tbody>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  <tr valign="top" class="<?php if(!get_option('wc_ast_status_delivered')){echo 'disable_row'; } ?>">
73
  <td class="forminp" style="width: 30px;">
74
  <span class="mdl-list__item-secondary-action">
61
  <tbody>
62
  <tr valign="top">
63
  <td>
64
+ <h3 style=""><?php _e( 'Order Statuses', 'woo-advanced-shipment-tracking' ); ?></h3>
65
  </td>
66
  </tr>
67
  </tbody>
68
  </table>
69
+ <?php $this->get_single_column_html( $this->get_rename_order_status_data() );?>
70
  <table class="form-table order-status-table">
71
+ <tbody>
72
+ <tr valign="top" class="shipped_order_status_tr <?php if(!get_option('wc_ast_status_shipped_active')){echo 'disable_row'; } ?>" style="<?php if(get_option('wc_ast_completed_to_shipped') == 'wc_ast_rename_to_shipped' || get_option('wc_ast_completed_to_shipped') == 'none'){echo 'display:none;'; } ?>">
73
+ <td class="forminp" style="width: 30px;">
74
+ <span class="mdl-list__item-secondary-action">
75
+ <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="wc_ast_status_shipped_active">
76
+ <input type="hidden" name="wc_ast_status_shipped_active" value="0"/>
77
+ <input type="checkbox" id="wc_ast_status_shipped_active" name="wc_ast_status_shipped_active" class="mdl-switch__input" <?php if(get_option('wc_ast_status_shipped_active')){echo 'checked'; } ?> value="1"/>
78
+ </label>
79
+ </span>
80
+ </td>
81
+ <td class="forminp status-label-column">
82
+ <span class="order-label wc-shipped">
83
+ <?php _e( 'Shipped', 'woo-advanced-shipment-tracking' ); ?>
84
+ </span>
85
+ </td>
86
+ <td class="forminp">
87
+ <?php
88
+ $wcast_enable_shipped_email = get_option('woocommerce_customer_shipped_order_settings');
89
+ if(isset($wcast_enable_shipped_email['enabled']) && ($wcast_enable_shipped_email['enabled'] == 'yes' || $wcast_enable_shipped_email['enabled'] == 1)){
90
+ $shipped_checked = 'checked';
91
+ } else{
92
+ $shipped_checked = '';
93
+ }
94
+ ?>
95
+ <fieldset>
96
+ <input class="input-text regular-input " type="text" name="wc_ast_shipped_status_label_color" id="wc_ast_shipped_status_label_color" value="<?php echo get_option('wc_ast_shipped_status_label_color','#b7b7b7')?>" >
97
+ <select class="select" id="wc_ast_shipped_status_label_font_color" name="wc_ast_shipped_status_label_font_color">
98
+ <option value="#fff" <?php if(get_option('wc_ast_shipped_status_label_font_color') == '#fff'){ echo 'selected'; }?>><?php _e( 'Light Font', 'woo-advanced-shipment-tracking' ); ?></option>
99
+ <option value="#000" <?php if(get_option('wc_ast_shipped_status_label_font_color') == '#000'){ echo 'selected'; }?>><?php _e( 'Dark Font', 'woo-advanced-shipment-tracking' ); ?></option>
100
+ </select>
101
+ <label class="send_email_label">
102
+ <input type="hidden" name="wcast_enable_shipped_email" value="0"/>
103
+ <input type="checkbox" name="wcast_enable_shipped_email" id="wcast_enable_shipped_email" <?php echo $shipped_checked; ?> value="1"><?php _e( 'Send Email', 'woo-advanced-shipment-tracking' ); ?>
104
+ </label>
105
+ <a class='settings_edit' href="<?php echo wcast_initialise_customizer_email::get_customizer_url('customer_shipped_email'); ?>"><?php _e( 'Edit', 'woocommerce' ) ?></a>
106
+ </fieldset>
107
+ </td>
108
+ </tr>
109
  <tr valign="top" class="<?php if(!get_option('wc_ast_status_delivered')){echo 'disable_row'; } ?>">
110
  <td class="forminp" style="width: 30px;">
111
  <span class="mdl-list__item-secondary-action">
includes/views/admin_trackship_dashboard.php CHANGED
@@ -1,56 +1,43 @@
1
  <section id="content_trackship_dashboard" class="inner_tab_section">
2
  <div class="tab_inner_container">
3
- <div class="outer_form_table">
4
  <table class="form-table heading-table">
5
  <tbody>
6
  <tr valign="top">
7
- <td><h3 style=""><?php _e( 'Connection status', 'woo-advanced-shipment-tracking' ); ?></h3></td>
8
  </tr>
9
  </tbody>
10
  </table>
11
  <table class="form-table">
12
  <tbody>
13
  <tr valign="top">
14
- <td><label><?php _e( 'TrackShip Connection Status', 'woo-advanced-shipment-tracking' ); ?></label></td>
15
- <td class="forminp">
16
- <fieldset>
17
- <a href="https://my.trackship.info/?utm_source=wpadmin&utm_medium=sidebar&utm_campaign=upgrade" target="_blank">
18
- <span class="api_connected"><label><?php _e( 'Connected', 'woo-advanced-shipment-tracking' ); ?></label><span class="dashicons dashicons-yes"></span></span>
19
- </a>
20
- </fieldset>
21
- </td>
22
- </tr>
23
- <tr valign="top">
24
- <td><label><?php _e( 'Trackers Balance', 'woo-advanced-shipment-tracking' ); ?></label></td>
25
  <td class="forminp">
26
  <fieldset>
27
- <strong><?php echo get_option('trackers_balance'); ?></strong>
28
  </fieldset>
29
  </td>
30
  </tr>
31
  <tr valign="top">
32
- <td><label><?php _e( 'Current Plan', 'woo-advanced-shipment-tracking' ); ?></label></td>
33
  <td class="forminp">
34
- <fieldset>
35
- <strong>
36
- <?php
37
  if(isset($plan_data->subscription_plan)){
38
  echo $plan_data->subscription_plan;
39
  }
40
- ?>
41
- </strong>
42
- </fieldset>
43
- </td>
44
- </tr>
45
- <tr valign="top">
46
- <td colspan="2">
47
- <?php _e( 'You are now connected with TrackShip! TrackShip makes it effortless to automate your post shipping operations and get tracking and delivery status updates directly in the WooCommerce admin.', 'woo-advanced-shipment-tracking' ); ?>
48
  </td>
49
  </tr>
 
 
 
 
 
 
50
  <tr valign="top">
51
  <td colspan="2">
52
- <a href="https://trackship.info/documentation/?utm_source=wpadmin&utm_medium=ts_settings&utm_campaign=docs" class="" style="margin-right: 10px;" target="blank"><?php _e( 'Documentation', 'woo-advanced-shipment-tracking' ); ?></a>
53
- <a href="https://my.trackship.info/?utm_source=wpadmin&utm_medium=ts_settings&utm_campaign=dashboard" class="" target="blank"><?php _e( 'TrackShip Dashboard', 'woo-advanced-shipment-tracking' ); ?></a>
54
  </td>
55
  </tr>
56
  </tbody>
@@ -67,7 +54,7 @@
67
  </tr>
68
  </tbody>
69
  </table>
70
- <?php $this->get_html( $this->get_trackship_general_data() ); ?>
71
  <table class="form-table">
72
  <tbody>
73
  <tr valign="top">
1
  <section id="content_trackship_dashboard" class="inner_tab_section">
2
  <div class="tab_inner_container">
3
+ <div class="outer_form_table trackship_status_section">
4
  <table class="form-table heading-table">
5
  <tbody>
6
  <tr valign="top">
7
+ <td><h3 style=""><?php _e( 'TrackShip status', 'woo-advanced-shipment-tracking' ); ?></h3></td>
8
  </tr>
9
  </tbody>
10
  </table>
11
  <table class="form-table">
12
  <tbody>
13
  <tr valign="top">
14
+ <th scope="row" class="titledesc"><label><?php _e( 'Connection Status', 'woo-advanced-shipment-tracking' ); ?></label></th>
 
 
 
 
 
 
 
 
 
 
15
  <td class="forminp">
16
  <fieldset>
17
+ <a href="https://trackship.info/my-account/?utm_source=wpadmin&utm_medium=sidebar&utm_campaign=upgrade" target="_blank" class="api_connected"><?php _e( 'Connected', 'woo-advanced-shipment-tracking' ); ?><span class="dashicons dashicons-yes"></span></a>
18
  </fieldset>
19
  </td>
20
  </tr>
21
  <tr valign="top">
22
+ <th scope="row" class="titledesc"><label><?php _e( 'Current Plan', 'woo-advanced-shipment-tracking' ); ?></label></th>
23
  <td class="forminp">
24
+ <fieldset><?php
 
 
25
  if(isset($plan_data->subscription_plan)){
26
  echo $plan_data->subscription_plan;
27
  }
28
+ ?></fieldset>
 
 
 
 
 
 
 
29
  </td>
30
  </tr>
31
+ <tr valign="top">
32
+ <th scope="row" class="titledesc"><label><?php _e( 'Trackers Balance', 'woo-advanced-shipment-tracking' ); ?></label></th>
33
+ <td class="forminp">
34
+ <fieldset><?php echo get_option('trackers_balance'); ?></strong></fieldset>
35
+ </td>
36
+ </tr>
37
  <tr valign="top">
38
  <td colspan="2">
39
+ <a href="https://trackship.info/docs/overview/?utm_source=wpadmin&utm_medium=ts_settings&utm_campaign=docs" class="" style="margin-right: 10px;" target="blank"><?php _e( 'Documentation', 'woo-advanced-shipment-tracking' ); ?></a>
40
+ <a href="https://trackship.info/my-account/?utm_source=wpadmin&utm_medium=ts_settings&utm_campaign=dashboard" class="" target="blank"><?php _e( 'TrackShip Dashboard', 'woo-advanced-shipment-tracking' ); ?></a>
41
  </td>
42
  </tr>
43
  </tbody>
54
  </tr>
55
  </tbody>
56
  </table>
57
+ <?php $this->get_html_2( $this->get_trackship_general_data() ); ?>
58
  <table class="form-table">
59
  <tbody>
60
  <tr valign="top">
includes/views/zorem_admin_sidebar.php CHANGED
@@ -5,34 +5,31 @@
5
  ?>
6
  <div class="zorem_admin_sidebar">
7
  <div class="zorem_admin_sidebar_inner">
8
- <?php $wc_ast_api_key = get_option('wc_ast_api_key'); ?>
9
- <div class="zorem-sidebar__section">
10
- <h3>AST Add-ons</h3>
11
- <div class="sidebar_addon_inner">
12
- <img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/AST-banner.png" class="sidebar_addon_logo">
13
- <div class="addon_button_div">
14
- <?php if ( !is_plugin_active( 'ast-tracking-per-order-items/ast-tracking-per-order-items.php' ) ) { ?>
15
- <a href="https://www.zorem.com/shop/tracking-per-item-ast-add-on/?utm_source=wpadmin&utm_medium=sidebar&utm_campaign=upgrade" target="blank" class="button button-primary btn_ast2 addon_widget_button"><?php _e( 'Get This Add-on >', 'woo-advanced-shipment-tracking' ); ?></a>
16
- <?php } else{
17
- if($this->licence_valid()){ ?>
18
- <a href="https://www.zorem.com/my-account/api-keys/?utm_source=wpadmin&utm_medium=sidebar&utm_campaign=upgrade" class="button button-primary btn_green2 addon_widget_button" target="blank"><?php _e('Active','woo-advanced-shipment-tracking');?> <span class="dashicons dashicons-yes"></span></a>
19
- <?php } else{ ?>
20
  <a href="https://www.zorem.com/shop/tracking-per-item-ast-add-on/?utm_source=wpadmin&utm_medium=sidebar&utm_campaign=upgrade" target="blank" class="button button-primary btn_ast2 addon_widget_button"><?php _e( 'Get This Add-on >', 'woo-advanced-shipment-tracking' ); ?></a>
21
- <?php }
22
- } ?>
23
- </div>
 
 
 
 
 
 
 
 
24
  </div>
25
- <div class="sidebar_addon_inner">
26
- <img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/trackship-banner.png" class="sidebar_addon_logo">
27
- <div class="addon_button_div">
28
- <?php if(!$wc_ast_api_key){ ?>
29
- <a href="https://trackship.info/?utm_source=wpadmin&utm_medium=sidebar&utm_campaign=upgrade" class="button button-primary btn_ast2 addon_widget_button" target="_blank"><span><?php _e( 'Upgrade to PRO', 'woo-advanced-shipment-tracking' ); ?></span><i class="icon-angle-right"></i></a>
30
- <?php } else{ ?>
31
- <a href="https://my.trackship.info/?utm_source=wpadmin&utm_medium=sidebar&utm_campaign=upgrade" class="button button-primary btn_green2 addon_widget_button" target="_blank"><span><?php _e( 'Connected', 'woo-advanced-shipment-tracking' ); ?></span><i class="icon-angle-right"></i></a>
32
- <?php } ?>
33
- </div>
34
- </div>
35
- </div>
36
  <div class="zorem-sidebar__section">
37
  <h3 class="top-border">Your opinion matters to us!</h3>
38
  <p>If you enjoy using The Advanced Shipment Tracking plugin, please take a minute and <a href="https://wordpress.org/support/plugin/woo-advanced-shipment-tracking/reviews/#new-post" target="_blank">share your review</a>
5
  ?>
6
  <div class="zorem_admin_sidebar">
7
  <div class="zorem_admin_sidebar_inner">
8
+
9
+ <?php $wc_ast_api_key = get_option('wc_ast_api_key');
10
+
11
+ if ( !is_plugin_active( 'ast-tracking-per-order-items/ast-tracking-per-order-items.php' ) || !$wc_ast_api_key) { ?>
12
+ <div class="zorem-sidebar__section">
13
+ <h3>AST Add-ons</h3>
14
+ <?php if ( !is_plugin_active( 'ast-tracking-per-order-items/ast-tracking-per-order-items.php' ) ) { ?>
15
+ <div class="sidebar_addon_inner">
16
+ <img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/AST-banner.png" class="sidebar_addon_logo">
17
+ <div class="addon_button_div">
 
 
18
  <a href="https://www.zorem.com/shop/tracking-per-item-ast-add-on/?utm_source=wpadmin&utm_medium=sidebar&utm_campaign=upgrade" target="blank" class="button button-primary btn_ast2 addon_widget_button"><?php _e( 'Get This Add-on >', 'woo-advanced-shipment-tracking' ); ?></a>
19
+ </div>
20
+ </div>
21
+ <?php } ?>
22
+ <?php if(!$wc_ast_api_key){ ?>
23
+ <div class="sidebar_addon_inner">
24
+ <img src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/trackship-banner.png" class="sidebar_addon_logo">
25
+ <div class="addon_button_div">
26
+ <a href="https://trackship.info/?utm_source=wpadmin&utm_medium=sidebar&utm_campaign=upgrade" class="button button-primary btn_ast2 addon_widget_button" target="_blank"><span><?php _e( 'Upgrade to PRO', 'woo-advanced-shipment-tracking' ); ?></span><i class="icon-angle-right"></i></a>
27
+ </div>
28
+ </div>
29
+ <?php } ?>
30
  </div>
31
+ <?php }?>
32
+
 
 
 
 
 
 
 
 
 
33
  <div class="zorem-sidebar__section">
34
  <h3 class="top-border">Your opinion matters to us!</h3>
35
  <p>If you enjoy using The Advanced Shipment Tracking plugin, please take a minute and <a href="https://wordpress.org/support/plugin/woo-advanced-shipment-tracking/reviews/#new-post" target="_blank">share your review</a>
readme.txt CHANGED
@@ -96,10 +96,15 @@ USPS, ePacket, Delhivery, Yun Express Tracking, UPS, Australia Post, FedEx, Aram
96
  * [Booster for WooCommerce](https://wordpress.org/plugins/woocommerce-jetpack/)
97
  * [WP-Lister Pro for Amazon](https://www.wplab.com/plugins/wp-lister-for-amazon/)
98
 
99
- = Compatibility with PDF Invoices & Packing Slips plugins =
100
  * [WooCommerce PDF Invoices & Packing Slips plugin](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips)
101
  * [DHL for WooCommerce](https://wordpress.org/plugins/dhl-for-woocommerce/)
 
 
102
  * [ShipWorks Connector for WordPress](https://wordpress.org/plugins/shipworks-e-commerce-bridge/)
 
 
 
103
 
104
  = Compatibility with SMS Plugins =
105
  * [SMS Alert Order Notifications – WooCommerce](https://wordpress.org/plugins/sms-alert/)
@@ -156,6 +161,30 @@ http://a32694-tmp.s415.upress.link/wp-json/wc/v1/orders/<order-id>/shipment-trac
156
 
157
  == Changelog ==
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  = 2.9.6 =
160
  * Dev - Pass custom order number generate by custom order plugin in TrackShip
161
  * Dev - Remove underscore validation in tracking number
96
  * [Booster for WooCommerce](https://wordpress.org/plugins/woocommerce-jetpack/)
97
  * [WP-Lister Pro for Amazon](https://www.wplab.com/plugins/wp-lister-for-amazon/)
98
 
99
+ = Compatibility with PDF Invoices plugins =
100
  * [WooCommerce PDF Invoices & Packing Slips plugin](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips)
101
  * [DHL for WooCommerce](https://wordpress.org/plugins/dhl-for-woocommerce/)
102
+
103
+ = Compatibility with Shipping Labels Plugins =
104
  * [ShipWorks Connector for WordPress](https://wordpress.org/plugins/shipworks-e-commerce-bridge/)
105
+ * [WooCommerce ShipStation Gateway](https://wordpress.org/plugins/woocommerce-shipstation-integration/)
106
+ * [WooCommerce Shipping Services](https://wordpress.org/plugins/woocommerce-services/)
107
+ * [WooCommerce UPS Shipping Plugin with Print Label](https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/)
108
 
109
  = Compatibility with SMS Plugins =
110
  * [SMS Alert Order Notifications – WooCommerce](https://wordpress.org/plugins/sms-alert/)
161
 
162
  == Changelog ==
163
 
164
+ = 2.9.9.2 =
165
+ * Fix - Fatal error: Uncaught Error: Call to a member function get() on null in /home/jh1ua38qa95m/public_html/store/wp-includes/query.php:28 Stack trace: woo-advanced-shipment-tracking/includes/class-wc-advanced-shipment-tracking-settings.php(444)
166
+
167
+ = 2.9.9.1 =
168
+ * Fix - Fatal error: Uncaught Error: Call to a member function get_items() on bool in woo-advanced-shipment-tracking/includes/class-wc-advanced-shipment-tracking.php:328
169
+
170
+ = 2.9.9 =
171
+ * Enhancement - Added new option for create new order status shipped not just rename, so user can use completed and shipped both order status for virtual orders and Local Pickup shipping method
172
+ * Enhancement - Set tracking number field focus on orders ans single order page
173
+ * Enhancement - Update TrackShip link on WordPress dashboard and on the AST settings page
174
+ * Dev - Limit get orders to 100 on TrackShip tools page
175
+
176
+ = 2.9.8 =
177
+ * Fix - fixed issue so trackship_supported column adding in shipping providers table and based on that use carrier website as tracking link if TrackShip not sot supported
178
+
179
+ = 2.9.7 =
180
+ * Dev - Added trackship_supported column in shipping providers table and based on that use carrier website as tracking link if TrackShip not sot supported
181
+ * Dev - Added custom order number compatibility in TrackShip tracking form
182
+ * Dev - Remove dot validation in tracking number
183
+ * Dev - Remove dot and underscore validation from Bulk Upload trackig information
184
+ * Enhancement - Added Order Id in Inline Tracking Form
185
+ * Enhancement - Remove Add Tracking button form orders action if order status is On Hold, Failed , Cancelled, Ready for Pickup and Picked up
186
+ * Enhancement - Updated design of TrackShip dashboard
187
+
188
  = 2.9.6 =
189
  * Dev - Pass custom order number generate by custom order plugin in TrackShip
190
  * Dev - Remove underscore validation in tracking number
templates/emails/customer-shipped-order.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customer shipped order email
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-shipped-order.php.
6
+ *
7
+ * HOWEVER, on occasion WooCommerce will need to update template files and you
8
+ * (the theme developer) will need to copy the new files to your theme to
9
+ * maintain compatibility. We try to do this as little as possible, but it does
10
+ * happen. When this occurs the version of the template file will be bumped and
11
+ * the readme will list any important changes.
12
+ *
13
+ * @see https://docs.woocommerce.com/document/template-structure/
14
+ * @package WooCommerce/Templates/Emails
15
+ * @version 3.7.0
16
+ */
17
+
18
+ if ( ! defined( 'ABSPATH' ) ) {
19
+ exit;
20
+ }
21
+ $wcast_shipped_customizer_settings = new wcast_shipped_customizer_email();
22
+
23
+ $ast = new WC_Advanced_Shipment_Tracking_Actions;
24
+ $email_content = $ast->get_option_value_from_array('woocommerce_customer_shipped_order_settings','wcast_shipped_email_content',$wcast_shipped_customizer_settings->defaults['wcast_shipped_email_content']);
25
+
26
+ $email_content = str_replace( '{customer_email}', $order->get_billing_email(), $email_content );
27
+ $email_content = str_replace( '{site_title}', $wcast_shipped_customizer_settings->get_blogname(), $email_content );
28
+ $email_content = str_replace( '{customer_first_name}', $order->get_billing_first_name(), $email_content );
29
+ $email_content = str_replace( '{customer_last_name}', $order->get_billing_last_name(), $email_content );
30
+
31
+ if($order->get_billing_company()){
32
+ $email_content = str_replace( '{customer_company_name}', $order->get_billing_company(), $email_content );
33
+ } else{
34
+ $email_content = str_replace( '{customer_company_name}','', $email_content );
35
+ }
36
+
37
+ $user = $order->get_user();
38
+ if($user){
39
+ $username = $user->user_login;
40
+ }
41
+ if(isset($username)){
42
+ $email_content = str_replace( '{customer_username}', $username, $email_content );
43
+ } else{
44
+ $email_content = str_replace( '{customer_username}', '', $email_content );
45
+ }
46
+ $email_content = str_replace( '{order_number}', $order->get_id(), $email_content );
47
+ /*
48
+ * @hooked WC_Emails::email_header() Output the email header
49
+ */
50
+ do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
51
+
52
+ <?php /* translators: %s: Site title */ ?>
53
+ <p class="shipped_email_content"><?php echo $email_content; ?></p>
54
+ <?php
55
+
56
+ /*
57
+ * @hooked WC_Emails::order_details() Shows the order details table.
58
+ * @hooked WC_Structured_Data::generate_order_data() Generates structured data.
59
+ * @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
60
+ * @since 2.5.0
61
+ */
62
+ do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
63
+
64
+ /*
65
+ * @hooked WC_Emails::order_meta() Shows order meta data.
66
+ */
67
+ do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
68
+
69
+ /*
70
+ * @hooked WC_Emails::customer_details() Shows customer details
71
+ * @hooked WC_Emails::email_address() Shows email address
72
+ */
73
+ do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
74
+
75
+ /**
76
+ * Show user-defined additonal content - this is set in each email's settings.
77
+ */
78
+ if ( $additional_content ) {
79
+ echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) );
80
+ }
81
+
82
+ /*
83
+ * @hooked WC_Emails::email_footer() Output the email footer
84
+ */
85
+ do_action( 'woocommerce_email_footer', $email );
templates/emails/tracking-info.php CHANGED
@@ -33,7 +33,7 @@ if ( $tracking_items ) :
33
  $tracking_info_settings = get_option('tracking_info_settings');
34
  $ast = new WC_Advanced_Shipment_Tracking_Actions;
35
 
36
- $select_tracking_template = $tracking_info_settings['select_tracking_template'];
37
 
38
  $show_provider_th = 1;
39
  $colspan = 1;
@@ -71,9 +71,9 @@ if ( $tracking_items ) :
71
 
72
  $email_border_size = $ast->get_option_value_from_array('tracking_info_settings','table_border_size',$wcast_customizer_settings->defaults['table_border_size']);
73
 
74
- if($tracking_info_settings['header_text_change']){ $shipment_tracking_header = $tracking_info_settings['header_text_change']; } else{ $shipment_tracking_header = "Tracking Information"; }
75
 
76
- if($tracking_info_settings['additional_header_text']){ $shipment_tracking_header_text = $tracking_info_settings['additional_header_text']; }
77
 
78
  $email_table_backgroud_color = $ast->get_option_value_from_array('tracking_info_settings','table_bg_color',$wcast_customizer_settings->defaults['table_bg_color']);
79
 
@@ -168,7 +168,7 @@ if ( $tracking_items ) :
168
 
169
  $simple_layout_content_updated = str_replace('{shipping_provider}',$formatted_tracking_provider,$simple_layout_content_updated);
170
 
171
- $tracking_number_link = '<a href="'.esc_url( $url ).'">'.$tracking_item['tracking_number'].'</a>';
172
 
173
  $simple_layout_content_updated = str_replace('{tracking_number_link}',$tracking_number_link,$simple_layout_content_updated);
174
 
33
  $tracking_info_settings = get_option('tracking_info_settings');
34
  $ast = new WC_Advanced_Shipment_Tracking_Actions;
35
 
36
+ $select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$wcast_customizer_settings->defaults['select_tracking_template']);
37
 
38
  $show_provider_th = 1;
39
  $colspan = 1;
71
 
72
  $email_border_size = $ast->get_option_value_from_array('tracking_info_settings','table_border_size',$wcast_customizer_settings->defaults['table_border_size']);
73
 
74
+ $shipment_tracking_header = $ast->get_option_value_from_array('tracking_info_settings','header_text_change','Tracking Information');
75
 
76
+ $shipment_tracking_header_text = $ast->get_option_value_from_array('tracking_info_settings','additional_header_text','');
77
 
78
  $email_table_backgroud_color = $ast->get_option_value_from_array('tracking_info_settings','table_bg_color',$wcast_customizer_settings->defaults['table_bg_color']);
79
 
168
 
169
  $simple_layout_content_updated = str_replace('{shipping_provider}',$formatted_tracking_provider,$simple_layout_content_updated);
170
 
171
+ $tracking_number_link = '<a target="_blank" href="'.esc_url( $url ).'">'.$tracking_item['tracking_number'].'</a>';
172
 
173
  $simple_layout_content_updated = str_replace('{tracking_number_link}',$tracking_number_link,$simple_layout_content_updated);
174
 
templates/myaccount/tracking-info.php CHANGED
@@ -31,8 +31,8 @@ if ( $tracking_items ) :
31
  $ast = new WC_Advanced_Shipment_Tracking_Actions;
32
 
33
  $tracking_info_settings = get_option('tracking_info_settings');
34
-
35
- $select_tracking_template = $tracking_info_settings['select_tracking_template'];
36
 
37
  $show_provider_th = 1;
38
  $colspan = 1;
@@ -64,9 +64,9 @@ if ( $tracking_items ) :
64
 
65
  if(get_theme_mod('table_border_size')){ $email_border_size = get_theme_mod('table_border_size'); } else{ $email_border_size = "1"; }
66
 
67
- if($tracking_info_settings['header_text_change']){ $shipment_tracking_header = $tracking_info_settings['header_text_change']; } else{ $shipment_tracking_header = "Tracking Information"; }
68
 
69
- if($tracking_info_settings['additional_header_text']){ $shipment_tracking_header_text = $tracking_info_settings['additional_header_text']; }
70
 
71
  $email_table_backgroud_color = $ast->get_option_value_from_array('tracking_info_settings','table_bg_color',$wcast_customizer_settings->defaults['table_bg_color']);
72
 
@@ -146,7 +146,7 @@ if ( $tracking_items ) :
146
 
147
  $simple_layout_content_updated = str_replace('{shipping_provider}',$formatted_tracking_provider,$simple_layout_content_updated);
148
 
149
- $tracking_number_link = '<a href="'.esc_url( $url ).'">'.$tracking_item['tracking_number'].'</a>';
150
 
151
  $simple_layout_content_updated = str_replace('{tracking_number_link}',$tracking_number_link,$simple_layout_content_updated);
152
 
31
  $ast = new WC_Advanced_Shipment_Tracking_Actions;
32
 
33
  $tracking_info_settings = get_option('tracking_info_settings');
34
+
35
+ $select_tracking_template = $ast->get_option_value_from_array('tracking_info_settings','select_tracking_template',$wcast_customizer_settings->defaults['select_tracking_template']);
36
 
37
  $show_provider_th = 1;
38
  $colspan = 1;
64
 
65
  if(get_theme_mod('table_border_size')){ $email_border_size = get_theme_mod('table_border_size'); } else{ $email_border_size = "1"; }
66
 
67
+ $shipment_tracking_header = $ast->get_option_value_from_array('tracking_info_settings','header_text_change','Tracking Information');
68
 
69
+ $shipment_tracking_header_text = $ast->get_option_value_from_array('tracking_info_settings','additional_header_text','');
70
 
71
  $email_table_backgroud_color = $ast->get_option_value_from_array('tracking_info_settings','table_bg_color',$wcast_customizer_settings->defaults['table_bg_color']);
72
 
146
 
147
  $simple_layout_content_updated = str_replace('{shipping_provider}',$formatted_tracking_provider,$simple_layout_content_updated);
148
 
149
+ $tracking_number_link = '<a target="_blank" href="'.esc_url( $url ).'">'.$tracking_item['tracking_number'].'</a>';
150
 
151
  $simple_layout_content_updated = str_replace('{tracking_number_link}',$tracking_number_link,$simple_layout_content_updated);
152
 
woocommerce-advanced-shipment-tracking.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Advanced Shipment Tracking for WooCommerce
5
  * Plugin URI: https://www.zorem.com/products/woocommerce-advanced-shipment-tracking/
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.9.6
8
  * Author: zorem
9
  * Author URI: https://www.zorem.com
10
  * License: GPL-2.0+
@@ -22,7 +22,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
22
  *
23
  * @var string
24
  */
25
- public $version = '2.9.6';
26
 
27
  /**
28
  * Initialize the main plugin function
@@ -185,10 +185,14 @@ class zorem_woocommerce_advanced_shipment_tracking {
185
  $wc_ast_status_delivered = get_option('wc_ast_status_delivered');
186
  if($wc_ast_status_delivered == 1)
187
  add_action( 'woocommerce_order_status_delivered', array( $this, 'email_trigger_delivered' ), 10, 2 );
 
 
 
 
188
 
189
  $wc_ast_status_partial_shipped = get_option('wc_ast_status_partial_shipped');
190
  if($wc_ast_status_partial_shipped == 1)
191
- add_action( 'woocommerce_order_status_partial-shipped', array( $this, 'email_trigger_partial_shipped' ), 10, 2 );
192
 
193
  $wc_ast_status_updated_tracking = get_option('wc_ast_status_updated_tracking');
194
  if($wc_ast_status_updated_tracking == 1)
@@ -216,6 +220,15 @@ class zorem_woocommerce_advanced_shipment_tracking {
216
  WC()->mailer()->emails['WC_Email_Customer_Partial_Shipped_Order']->trigger( $order_id, $order );
217
  }
218
 
 
 
 
 
 
 
 
 
 
219
  /**
220
  * Send email when order status change to "Updated Tracking"
221
  *
@@ -411,6 +424,10 @@ class zorem_woocommerce_advanced_shipment_tracking {
411
 
412
  require_once $this->get_plugin_path() . '/includes/customizer/class-wc-partial-shipped-email-customizer.php';
413
 
 
 
 
 
414
  require_once $this->get_plugin_path() . '/includes/customizer/class-wc-updated-tracking-email-customizer.php';
415
 
416
  require_once $this->get_plugin_path() . '/includes/customizer/class-wc-failure-email-customizer.php';
4
  * Plugin Name: Advanced Shipment Tracking for WooCommerce
5
  * Plugin URI: https://www.zorem.com/products/woocommerce-advanced-shipment-tracking/
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.9.9.3
8
  * Author: zorem
9
  * Author URI: https://www.zorem.com
10
  * License: GPL-2.0+
22
  *
23
  * @var string
24
  */
25
+ public $version = '2.9.9.3';
26
 
27
  /**
28
  * Initialize the main plugin function
185
  $wc_ast_status_delivered = get_option('wc_ast_status_delivered');
186
  if($wc_ast_status_delivered == 1)
187
  add_action( 'woocommerce_order_status_delivered', array( $this, 'email_trigger_delivered' ), 10, 2 );
188
+
189
+ $wc_ast_status_shipped = get_option('wc_ast_completed_to_shipped');
190
+ if($wc_ast_status_shipped == 'wc_ast_create_shipped')
191
+ add_action( 'woocommerce_order_status_shipped', array( $this, 'email_trigger_shipped' ), 10, 2 );
192
 
193
  $wc_ast_status_partial_shipped = get_option('wc_ast_status_partial_shipped');
194
  if($wc_ast_status_partial_shipped == 1)
195
+ add_action( 'woocommerce_order_status_partial-shipped', array( $this, 'email_trigger_partial_shipped' ), 10, 2 );
196
 
197
  $wc_ast_status_updated_tracking = get_option('wc_ast_status_updated_tracking');
198
  if($wc_ast_status_updated_tracking == 1)
220
  WC()->mailer()->emails['WC_Email_Customer_Partial_Shipped_Order']->trigger( $order_id, $order );
221
  }
222
 
223
+ /**
224
+ * Send email when order status change to "Shipped"
225
+ *
226
+ */
227
+ public function email_trigger_shipped($order_id, $order = false){
228
+ require_once( 'includes/email-manager.php' );
229
+ WC()->mailer()->emails['WC_Email_Customer_Shipped_Order']->trigger( $order_id, $order );
230
+ }
231
+
232
  /**
233
  * Send email when order status change to "Updated Tracking"
234
  *
424
 
425
  require_once $this->get_plugin_path() . '/includes/customizer/class-wc-partial-shipped-email-customizer.php';
426
 
427
+ if(get_option('wc_ast_completed_to_shipped') == 'wc_ast_create_shipped' && get_option('wc_ast_status_shipped_active')){
428
+ require_once $this->get_plugin_path() . '/includes/customizer/class-wc-shipped-email-customizer.php';
429
+ }
430
+
431
  require_once $this->get_plugin_path() . '/includes/customizer/class-wc-updated-tracking-email-customizer.php';
432
 
433
  require_once $this->get_plugin_path() . '/includes/customizer/class-wc-failure-email-customizer.php';