Flexible Shipping for WooCommerce - Version 3.2.0

Version Description

  • 2019-03-11 =
  • Added support for UPS Access Points for FS Connect
  • Removed argument types for WooCommerce types (ie. WC_Order)
Download this release

Release Info

Developer jablonowski
Plugin Icon 128x128 Flexible Shipping for WooCommerce
Version 3.2.0
Comparing to
See all releases

Code changes from version 3.1.12 to 3.2.0

Files changed (69) hide show
  1. assets/images/ajax-loading.gif +0 -0
  2. assets/images/marker-icon.png +0 -0
  3. assets/js/admin.js +1 -0
  4. assets/js/admin.min.js +1 -1
  5. assets/js/admin_saas_platform.js +12 -4
  6. assets/js/admin_saas_platform.min.js +1 -1
  7. assets/js/checkout.js +3 -0
  8. assets/js/checkout.min.js +1 -0
  9. assets/js/collection-points-map.js +58 -0
  10. assets/js/collection-points-map.min.js +1 -0
  11. classes/checkout/class-checkout-ajax-request-data.php +119 -0
  12. classes/class-flexible-shipping-plugin.php +13 -4
  13. classes/manifest/class-manifest.php +19 -18
  14. classes/saas/checkout-fields/class-saas-checkout-field-collection-points.php +153 -0
  15. classes/saas/checkout-fields/class-saas-checkout-fields-checkout.php +166 -0
  16. classes/saas/checkout-fields/class-saas-checkout-fields-shipment.php +123 -0
  17. classes/saas/checkout-fields/class-saas-field-visible-when-checkout.php +71 -0
  18. classes/saas/checkout-fields/class-saas-field-visible-when-shipment.php +63 -0
  19. classes/saas/checkout-fields/class-saas-field-visible-when.php +70 -0
  20. classes/saas/class-saas-free-shipping-metadata-handler.php +1 -1
  21. classes/saas/class-saas-live-rates-fallback-metadata-handler.php +3 -3
  22. classes/saas/class-saas-live-rates-handler.php +26 -3
  23. classes/saas/class-saas-shipping-service.php +25 -0
  24. classes/saas/class-saas-shipping-services-manager.php +35 -4
  25. classes/saas/collection-points/class-saas-collection-points-ajax-request-data.php +21 -0
  26. classes/saas/collection-points/class-saas-collection-points-ajax.php +81 -0
  27. classes/saas/collection-points/class-saas-collection-points-map.php +66 -0
  28. classes/saas/collection-points/class-saas-shipping-service-collection-points.php +126 -0
  29. classes/saas/collection-points/views/map.php +174 -0
  30. classes/shipment/class-shipment-request-fields.php +15 -0
  31. classes/shipment/class-shipment.php +19 -18
  32. classes/shipment/cpt-shipment.php +7 -2
  33. classes/shipment/functions.php +18 -7
  34. classes/shipment/saas/class-shipment-saas-metabox.php +27 -0
  35. classes/shipment/saas/class-shipment-saas-send.php +4 -3
  36. classes/shipment/saas/class-shipment-saas.php +63 -25
  37. classes/shipment/saas/views/order-metabox-fieldset.php +16 -3
  38. flexible-shipping.php +3 -3
  39. lang/flexible-shipping-pl_PL.mo +0 -0
  40. lang/flexible-shipping-pl_PL.po +55 -30
  41. plugin-load.php +1 -1
  42. readme.txt +5 -1
  43. templates/checkout/shipping-method-after.php +42 -0
  44. templates/email/after_order_table_checkout_field.php +22 -0
  45. templates/myaccount/after_order_table_checkout_field.php +22 -0
  46. vendor/autoload.php +1 -1
  47. vendor/composer/autoload_classmap.php +21 -0
  48. vendor/composer/autoload_real.php +7 -7
  49. vendor/composer/autoload_static.php +25 -4
  50. vendor/composer/installed.json +6 -6
  51. vendor/wpdesk/wp-saas-platform-client/changelog.txt +6 -0
  52. vendor/wpdesk/wp-saas-platform-client/src/ApiClient/ClientImplementation.php +1 -1
  53. vendor/wpdesk/wp-saas-platform-client/src/ApiClient/RequestCacheInfoResolver.php +1 -2
  54. vendor/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/ClientCollectionPoint.php +89 -0
  55. vendor/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/ClientMapLocation.php +38 -0
  56. vendor/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SearchRequest.php +52 -0
  57. vendor/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SearchResponse.php +34 -0
  58. vendor/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SingleRequest.php +23 -0
  59. vendor/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SingleResponse.php +34 -0
  60. vendor/wpdesk/wp-saas-platform-client/src/Model/Rate/RateRequest.php +1 -0
  61. vendor/wpdesk/wp-saas-platform-client/src/Model/Shipment/Actor.php +14 -0
  62. vendor/wpdesk/wp-saas-platform-client/src/Model/Shipment/Address.php +54 -6
  63. vendor/wpdesk/wp-saas-platform-client/src/Model/Shipment/ShipmentRequest.php +24 -0
  64. vendor/wpdesk/wp-saas-platform-client/src/Platform.php +57 -0
  65. vendor/wpdesk/wp-saas-platform-client/src/Request/ParcelCollectionPoints/GetSingleRequest.php +33 -0
  66. vendor/wpdesk/wp-saas-platform-client/src/Request/ParcelCollectionPoints/PostSearchRequest.php +38 -0
  67. vendor/wpdesk/wp-saas-platform-client/src/Response/ParcelCollectionPoints/GetSingleResponse.php +23 -0
  68. vendor/wpdesk/wp-saas-platform-client/src/Response/ParcelCollectionPoints/PostSearchResponse.php +35 -0
  69. vendor/wpdesk/wp-saas-platform-client/src/Response/Rate/PostRateResponse.php +2 -1
assets/images/ajax-loading.gif ADDED
Binary file
assets/images/marker-icon.png ADDED
Binary file
assets/js/admin.js CHANGED
@@ -197,6 +197,7 @@ function fs_ajax(button, id, fs_action) {
197
  }).always(function () {
198
  jQuery('.button-shipping').attr('disabled', false);
199
  jQuery('.shipping-spinner').parent().find('.spinner').css({visibility: 'hidden'});
 
200
  }).fail(function (jqXHR, textStatus) {
201
  jQuery('#flexible_shipping_shipment_' + id + ' .flexible_shipping_shipment_message').addClass("flexible_shipping_shipment_message_error");
202
  jQuery('#flexible_shipping_shipment_' + id + ' .flexible_shipping_shipment_message').show();
197
  }).always(function () {
198
  jQuery('.button-shipping').attr('disabled', false);
199
  jQuery('.shipping-spinner').parent().find('.spinner').css({visibility: 'hidden'});
200
+ fs_select2();
201
  }).fail(function (jqXHR, textStatus) {
202
  jQuery('#flexible_shipping_shipment_' + id + ' .flexible_shipping_shipment_message').addClass("flexible_shipping_shipment_message_error");
203
  jQuery('#flexible_shipping_shipment_' + id + ' .flexible_shipping_shipment_message').show();
assets/js/admin.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(){if(jQuery("#flexible_shipping_labels_url").length){window.location.href=jQuery("#flexible_shipping_labels_url").attr("href")}if(jQuery("a.shipping_manifest_download").length==1){window.location.href=jQuery("a.shipping_manifest_download").attr("href")}if(typeof window.history.pushState=="function"){var a=document.location.href;var d=document.location.href;a=fs_removeParam("bulk_flexible_shipping_labels",a);a=fs_removeParam("bulk_flexible_shipping_send",a);a=fs_removeParam("bulk_flexible_shipping_manifests",a);a=fs_removeParam("bulk_flexible_shipping_no_labels_created",a);a=fs_trimChar(a,"?");if(a!=d){window.history.pushState({},"",a)}}var e=jQuery(".fs-connect__vertical-nav-container"),c=jQuery(".fs-connect__content-container");nextFeatureButtons=jQuery(".fs-banner__button-container .next-feature"),e.on("click",".vertical-menu__feature-item:not( .vertical-menu__feature-item-is-selected )",function(){b(jQuery(this).index())});nextFeatureButtons.on("click",function(g){g.preventDefault();var f=jQuery(this).closest(".fs-connect__slide").index();b(f+1)});function b(f){e.find(".vertical-menu__feature-item-is-selected").removeClass("vertical-menu__feature-item-is-selected");c.find(".fs__slide-is-active").removeClass("fs__slide-is-active");e.children().eq(f).addClass("vertical-menu__feature-item-is-selected");c.children().eq(f).addClass("fs__slide-is-active")}});function fs_removeParam(b,d){var e=d.split("?")[0],f,c=[],g=(d.indexOf("?")!==-1)?d.split("?")[1]:"";if(g!==""){c=g.split("&");for(var a=c.length-1;a>=0;a-=1){f=c[a].split("=")[0];if(f===b){c.splice(a,1)}}e=e+"?"+c.join("&")}return e}function fs_trimChar(b,a){while(b.charAt(0)==a){b=b.substring(1)}while(b.charAt(b.length-1)==a){b=b.substring(0,b.length-1)}return b}function fs_id(a){return jQuery(a).closest(".flexible_shipping_shipment").attr("data-id")}function fs_data_set_val(c,a,f){if(typeof a=="undefined"){return c}if(a.indexOf("[")==-1){c[a]=f}else{var d=a.split("[");var g=c;var e=c;var b="";jQuery.each(d,function(i,h){b=h.replace("]","");if(typeof g[b]=="undefined"){g[b]={}}e=g;g=g[b]});e[b]=f}return c}function fs_ajax(a,e,d){jQuery(".button-shipping").attr("disabled",true);jQuery(a).parent().find(".spinner").css({visibility:"visible"});var c={};jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content input, #flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content select, #flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content textarea").each(function(){if(jQuery(this).attr("type")=="radio"){c=fs_data_set_val(c,jQuery(this).attr("name"),jQuery("#flexible_shipping_shipment_"+e+" input[name="+jQuery(this).attr("name")+"]:checked").val())}else{if(jQuery(this).attr("type")=="checkbox"){if(jQuery(this).is(":checked")){c=fs_data_set_val(c,jQuery(this).attr("name"),jQuery(this).val())}else{c=fs_data_set_val(c,jQuery(this).attr("name"),"")}}else{c=fs_data_set_val(c,jQuery(this).attr("name"),jQuery(this).val())}}});var b=jQuery("#flexible_shipping_shipment_nonce_"+e).val();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").hide();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").removeClass("flexible_shipping_shipment_message_error");jQuery.ajax({url:fs_admin.ajax_url,type:"POST",data:{fs_action:d,action:"flexible_shipping",nonce:b,shipment_id:e,data:c},dataType:"json"}).done(function(f){if(f){if(f=="0"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html("Invalid response: 0")}else{if(f.status=="success"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content").html(f.content);jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").hide();if(typeof f.message!="undefined"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html(f.message)}}else{if(typeof f.content!=="undefined"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content").html(f.content)}jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").addClass("flexible_shipping_shipment_message_error");jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html(f.message)}}}else{jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").addClass("flexible_shipping_shipment_message_error");jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html("Request failed: invalid method?")}}).always(function(){jQuery(".button-shipping").attr("disabled",false);jQuery(".shipping-spinner").parent().find(".spinner").css({visibility:"hidden"})}).fail(function(f,g){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").addClass("flexible_shipping_shipment_message_error");jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html("Request failed: "+g+" "+f.status)})}jQuery(function(a){a(document).on("click",".flexible-shipping-taxes-notice .notice-dismiss",function(){a.ajax(ajaxurl,{type:"POST",data:{action:"flexible_shipping_taxes_notice"}})})});
1
+ jQuery(document).ready(function(){if(jQuery("#flexible_shipping_labels_url").length){window.location.href=jQuery("#flexible_shipping_labels_url").attr("href")}if(jQuery("a.shipping_manifest_download").length==1){window.location.href=jQuery("a.shipping_manifest_download").attr("href")}if(typeof window.history.pushState=="function"){var a=document.location.href;var d=document.location.href;a=fs_removeParam("bulk_flexible_shipping_labels",a);a=fs_removeParam("bulk_flexible_shipping_send",a);a=fs_removeParam("bulk_flexible_shipping_manifests",a);a=fs_removeParam("bulk_flexible_shipping_no_labels_created",a);a=fs_trimChar(a,"?");if(a!=d){window.history.pushState({},"",a)}}var e=jQuery(".fs-connect__vertical-nav-container"),c=jQuery(".fs-connect__content-container");nextFeatureButtons=jQuery(".fs-banner__button-container .next-feature"),e.on("click",".vertical-menu__feature-item:not( .vertical-menu__feature-item-is-selected )",function(){b(jQuery(this).index())});nextFeatureButtons.on("click",function(g){g.preventDefault();var f=jQuery(this).closest(".fs-connect__slide").index();b(f+1)});function b(f){e.find(".vertical-menu__feature-item-is-selected").removeClass("vertical-menu__feature-item-is-selected");c.find(".fs__slide-is-active").removeClass("fs__slide-is-active");e.children().eq(f).addClass("vertical-menu__feature-item-is-selected");c.children().eq(f).addClass("fs__slide-is-active")}});function fs_removeParam(b,d){var e=d.split("?")[0],f,c=[],g=(d.indexOf("?")!==-1)?d.split("?")[1]:"";if(g!==""){c=g.split("&");for(var a=c.length-1;a>=0;a-=1){f=c[a].split("=")[0];if(f===b){c.splice(a,1)}}e=e+"?"+c.join("&")}return e}function fs_trimChar(b,a){while(b.charAt(0)==a){b=b.substring(1)}while(b.charAt(b.length-1)==a){b=b.substring(0,b.length-1)}return b}function fs_id(a){return jQuery(a).closest(".flexible_shipping_shipment").attr("data-id")}function fs_data_set_val(c,a,f){if(typeof a=="undefined"){return c}if(a.indexOf("[")==-1){c[a]=f}else{var d=a.split("[");var g=c;var e=c;var b="";jQuery.each(d,function(i,h){b=h.replace("]","");if(typeof g[b]=="undefined"){g[b]={}}e=g;g=g[b]});e[b]=f}return c}function fs_ajax(a,e,d){jQuery(".button-shipping").attr("disabled",true);jQuery(a).parent().find(".spinner").css({visibility:"visible"});var c={};jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content input, #flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content select, #flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content textarea").each(function(){if(jQuery(this).attr("type")=="radio"){c=fs_data_set_val(c,jQuery(this).attr("name"),jQuery("#flexible_shipping_shipment_"+e+" input[name="+jQuery(this).attr("name")+"]:checked").val())}else{if(jQuery(this).attr("type")=="checkbox"){if(jQuery(this).is(":checked")){c=fs_data_set_val(c,jQuery(this).attr("name"),jQuery(this).val())}else{c=fs_data_set_val(c,jQuery(this).attr("name"),"")}}else{c=fs_data_set_val(c,jQuery(this).attr("name"),jQuery(this).val())}}});var b=jQuery("#flexible_shipping_shipment_nonce_"+e).val();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").hide();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").removeClass("flexible_shipping_shipment_message_error");jQuery.ajax({url:fs_admin.ajax_url,type:"POST",data:{fs_action:d,action:"flexible_shipping",nonce:b,shipment_id:e,data:c},dataType:"json"}).done(function(f){if(f){if(f=="0"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html("Invalid response: 0")}else{if(f.status=="success"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content").html(f.content);jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").hide();if(typeof f.message!="undefined"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html(f.message)}}else{if(typeof f.content!=="undefined"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content").html(f.content)}jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").addClass("flexible_shipping_shipment_message_error");jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html(f.message)}}}else{jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").addClass("flexible_shipping_shipment_message_error");jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html("Request failed: invalid method?")}}).always(function(){jQuery(".button-shipping").attr("disabled",false);jQuery(".shipping-spinner").parent().find(".spinner").css({visibility:"hidden"});fs_select2()}).fail(function(f,g){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").addClass("flexible_shipping_shipment_message_error");jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html("Request failed: "+g+" "+f.status)})}jQuery(function(a){a(document).on("click",".flexible-shipping-taxes-notice .notice-dismiss",function(){a.ajax(ajaxurl,{type:"POST",data:{action:"flexible_shipping_taxes_notice"}})})});
assets/js/admin_saas_platform.js CHANGED
@@ -78,6 +78,17 @@ function flexible_shipping_saas_checkbox_dependent_field(checkbox) {
78
  }
79
  }
80
 
 
 
 
 
 
 
 
 
 
 
 
81
  jQuery(document).on('click','.fs-saas-button-create', function( event ) {
82
  flexible_shipping_saas_click_action( 'send', this, event );
83
  });
@@ -98,9 +109,6 @@ jQuery(document).on('change', 'input[type=checkbox]', function( e ) {
98
  });
99
 
100
  jQuery(document).ready(function() {
101
- let elements = jQuery( '.fs_select2' );
102
- if ( elements.length ) {
103
- elements.select2();
104
- }
105
  });
106
 
78
  }
79
  }
80
 
81
+ function fs_select2() {
82
+ let elements = jQuery( '.fs_select2' );
83
+ if ( elements.length ) {
84
+ if (jQuery.fn.selectWoo) {
85
+ elements.selectWoo();
86
+ } else {
87
+ elements.select2();
88
+ }
89
+ }
90
+ }
91
+
92
  jQuery(document).on('click','.fs-saas-button-create', function( event ) {
93
  flexible_shipping_saas_click_action( 'send', this, event );
94
  });
109
  });
110
 
111
  jQuery(document).ready(function() {
112
+ fs_select2();
 
 
 
113
  });
114
 
assets/js/admin_saas_platform.min.js CHANGED
@@ -1 +1 @@
1
- function flexible_shipping_saas_integration_options(b){var a="."+b;jQuery(".flexible_shipping_method_rules").css("display","table-row");if(jQuery("#woocommerce_flexible_shipping_method_integration").val()==b){jQuery(a).closest("tr").css("display","table-row")}else{jQuery(a).closest("tr").css("display","none")}flexible_shipping_saas_rates_type_options()}function flexible_shipping_saas_rates_type_options(){if(jQuery("#woocommerce_flexible_shipping_method_integration").length){var a="."+jQuery("#woocommerce_flexible_shipping_method_integration").val();if(a!=="."){var b=jQuery(".fs-rates-type"+a).val();jQuery(a).each(function(c){var d=jQuery(this).closest("tr");if("custom"===b){if(!jQuery(this).hasClass("fs-method")){d.css("display","none")}else{d.css("display","table-row")}}if("live"===b){if(!jQuery(this).hasClass("fs-live")){d.css("display","none")}else{d.css("display","table-row")}}});jQuery(window).trigger("resize");jQuery(a).each(function(c){if("checkbox"===jQuery(this).attr("type")){jQuery(this).trigger("change")}})}}}function flexible_shipping_saas_click_action(c,a,b){let id=jQuery(a).attr("data-id");if(typeof id!=="undefined"){b.stopImmediatePropagation();b.preventDefault();let element_id=fs_id(a);fs_ajax(a,element_id,c)}}function flexible_shipping_saas_checkbox_dependent_field(c){var a=jQuery(c).data("dependent-field-id");if(typeof a!=="undefined"&&jQuery(c).is(":visible")){var e=jQuery("#"+a);if(jQuery(c).is(":checked")){e.closest("tr").css("display","table-row")}else{e.closest("tr").css("display","none")}}var b=jQuery(c).data("dependent-row-class");if(typeof b!=="undefined"){var d=jQuery("."+b);if(jQuery(c).is(":visible")){if(jQuery(c).is(":checked")){d.css("display","table-row")}else{d.css("display","none")}}else{d.css("display","table-row")}}}jQuery(document).on("click",".fs-saas-button-create",function(a){flexible_shipping_saas_click_action("send",this,a)});jQuery(document).on("click",".fs-saas-button-save",function(a){flexible_shipping_saas_click_action("save",this,event)});jQuery(document).on("click",".fs-saas-button-cancel-created",function(a){flexible_shipping_saas_click_action("cancel",this,event)});jQuery(document).on("change",".fs-rates-type",function(a){flexible_shipping_saas_rates_type_options()});jQuery(document).on("change","input[type=checkbox]",function(a){flexible_shipping_saas_checkbox_dependent_field(this)});jQuery(document).ready(function(){let elements=jQuery(".fs_select2");if(elements.length){elements.select2()}});
1
+ function flexible_shipping_saas_integration_options(b){var a="."+b;jQuery(".flexible_shipping_method_rules").css("display","table-row");if(jQuery("#woocommerce_flexible_shipping_method_integration").val()==b){jQuery(a).closest("tr").css("display","table-row")}else{jQuery(a).closest("tr").css("display","none")}flexible_shipping_saas_rates_type_options()}function flexible_shipping_saas_rates_type_options(){if(jQuery("#woocommerce_flexible_shipping_method_integration").length){var a="."+jQuery("#woocommerce_flexible_shipping_method_integration").val();if(a!=="."){var b=jQuery(".fs-rates-type"+a).val();jQuery(a).each(function(c){var d=jQuery(this).closest("tr");if("custom"===b){if(!jQuery(this).hasClass("fs-method")){d.css("display","none")}else{d.css("display","table-row")}}if("live"===b){if(!jQuery(this).hasClass("fs-live")){d.css("display","none")}else{d.css("display","table-row")}}});jQuery(window).trigger("resize");jQuery(a).each(function(c){if("checkbox"===jQuery(this).attr("type")){jQuery(this).trigger("change")}})}}}function flexible_shipping_saas_click_action(c,a,b){let id=jQuery(a).attr("data-id");if(typeof id!=="undefined"){b.stopImmediatePropagation();b.preventDefault();let element_id=fs_id(a);fs_ajax(a,element_id,c)}}function flexible_shipping_saas_checkbox_dependent_field(c){var a=jQuery(c).data("dependent-field-id");if(typeof a!=="undefined"&&jQuery(c).is(":visible")){var e=jQuery("#"+a);if(jQuery(c).is(":checked")){e.closest("tr").css("display","table-row")}else{e.closest("tr").css("display","none")}}var b=jQuery(c).data("dependent-row-class");if(typeof b!=="undefined"){var d=jQuery("."+b);if(jQuery(c).is(":visible")){if(jQuery(c).is(":checked")){d.css("display","table-row")}else{d.css("display","none")}}else{d.css("display","table-row")}}}function fs_select2(){let elements=jQuery(".fs_select2");if(elements.length){if(jQuery.fn.selectWoo){elements.selectWoo()}else{elements.select2()}}}jQuery(document).on("click",".fs-saas-button-create",function(a){flexible_shipping_saas_click_action("send",this,a)});jQuery(document).on("click",".fs-saas-button-save",function(a){flexible_shipping_saas_click_action("save",this,event)});jQuery(document).on("click",".fs-saas-button-cancel-created",function(a){flexible_shipping_saas_click_action("cancel",this,event)});jQuery(document).on("change",".fs-rates-type",function(a){flexible_shipping_saas_rates_type_options()});jQuery(document).on("change","input[type=checkbox]",function(a){flexible_shipping_saas_checkbox_dependent_field(this)});jQuery(document).ready(function(){fs_select2()});
assets/js/checkout.js ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ jQuery(document).on('change', '.flexible-shipping-collection-point-select', function () {
2
+ jQuery(document.body).trigger('update_checkout');
3
+ });
assets/js/checkout.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).on("change",".flexible-shipping-collection-point-select",function(){jQuery(document.body).trigger("update_checkout")});
assets/js/collection-points-map.js ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function () {
2
+ var window_map;
3
+
4
+ jQuery(document).on('click', '.flexible-shipping-collection-point-map-selector', function () {
5
+ var service_id = jQuery(this).attr('data-service-id');
6
+ var select_id = jQuery(this).attr('data-select-id');
7
+ var params = {
8
+ service_id: service_id,
9
+ select_id: select_id,
10
+ };
11
+
12
+ var y = window.top.outerHeight / 2 + window.top.screenY - (600 / 2);
13
+ var x = window.top.outerWidth / 2 + window.top.screenX - (800 / 2);
14
+
15
+ window_map = window.open(fs_collection_points_map.collection_points_map_url + '&' + jQuery.param(params), "", "width=800,height=600,top=" + y + ",left=" + x);
16
+ window.addEventListener('message', function (event) {
17
+ if (event.origin !== window.location.origin) {
18
+ return false;
19
+ }
20
+
21
+ if ('get_adresses_data' === event.data.action) {
22
+ send_adresses_data_to_map(window_map, service_id, select_id);
23
+ }
24
+
25
+ if (event.data.point_id && 'select_point' === event.data.action) {
26
+ update_point_from_map(event.data.point_id, select_id);
27
+ }
28
+ }, true);
29
+ return false;
30
+ });
31
+
32
+ function update_point_from_map(point_id, select_id) {
33
+ var point_select = jQuery('#' + select_id);
34
+ point_select.val(point_id);
35
+ point_select.trigger('change.select2');
36
+ jQuery(document.body).trigger('update_checkout');
37
+ }
38
+
39
+ function send_adresses_data_to_map(window_map, service_id, select_field_id) {
40
+ var data = {
41
+ different_addres: jQuery('#ship-to-different-address-checkbox').prop('checked'),
42
+ shipping_country: jQuery('#shipping_country').val(),
43
+ shipping_address_1: jQuery('#shipping_address_1').val(),
44
+ shipping_address_2: jQuery('#shipping_address_2').val(),
45
+ shipping_postcode: jQuery('#shipping_postcode').val(),
46
+ shipping_city: jQuery('#shipping_city').val(),
47
+ billing_country: jQuery('#billing_country').val(),
48
+ billing_address_1: jQuery('#billing_address_1').val(),
49
+ billing_address_2: jQuery('#billing_address_2').val(),
50
+ billing_postcode: jQuery('#billing_postcode').val(),
51
+ billing_city: jQuery('#billing_city').val(),
52
+ selected_point: jQuery('#' + select_field_id).val(),
53
+ action: 'fs_collection_points_' + service_id,
54
+ security: fs_collection_points_map.ajax_nonce
55
+ };
56
+ window_map.postMessage({addresses_data: data, action: 'send_address_data'}, window.location.origin);
57
+ }
58
+ })
assets/js/collection-points-map.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(){var b;jQuery(document).on("click",".flexible-shipping-collection-point-map-selector",function(){var e=jQuery(this).attr("data-service-id");var h=jQuery(this).attr("data-select-id");var f={service_id:e,select_id:h};var g=window.top.outerHeight/2+window.top.screenY-(600/2);var d=window.top.outerWidth/2+window.top.screenX-(800/2);b=window.open(fs_collection_points_map.collection_points_map_url+"&"+jQuery.param(f),"","width=800,height=600,top="+g+",left="+d);window.addEventListener("message",function(i){if(i.origin!==window.location.origin){return false}if("get_adresses_data"===i.data.action){c(b,e,h)}if(i.data.point_id&&"select_point"===i.data.action){a(i.data.point_id,h)}},true);return false});function a(d,f){var e=jQuery("#"+f);e.val(d);e.trigger("change.select2");jQuery(document.body).trigger("update_checkout")}function c(d,f,e){var g={different_addres:jQuery("#ship-to-different-address-checkbox").prop("checked"),shipping_country:jQuery("#shipping_country").val(),shipping_address_1:jQuery("#shipping_address_1").val(),shipping_address_2:jQuery("#shipping_address_2").val(),shipping_postcode:jQuery("#shipping_postcode").val(),shipping_city:jQuery("#shipping_city").val(),billing_country:jQuery("#billing_country").val(),billing_address_1:jQuery("#billing_address_1").val(),billing_address_2:jQuery("#billing_address_2").val(),billing_postcode:jQuery("#billing_postcode").val(),billing_city:jQuery("#billing_city").val(),selected_point:jQuery("#"+e).val(),action:"fs_collection_points_"+f,security:fs_collection_points_map.ajax_nonce};d.postMessage({addresses_data:g,action:"send_address_data"},window.location.origin)}});
classes/checkout/class-checkout-ajax-request-data.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Handles woocommerce AJAX request data.
5
+ *
6
+ * Class WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data
7
+ */
8
+ class WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data {
9
+
10
+ /**
11
+ * POST data.
12
+ *
13
+ * @var array
14
+ */
15
+ protected $post_data = array();
16
+
17
+ /**
18
+ * WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data constructor.
19
+ *
20
+ * @param array $request Request array.
21
+ */
22
+ public function __construct( array $request ) {
23
+ if ( ! empty( $request['post_data'] ) ) {
24
+ parse_str( $request['post_data'], $this->post_data );
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Get data by name;
30
+ *
31
+ * @param string $name Name.
32
+ *
33
+ * @return string|null
34
+ */
35
+ public function get_data_by_name( $name ) {
36
+ return isset( $this->post_data[ $name ] ) ? $this->post_data[ $name ] : null;
37
+ }
38
+
39
+ /**
40
+ * Ship to difrrent address?
41
+ *
42
+ * @return bool
43
+ */
44
+ private function ship_to_different_address() {
45
+ $ship_to_different_address = $this->get_data_by_name( 'ship_to_different_address' );
46
+ return isset( $ship_to_different_address ) && '1' === $ship_to_different_address;
47
+ }
48
+
49
+ /**
50
+ * Get shipping field value.
51
+ *
52
+ * @param string $field_name Field name.
53
+ *
54
+ * @return string
55
+ */
56
+ private function get_shipping_field_value( $field_name ) {
57
+ if ( $this->ship_to_different_address() ) {
58
+ $field_value = $this->get_data_by_name( 'shipping_' . $field_name );
59
+ } else {
60
+ $field_value = $this->get_data_by_name( 'billing_' . $field_name );
61
+ }
62
+ return is_null( $field_value ) ? '' : $field_value;
63
+ }
64
+
65
+ /**
66
+ * Get shipping address_1.
67
+ *
68
+ * @return string
69
+ */
70
+ public function get_shipping_address_1() {
71
+ return $this->get_shipping_field_value( 'address_1' );
72
+ }
73
+
74
+ /**
75
+ * Get shipping address_2.
76
+ *
77
+ * @return string
78
+ */
79
+ public function get_shipping_address_2() {
80
+ return $this->get_shipping_field_value( 'address_2' );
81
+ }
82
+
83
+ /**
84
+ * Get shipping postcode.
85
+ *
86
+ * @return string
87
+ */
88
+ public function get_shipping_postcode() {
89
+ return $this->get_shipping_field_value( 'postcode' );
90
+ }
91
+
92
+ /**
93
+ * Get shipping city.
94
+ *
95
+ * @return string
96
+ */
97
+ public function get_shipping_city() {
98
+ return $this->get_shipping_field_value( 'city' );
99
+ }
100
+
101
+ /**
102
+ * Get shipping state.
103
+ *
104
+ * @return string
105
+ */
106
+ public function get_shipping_state() {
107
+ return $this->get_shipping_field_value( 'state' );
108
+ }
109
+
110
+ /**
111
+ * Get shipping country.
112
+ *
113
+ * @return string
114
+ */
115
+ public function get_shipping_country() {
116
+ return $this->get_shipping_field_value( 'country' );
117
+ }
118
+
119
+ }
classes/class-flexible-shipping-plugin.php CHANGED
@@ -17,7 +17,7 @@ class Flexible_Shipping_Plugin
17
  /**
18
  * @var string
19
  */
20
- private $scripts_version = '165';
21
 
22
  /**
23
  * @var WPDesk_Flexible_Shipping_Admin_Notices
@@ -111,7 +111,7 @@ class Flexible_Shipping_Plugin
111
 
112
  $this->add_hookable( new WPDesk_Flexible_Shipping_SaaS_User_Registration( $connection, $this->saas_platform_links, $this->variant ) );
113
 
114
- $services_manager = new WPDesk_Flexible_Shipping_SaaS_Services_Manager( $connection, $this->saas_platform_links, $this->logger, $this->variant );
115
  $this->add_hookable( $services_manager );
116
 
117
  if ( $services_manager->is_require_uk_states() ) {
@@ -135,6 +135,8 @@ class Flexible_Shipping_Plugin
135
 
136
  $this->add_hookable( new WPDesk_Flexible_Shipping_SaaS_Tracker( $connection, $services_manager ) );
137
 
 
 
138
  }
139
 
140
  /**
@@ -185,8 +187,8 @@ class Flexible_Shipping_Plugin
185
  public function init() {
186
  $this->init_base_variables();
187
  $this->init_platform_links();
188
- $this->load_dependencies();
189
  $this->init_renderer();
 
190
  $this->hooks();
191
  }
192
 
@@ -284,7 +286,7 @@ class Flexible_Shipping_Plugin
284
  *
285
  * @param WC_Order $order Order.
286
  */
287
- public function add_flexible_shipping_order_meta_on_checkout( WC_Order $order ) {
288
  if ( ! $this->is_order_processed_on_checkout ) {
289
  $mutex = \WPDesk\Mutex\WordpressPostMutex::fromOrder( $order );
290
  $mutex->acquireLock();
@@ -410,6 +412,13 @@ class Flexible_Shipping_Plugin
410
  array(), $this->scripts_version );
411
  }
412
 
 
 
 
 
 
 
 
413
  /**
414
  * @param array $links
415
  *
17
  /**
18
  * @var string
19
  */
20
+ private $scripts_version = FLEXIBLE_SHIPPING_VERSION . '.181';
21
 
22
  /**
23
  * @var WPDesk_Flexible_Shipping_Admin_Notices
111
 
112
  $this->add_hookable( new WPDesk_Flexible_Shipping_SaaS_User_Registration( $connection, $this->saas_platform_links, $this->variant ) );
113
 
114
+ $services_manager = new WPDesk_Flexible_Shipping_SaaS_Services_Manager( $connection, $this->saas_platform_links, $this->renderer, $this->variant, $this->logger );
115
  $this->add_hookable( $services_manager );
116
 
117
  if ( $services_manager->is_require_uk_states() ) {
135
 
136
  $this->add_hookable( new WPDesk_Flexible_Shipping_SaaS_Tracker( $connection, $services_manager ) );
137
 
138
+ $this->add_hookable( new WPDesk_Flexible_Shipping_SaaS_Collection_Points_Map_Loader() );
139
+
140
  }
141
 
142
  /**
187
  public function init() {
188
  $this->init_base_variables();
189
  $this->init_platform_links();
 
190
  $this->init_renderer();
191
+ $this->load_dependencies();
192
  $this->hooks();
193
  }
194
 
286
  *
287
  * @param WC_Order $order Order.
288
  */
289
+ public function add_flexible_shipping_order_meta_on_checkout( $order ) {
290
  if ( ! $this->is_order_processed_on_checkout ) {
291
  $mutex = \WPDesk\Mutex\WordpressPostMutex::fromOrder( $order );
292
  $mutex->acquireLock();
412
  array(), $this->scripts_version );
413
  }
414
 
415
+
416
+ public function wp_enqueue_scripts() {
417
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
418
+ wp_register_script( 'fs_saas_checkout', trailingslashit( $this->get_plugin_assets_url() ) . 'js/checkout' . $suffix . '.js', array( 'jquery' ), $this->scripts_version );
419
+ wp_enqueue_script( 'fs_saas_checkout' );
420
+ }
421
+
422
  /**
423
  * @param array $links
424
  *
classes/manifest/class-manifest.php CHANGED
@@ -55,24 +55,25 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping_Manifest' ) ) {
55
  */
56
  private $meta_data_save_keys = array();
57
 
58
- /**
59
- * WPDesk_Flexible_Shipping_Manifest constructor.
60
- * @param $manifest
61
- * @param WC_Order|null $order
62
- */
63
- public function __construct( $manifest, WC_Order $order = null ) {
64
- if ( is_numeric( $manifest ) ) {
65
- $this->id = absint( $manifest );
66
- $this->post = get_post( $this->id );
67
- } elseif ( $manifest instanceof WPDesk_Flexible_Shipping_Manifest ) {
68
- $this->id = absint( $manifest->get_id() );
69
- $this->post = $manifest->get_post();
70
- } elseif ( isset( $manifest->ID ) ) {
71
- $this->id = absint( $manifest->ID );
72
- $this->post = $manifest;
73
- }
74
- $this->order = $order;
75
- }
 
76
 
77
  /**
78
  * @return mixed
55
  */
56
  private $meta_data_save_keys = array();
57
 
58
+ /**
59
+ * WPDesk_Flexible_Shipping_Manifest constructor.
60
+ *
61
+ * @param int|WPDesk_Flexible_Shipping_Manifest|WP_Post $manifest Manifest.
62
+ * @param WC_Order|null $order Order.
63
+ */
64
+ public function __construct( $manifest, $order = null ) {
65
+ if ( is_numeric( $manifest ) ) {
66
+ $this->id = absint( $manifest );
67
+ $this->post = get_post( $this->id );
68
+ } elseif ( $manifest instanceof WPDesk_Flexible_Shipping_Manifest ) {
69
+ $this->id = absint( $manifest->get_id() );
70
+ $this->post = $manifest->get_post();
71
+ } elseif ( isset( $manifest->ID ) ) {
72
+ $this->id = absint( $manifest->ID );
73
+ $this->post = $manifest;
74
+ }
75
+ $this->order = $order;
76
+ }
77
 
78
  /**
79
  * @return mixed
classes/saas/checkout-fields/class-saas-checkout-field-collection-points.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Displays collection points in checkout.
5
+ *
6
+ * Class WPDesk_Flexible_Shipping_SaaS_Collection_Points_Checkout_Field
7
+ */
8
+ class WPDesk_Flexible_Shipping_SaaS_Checkout_Field_Collection_Points {
9
+
10
+ const FLEXIBLE_SHIPPING_COLLECTION_POINT = 'flexible_shipping_collection_point';
11
+
12
+ /**
13
+ * Shipping service.
14
+ *
15
+ * @var WPDesk_Flexible_Shipping_SaaS_Shipping_Service
16
+ */
17
+ private $shipping_service;
18
+
19
+ /**
20
+ * Service collection points.
21
+ *
22
+ * @var WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points
23
+ */
24
+ private $service_collection_points;
25
+
26
+ /**
27
+ * Renderer.
28
+ *
29
+ * @var WPDesk\View\Renderer\Renderer;
30
+ */
31
+ private $renderer;
32
+
33
+ /**
34
+ * Request data.
35
+ *
36
+ * @var WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data
37
+ */
38
+ private $request_data;
39
+
40
+ /**
41
+ * Field.
42
+ *
43
+ * @var array
44
+ */
45
+ private $field;
46
+
47
+ /**
48
+ * WPDesk_Flexible_Shipping_SaaS_Collection_Points_Checkout_Field constructor.
49
+ *
50
+ * @param WPDesk_Flexible_Shipping_SaaS_Shipping_Service $shipping_service Shipping service.
51
+ * @param WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points $service_collection_points Service collection points.
52
+ * @param \WPDesk\View\Renderer\Renderer $renderer Renderer.
53
+ * @param null|WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data $request_data Request data.
54
+ * @param array $field Field.
55
+ */
56
+ public function __construct(
57
+ WPDesk_Flexible_Shipping_SaaS_Shipping_Service $shipping_service,
58
+ WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points $service_collection_points,
59
+ WPDesk\View\Renderer\Renderer $renderer,
60
+ $request_data,
61
+ $field
62
+ ) {
63
+ $this->shipping_service = $shipping_service;
64
+ $this->service_collection_points = $service_collection_points;
65
+ $this->renderer = $renderer;
66
+ $this->request_data = $request_data;
67
+ $this->field = $field;
68
+ }
69
+
70
+
71
+ /**
72
+ * Get request data.
73
+ *
74
+ * @return array
75
+ */
76
+ private function get_post_data_from_request() {
77
+ if ( ! empty( $_REQUEST['post_data'] ) ) {
78
+ parse_str( $_REQUEST['post_data'], $post_data );
79
+ } else {
80
+ $post_data = array();
81
+ }
82
+ return $post_data;
83
+ }
84
+
85
+ /**
86
+ * Prepare collection points options.
87
+ *
88
+ * @return array
89
+ */
90
+ private function prepare_collection_points_options() {
91
+ $address = new \WPDesk\SaasPlatformClient\Model\Shipment\Address();
92
+ $address->setAddressLine1( $this->request_data->get_shipping_address_1() );
93
+ $address->setAddressLine2( $this->request_data->get_shipping_address_2() );
94
+ $address->setPostalCode( $this->request_data->get_shipping_postcode() );
95
+ $address->setCity( $this->request_data->get_shipping_city() );
96
+ $address->setStateCode( $this->request_data->get_shipping_state() );
97
+ $address->setCountryCode( $this->request_data->get_shipping_country() );
98
+
99
+ return $this->service_collection_points->prepare_collection_points_options_for_address( $address );
100
+ }
101
+
102
+ /**
103
+ * Display collection point on checkout.
104
+ */
105
+ public function display_collection_point_field_on_checkout() {
106
+ $collection_points_options = $this->prepare_collection_points_options();
107
+ $selected_collection_point = '';
108
+ $post_data = $this->get_post_data_from_request();
109
+ $field_name = $this->field['id'] . '_' . $this->shipping_service->get_integration_id();
110
+ $field_label = $this->field['name'];
111
+ $field_description = empty( $this->field['description'] ) ? '' : $this->field['description'];
112
+ if ( isset( $post_data[ $field_name ] ) && array_key_exists( $post_data[ $field_name ], $collection_points_options ) ) {
113
+ $selected_collection_point = $post_data[ $field_name ];
114
+ }
115
+ echo $this->renderer->render( // phpcs:ignore
116
+ 'checkout/shipping-method-after',
117
+ array(
118
+ 'select_options' => $collection_points_options, // phpcs:ignore
119
+ 'selected_collection_point' => $selected_collection_point, // phpcs:ignore
120
+ 'collection_point_label' => $field_label, // phpcs:ignore
121
+ 'collection_point_description' => $field_description, // phpcs:ignore
122
+ 'collection_point_field_name' => $field_name, // phpcs:ignore
123
+ 'collection_point_map_selector_label' => __( 'Select point from map', 'flexible-shipping' ), // phpcs:ignore
124
+ 'collection_point_service_id' => strval( $this->shipping_service->get_id() ), // phpcs:ignore
125
+ )
126
+ );
127
+ }
128
+
129
+ /**
130
+ * Display collection point for shipment.
131
+ *
132
+ * @param string $folder Template folder.
133
+ * @param WPDesk_Flexible_Shipping_Shipment_Saas $shipment Shipment.
134
+ */
135
+ public function display_collection_point_field_for_shipment( $folder, $shipment ) {
136
+ $field_label = $this->field['name'];
137
+ try {
138
+ $collection_point_response = $this->service_collection_points->get_collection_point( $shipment->get_meta( $this->field['id'] ) );
139
+ $field_value = $this->service_collection_points->format_single_point_description_from_response( $collection_point_response );
140
+ } catch ( Exception $e ) {
141
+ $field_value = $e->getMessage();
142
+ }
143
+ echo $this->renderer->render( // phpcs:ignore
144
+ $folder . '/after_order_table_checkout_field',
145
+ array(
146
+ 'field_label' => $field_label, // phpcs:ignore
147
+ 'field_value' => $field_value, // phpcs:ignore
148
+ )
149
+ );
150
+
151
+ }
152
+
153
+ }
classes/saas/checkout-fields/class-saas-checkout-fields-checkout.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Displays additional shipping checkout fields on checkout.
5
+ *
6
+ * Class WPDesk_Flexible_Shipping_SaaS_Shipping_Checkout_Fields_Checkout
7
+ */
8
+ class WPDesk_Flexible_Shipping_SaaS_Shipping_Checkout_Fields_Checkout implements \WPDesk\PluginBuilder\Plugin\Hookable {
9
+
10
+ /**
11
+ * Shipping service.
12
+ *
13
+ * @var WPDesk_Flexible_Shipping_SaaS_Shipping_Service
14
+ */
15
+ private $shipping_service;
16
+
17
+ /**
18
+ * Service collection points.
19
+ *
20
+ * @var WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points
21
+ */
22
+ private $service_collection_points;
23
+
24
+ /**
25
+ * Renderer.
26
+ *
27
+ * @var WPDesk\View\Renderer\Renderer;
28
+ */
29
+ private $renderer;
30
+
31
+ /**
32
+ * WPDesk_Flexible_Shipping_SaaS_Shipping_Checkout_Fields_Checkout constructor.
33
+ *
34
+ * @param WPDesk_Flexible_Shipping_SaaS_Shipping_Service $shipping_service Shipping service.
35
+ * @param WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points $service_collection_points Service collection points.
36
+ * @param \WPDesk\View\Renderer\Renderer $renderer Renderer.
37
+ */
38
+ public function __construct(
39
+ WPDesk_Flexible_Shipping_SaaS_Shipping_Service $shipping_service,
40
+ WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points $service_collection_points,
41
+ WPDesk\View\Renderer\Renderer $renderer
42
+ ) {
43
+ $this->shipping_service = $shipping_service;
44
+ $this->service_collection_points = $service_collection_points;
45
+ $this->renderer = $renderer;
46
+ }
47
+
48
+ /**
49
+ * Hooks.
50
+ */
51
+ public function hooks() {
52
+ add_action( 'woocommerce_review_order_after_shipping', array( $this, 'maybe_display_fields_on_checkout_page' ) );
53
+ }
54
+
55
+ /**
56
+ * Get Flexible shipping method from rate meta.
57
+ *
58
+ * @param array $shipping_rate_meta Shipping rate meta.
59
+ * @return array
60
+ */
61
+ private function get_flexible_shipping_method_from_rate_meta( array $shipping_rate_meta ) {
62
+ $fs_method = array();
63
+ if ( isset( $shipping_rate_meta['_fs_method'] ) ) {
64
+ $fs_method = $shipping_rate_meta['_fs_method'];
65
+ }
66
+ return $fs_method;
67
+ }
68
+
69
+ /**
70
+ * Get method integration from flexible shipping method.
71
+ *
72
+ * @param array $fs_method Flexible shipping method.
73
+ * @return string
74
+ */
75
+ private function get_method_integration_from_fs_method( array $fs_method ) {
76
+ $method_integration = '';
77
+ if ( isset( $fs_method['method_integration'] ) ) {
78
+ $method_integration = $fs_method['method_integration'];
79
+ }
80
+ return $method_integration;
81
+ }
82
+
83
+ /**
84
+ * Display access point.
85
+ *
86
+ * @param WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data $request_data Request data.
87
+ * @param array $field Field.
88
+ */
89
+ private function display_access_point( WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data $request_data, $field ) {
90
+ $access_point = new WPDesk_Flexible_Shipping_SaaS_Checkout_Field_Collection_Points(
91
+ $this->shipping_service,
92
+ $this->service_collection_points,
93
+ $this->renderer,
94
+ $request_data,
95
+ $field
96
+ );
97
+ $access_point->display_collection_point_field_on_checkout();
98
+ }
99
+
100
+ /**
101
+ * Maybe display parcel collection points field for shipping method.
102
+ *
103
+ * @param array $field Field.
104
+ * @param WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data $request_data Request data.
105
+ * @param WC_Shipping_Rate $cart_shipping_rate Shipping method.
106
+ */
107
+ public function maybe_display_parcel_collection_points_field_for_shipping_method(
108
+ array $field,
109
+ WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data $request_data,
110
+ WC_Shipping_Rate $cart_shipping_rate
111
+ ) {
112
+ $shipping_rate_meta = $cart_shipping_rate->get_meta_data();
113
+ $fs_method = $this->get_flexible_shipping_method_from_rate_meta( $shipping_rate_meta );
114
+ if ( $this->shipping_service->get_integration_id() === $this->get_method_integration_from_fs_method( $fs_method ) ) {
115
+ $visible_when = WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When_Checkout::create_for_field( $field, $cart_shipping_rate );
116
+ if ( $visible_when->is_visible() ) {
117
+ $this->display_access_point( $request_data, $field );
118
+ }
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Maybe display parcel collection points field.
124
+ *
125
+ * @param array $field Field.
126
+ * @param WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data $request_data Request data.
127
+ */
128
+ private function maybe_display_parcel_collection_points_field( array $field, WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data $request_data ) {
129
+ $cart_shipping_methods = WC()->cart->calculate_shipping();
130
+ foreach ( $cart_shipping_methods as $cart_shipping_rate ) {
131
+ $this->maybe_display_parcel_collection_points_field_for_shipping_method( $field, $request_data, $cart_shipping_rate );
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Maybe display fields from fieldset.
137
+ *
138
+ * @param array $fieldset Fieldset.
139
+ * @param WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data $request_data Request data.
140
+ */
141
+ private function maybe_display_fields_from_fieldset( array $fieldset, WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data $request_data ) {
142
+ if ( in_array( 'checkout', $fieldset['show-in'], true ) ) {
143
+ foreach ( $fieldset['fields'] as $field ) {
144
+ if ( 'parcel_collection_points' === $field['type'] ) {
145
+ $this->maybe_display_parcel_collection_points_field( $field, $request_data );
146
+ }
147
+ }
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Maybe display fields on checkout page.
153
+ */
154
+ public function maybe_display_fields_on_checkout_page() {
155
+ $request_data = new WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data( $_REQUEST );
156
+ try {
157
+ $request_fields = $this->shipping_service->get_fields_for_targets( [ $request_data->get_shipping_country() ] );
158
+ foreach ( $request_fields as $fieldset ) {
159
+ $this->maybe_display_fields_from_fieldset( $fieldset, $request_data );
160
+ }
161
+ } catch ( WPDesk_Flexible_Shipping_SaaS_Service_Settings_Not_Found $e ) {
162
+ null;
163
+ }
164
+ }
165
+
166
+ }
classes/saas/checkout-fields/class-saas-checkout-fields-shipment.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Displays additional shipping checkout fields for shipment.
5
+ *
6
+ * Class WPDesk_Flexible_Shipping_SaaS_Shipping_Checkout_Fields_Shipment
7
+ */
8
+ class WPDesk_Flexible_Shipping_SaaS_Shipping_Checkout_Fields_Shipment {
9
+
10
+ /**
11
+ * Shipping service.
12
+ *
13
+ * @var WPDesk_Flexible_Shipping_SaaS_Shipping_Service
14
+ */
15
+ private $shipping_service;
16
+
17
+ /**
18
+ * Service collection points.
19
+ *
20
+ * @var WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points
21
+ */
22
+ private $service_collection_points;
23
+
24
+ /**
25
+ * Renderer.
26
+ *
27
+ * @var WPDesk\View\Renderer\Renderer;
28
+ */
29
+ private $renderer;
30
+
31
+ /**
32
+ * Template folder.
33
+ *
34
+ * @var string;
35
+ */
36
+ private $folder;
37
+
38
+ /**
39
+ * WPDesk_Flexible_Shipping_SaaS_Shipping_Checkout_Fields_Checkout constructor.
40
+ *
41
+ * @param WPDesk_Flexible_Shipping_SaaS_Shipping_Service $shipping_service Shipping service.
42
+ * @param WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points $service_collection_points Service collection points.
43
+ * @param \WPDesk\View\Renderer\Renderer $renderer Renderer.
44
+ * @param string $folder Template folder.
45
+ */
46
+ public function __construct(
47
+ WPDesk_Flexible_Shipping_SaaS_Shipping_Service $shipping_service,
48
+ WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points $service_collection_points,
49
+ WPDesk\View\Renderer\Renderer $renderer,
50
+ $folder
51
+ ) {
52
+ $this->shipping_service = $shipping_service;
53
+ $this->service_collection_points = $service_collection_points;
54
+ $this->renderer = $renderer;
55
+ $this->folder = $folder;
56
+ }
57
+
58
+ /**
59
+ * Display access point.
60
+ *
61
+ * @param WPDesk_Flexible_Shipping_Shipment_Saas $shipment Shipment.
62
+ * @param array $field Field.
63
+ */
64
+ private function display_access_point( WPDesk_Flexible_Shipping_Shipment_Saas $shipment, $field ) {
65
+ $access_point = new WPDesk_Flexible_Shipping_SaaS_Checkout_Field_Collection_Points(
66
+ $this->shipping_service,
67
+ $this->service_collection_points,
68
+ $this->renderer,
69
+ null,
70
+ $field
71
+ );
72
+ $access_point->display_collection_point_field_for_shipment( $this->folder, $shipment );
73
+ }
74
+
75
+ /**
76
+ * Maybe display parcel collection points field.
77
+ *
78
+ * @param array $field Field.
79
+ * @param WPDesk_Flexible_Shipping_Shipment_Saas $shipment Shipment.
80
+ */
81
+ private function maybe_display_parcel_collection_points_field( array $field, WPDesk_Flexible_Shipping_Shipment_Saas $shipment ) {
82
+ $visible_when = WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When_Shipment::create_for_field( $field, $shipment );
83
+ if ( $visible_when->is_visible() ) {
84
+ $this->display_access_point( $shipment, $field );
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Maybe display fields from fieldset for shipment.
90
+ *
91
+ * @param array $fieldset Fieldset.
92
+ * @param WPDesk_Flexible_Shipping_Shipment_Saas $shipment Shipment.
93
+ */
94
+ private function maybe_display_fields_from_fieldset_for_shipment(
95
+ array $fieldset,
96
+ WPDesk_Flexible_Shipping_Shipment_Saas $shipment
97
+ ) {
98
+ if ( in_array( 'checkout', $fieldset['show-in'], true ) ) {
99
+ foreach ( $fieldset['fields'] as $field ) {
100
+ if ( 'parcel_collection_points' === $field['type'] ) {
101
+ $this->maybe_display_parcel_collection_points_field( $field, $shipment );
102
+ }
103
+ }
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Maybe display fields for shipment.
109
+ *
110
+ * @param WPDesk_Flexible_Shipping_Shipment_Saas $shipment Shipment.
111
+ */
112
+ public function maybe_display_fields_for_shipment( WPDesk_Flexible_Shipping_Shipment_Saas $shipment ) {
113
+ try {
114
+ $request_fields = $this->shipping_service->get_fields_for_targets( [ $shipment->get_order()->get_shipping_country() ] );
115
+ foreach ( $request_fields as $fieldset ) {
116
+ $this->maybe_display_fields_from_fieldset_for_shipment( $fieldset, $shipment );
117
+ }
118
+ } catch ( WPDesk_Flexible_Shipping_SaaS_Service_Settings_Not_Found $e ) {
119
+ null;
120
+ }
121
+ }
122
+
123
+ }
classes/saas/checkout-fields/class-saas-field-visible-when-checkout.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Handles conditional logic in checkout.
5
+ *
6
+ * Class WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When_Checkout
7
+ */
8
+ class WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When_Checkout extends WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When {
9
+
10
+ /**
11
+ * Cart shipping rate.
12
+ *
13
+ * @var array
14
+ */
15
+ private $cart_shipping_rate;
16
+
17
+ /**
18
+ * WPDesk_Flexible_Shipping_SaaS_Shipping_Checkout_Field_Visible_When constructor.
19
+ *
20
+ * @param array $visible_when_conditions Conditions.
21
+ * @param WC_Shipping_Rate $cart_shipping_rate Cart shipping rate.
22
+ */
23
+ public function __construct( array $visible_when_conditions, $cart_shipping_rate ) {
24
+ parent::__construct( $visible_when_conditions );
25
+ $this->cart_shipping_rate = $cart_shipping_rate;
26
+ }
27
+
28
+ /**
29
+ * Create for field.
30
+ *
31
+ * @param array $field Field.
32
+ * @param WC_Shipping_Rate $cart_shipping_rate Cart shipping rate.
33
+ *
34
+ * @return WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When_Checkout
35
+ */
36
+ public static function create_for_field( array $field, WC_Shipping_Rate $cart_shipping_rate ) {
37
+ $visible_when_conditions = array();
38
+ if ( isset( $field['visible-when'] ) ) {
39
+ $visible_when_conditions = $field['visible-when'];
40
+ }
41
+ return new self( $visible_when_conditions, $cart_shipping_rate );
42
+ }
43
+
44
+ /**
45
+ * Get service type from shipping rate.
46
+ *
47
+ * @return string
48
+ */
49
+ private function get_service_type_from_cart_shipping_rate() {
50
+ $meta_data = $this->cart_shipping_rate->get_meta_data();
51
+ $fs_saas_data = array();
52
+ if ( isset( $meta_data['_fs_saas_data'] ) ) {
53
+ $fs_saas_data = $meta_data['_fs_saas_data'];
54
+ }
55
+ $service_type = '';
56
+ if ( isset( $fs_saas_data['_fs_service_type'] ) ) {
57
+ $service_type = $fs_saas_data['_fs_service_type'];
58
+ }
59
+ return $service_type;
60
+ }
61
+
62
+ /**
63
+ * Get service type.
64
+ *
65
+ * @return string
66
+ */
67
+ protected function get_service_type() {
68
+ return $this->get_service_type_from_cart_shipping_rate();
69
+ }
70
+
71
+ }
classes/saas/checkout-fields/class-saas-field-visible-when-shipment.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Handles conditional logic for shipment.
5
+ *
6
+ * Class WPDesk_Flexible_Shipping_SaaS_Shipping_Shipment_Field_Visible_When
7
+ */
8
+ class WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When_Shipment extends WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When {
9
+
10
+ /**
11
+ * Shipment.
12
+ *
13
+ * @var WPDesk_Flexible_Shipping_Shipment
14
+ */
15
+ private $shipment;
16
+
17
+ /**
18
+ * WPDesk_Flexible_Shipping_SaaS_Shipping_Shipment_Field_Visible_When constructor.
19
+ *
20
+ * @param array $visible_when_conditions Conditions.
21
+ * @param WPDesk_Flexible_Shipping_Shipment $shipment Shipment.
22
+ */
23
+ public function __construct( array $visible_when_conditions, WPDesk_Flexible_Shipping_Shipment $shipment ) {
24
+ parent::__construct( $visible_when_conditions );
25
+ $this->shipment = $shipment;
26
+ }
27
+
28
+ /**
29
+ * Create for field.
30
+ *
31
+ * @param array $field Field.
32
+ * @param WPDesk_Flexible_Shipping_Shipment $shipment Shipment.
33
+ *
34
+ * @return WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When_Shipment
35
+ */
36
+ public static function create_for_field( array $field, WPDesk_Flexible_Shipping_Shipment $shipment ) {
37
+ $visible_when_conditions = array();
38
+ if ( isset( $field['visible-when'] ) ) {
39
+ $visible_when_conditions = $field['visible-when'];
40
+ }
41
+ return new self( $visible_when_conditions, $shipment );
42
+ }
43
+
44
+ /**
45
+ * Get service type from shipping rate.
46
+ *
47
+ * @return string
48
+ */
49
+ private function get_service_type_from_shipment() {
50
+ $service_type = $this->shipment->get_meta( 'service_type', '' );
51
+ return $service_type;
52
+ }
53
+
54
+ /**
55
+ * Get service type.
56
+ *
57
+ * @return string
58
+ */
59
+ protected function get_service_type() {
60
+ return $this->get_service_type_from_shipment();
61
+ }
62
+
63
+ }
classes/saas/checkout-fields/class-saas-field-visible-when.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Handles conditional logic.
5
+ *
6
+ * Class WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When
7
+ */
8
+ abstract class WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When {
9
+
10
+ /**
11
+ * Conditions.
12
+ *
13
+ * @var array
14
+ */
15
+ private $visible_when_conditions;
16
+
17
+ /**
18
+ * WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When constructor.
19
+ *
20
+ * @param array $visible_when_conditions Conditions.
21
+ */
22
+ public function __construct( array $visible_when_conditions ) {
23
+ $this->visible_when_conditions = $visible_when_conditions;
24
+ }
25
+
26
+ /**
27
+ * Get service type.
28
+ *
29
+ * @return string
30
+ */
31
+ abstract protected function get_service_type();
32
+
33
+ /**
34
+ * Is condition meet?
35
+ *
36
+ * @param array $condition Condition.
37
+ *
38
+ * @return bool
39
+ */
40
+ private function is_condition_meet( array $condition ) {
41
+ $is_condition_meet = false;
42
+
43
+ $field = $condition['field'];
44
+ $cond = $condition['cond'];
45
+ $values = $condition['values'];
46
+
47
+ $field_value = '';
48
+ if ( 'service_type' === $field ) {
49
+ $field_value = $this->get_service_type();
50
+ }
51
+ if ( 'in' === $cond ) {
52
+ $is_condition_meet = in_array( $field_value, $values, true );
53
+ }
54
+ return $is_condition_meet;
55
+ }
56
+
57
+ /**
58
+ * Is visible?
59
+ *
60
+ * @return bool
61
+ */
62
+ public function is_visible() {
63
+ $is_visible = true;
64
+ foreach ( $this->visible_when_conditions as $condition ) {
65
+ $is_visible = $is_visible && $this->is_condition_meet( $condition );
66
+ }
67
+ return $is_visible;
68
+ }
69
+
70
+ }
classes/saas/class-saas-free-shipping-metadata-handler.php CHANGED
@@ -26,7 +26,7 @@ class WPDesk_Flexible_Shipping_SaaS_Free_Shipping_Metadata_Handler implements \
26
  *
27
  * @return string
28
  */
29
- public function add_free_shipping_to_shipping_method_name( $names, WC_Order $order ) {
30
  $names = array();
31
  foreach ( $order->get_shipping_methods() as $shipping_method ) {
32
  $name = $shipping_method->get_name();
26
  *
27
  * @return string
28
  */
29
+ public function add_free_shipping_to_shipping_method_name( $names, $order ) {
30
  $names = array();
31
  foreach ( $order->get_shipping_methods() as $shipping_method ) {
32
  $name = $shipping_method->get_name();
classes/saas/class-saas-live-rates-fallback-metadata-handler.php CHANGED
@@ -22,12 +22,12 @@ class WPDesk_Flexible_Shipping_SaaS_Live_Rates_Fallback_Metadata_Handler impleme
22
  /**
23
  * Add fallback to shipping method name.
24
  *
25
- * @param string $names Names.
26
- * @param WC_Order $order Order.
27
  *
28
  * @return string
29
  */
30
- public function add_fallback_to_shipping_method_name( $names, WC_Order $order ) {
31
  $names = array();
32
  foreach ( $order->get_shipping_methods() as $shipping_method ) {
33
  $name = $shipping_method->get_name();
22
  /**
23
  * Add fallback to shipping method name.
24
  *
25
+ * @param string $names Names.
26
+ * @param WC_Abstract_Order $order Order.
27
  *
28
  * @return string
29
  */
30
+ public function add_fallback_to_shipping_method_name( $names, $order ) {
31
  $names = array();
32
  foreach ( $order->get_shipping_methods() as $shipping_method ) {
33
  $name = $shipping_method->get_name();
classes/saas/class-saas-live-rates-handler.php CHANGED
@@ -138,6 +138,7 @@ class WPDesk_Flexible_Shipping_SaaS_Live_Rates_Handler {
138
  $ship_to->setName( 'first last' );
139
  $ship_to->setCompanyName( '' );
140
  $ship_to->setPhoneNumber( '' );
 
141
  return $ship_to;
142
  }
143
 
@@ -213,6 +214,23 @@ class WPDesk_Flexible_Shipping_SaaS_Live_Rates_Handler {
213
  return $field_value;
214
  }
215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  /**
217
  * Prepare rate request additional fields.
218
  *
@@ -226,7 +244,11 @@ class WPDesk_Flexible_Shipping_SaaS_Live_Rates_Handler {
226
  foreach ( $fields as $fieldset ) {
227
  foreach ( $fieldset['fields'] as $field ) {
228
  if ( isset( $field['send-with'] ) && in_array( 'rate', $field['send-with'], true ) ) {
229
- $field_value = $this->get_shipping_method_setting_for_field( $field, $shipping_method );
 
 
 
 
230
  if ( isset( $field['send-as'] ) ) {
231
  $this->prepare_shipment_field_from_send_as( $field, $field['send-as'], $rate_request, $field_value );
232
  } else {
@@ -259,6 +281,7 @@ class WPDesk_Flexible_Shipping_SaaS_Live_Rates_Handler {
259
  $length = $this->get_int_element_from_array( $shipping_method, $this->integration_id . '_length' );
260
  $rate_request->setPackages( $this->prepare_packages( $package, $package_type, $description, $weight, $height, $width, $length ) );
261
 
 
262
  $destination_country = $package['destination']['country'];
263
  $fields = $this->shipping_service->get_fields_for_targets( array( $destination_country ) );
264
  $rate_request = $this->prepare_rate_request_additional_fields( $rate_request, $fields, $shipping_method );
@@ -564,7 +587,7 @@ class WPDesk_Flexible_Shipping_SaaS_Live_Rates_Handler {
564
  * @param WC_Shipping_Method $shipping_method Shipping method.
565
  * @return WC_Shipping_Rate
566
  */
567
- public function add_fallback_metadata_to_rate( WC_Shipping_Rate $rate, array $args, WC_Shipping_Method $shipping_method ) {
568
  remove_filter( 'woocommerce_shipping_method_add_rate', [ $this, 'add_fallback_metadata_to_rate' ], 10, 3 );
569
  $rate->add_meta_data( '_fs_fallback', $this->fallback_error_message );
570
  $rate->add_meta_data( self::FS_RATE_TYPE, self::RATE_TYPE_LIVE );
@@ -579,7 +602,7 @@ class WPDesk_Flexible_Shipping_SaaS_Live_Rates_Handler {
579
  * @param WC_Shipping_Method $shipping_method Shipping method.
580
  * @return WC_Shipping_Rate
581
  */
582
- public function add_free_shipping_metadata_to_rate( WC_Shipping_Rate $rate, array $args, WC_Shipping_Method $shipping_method ) {
583
  remove_filter( 'woocommerce_shipping_method_add_rate', [ $this, 'add_free_shipping_metadata_to_rate' ], 10, 3 );
584
  $rate->add_meta_data( '_fs_free_shipping', 'Free shipping' );
585
  $rate->add_meta_data( self::FS_RATE_TYPE, self::RATE_TYPE_LIVE );
138
  $ship_to->setName( 'first last' );
139
  $ship_to->setCompanyName( '' );
140
  $ship_to->setPhoneNumber( '' );
141
+ $ship_to->setEmail( '' );
142
  return $ship_to;
143
  }
144
 
214
  return $field_value;
215
  }
216
 
217
+ /**
218
+ * Get checkout value for field.
219
+ *
220
+ * @param array $field Field.
221
+ *
222
+ * @return string
223
+ */
224
+ private function get_checkout_value_for_field( array $field ) {
225
+ $field_name = $field['id'] . '_' . $this->shipping_service->get_integration_id();
226
+ $request_data = new WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data( $_REQUEST );
227
+ $field_value = $request_data->get_data_by_name( $field_name );
228
+ if ( empty( $field_value ) ) {
229
+ $field_value = null;
230
+ }
231
+ return $field_value;
232
+ }
233
+
234
  /**
235
  * Prepare rate request additional fields.
236
  *
244
  foreach ( $fields as $fieldset ) {
245
  foreach ( $fieldset['fields'] as $field ) {
246
  if ( isset( $field['send-with'] ) && in_array( 'rate', $field['send-with'], true ) ) {
247
+ if ( in_array( 'checkout', $fieldset['show-in'], true ) ) {
248
+ $field_value = $this->get_checkout_value_for_field( $field );
249
+ } else {
250
+ $field_value = $this->get_shipping_method_setting_for_field( $field, $shipping_method );
251
+ }
252
  if ( isset( $field['send-as'] ) ) {
253
  $this->prepare_shipment_field_from_send_as( $field, $field['send-as'], $rate_request, $field_value );
254
  } else {
281
  $length = $this->get_int_element_from_array( $shipping_method, $this->integration_id . '_length' );
282
  $rate_request->setPackages( $this->prepare_packages( $package, $package_type, $description, $weight, $height, $width, $length ) );
283
 
284
+
285
  $destination_country = $package['destination']['country'];
286
  $fields = $this->shipping_service->get_fields_for_targets( array( $destination_country ) );
287
  $rate_request = $this->prepare_rate_request_additional_fields( $rate_request, $fields, $shipping_method );
587
  * @param WC_Shipping_Method $shipping_method Shipping method.
588
  * @return WC_Shipping_Rate
589
  */
590
+ public function add_fallback_metadata_to_rate( $rate, array $args, $shipping_method ) {
591
  remove_filter( 'woocommerce_shipping_method_add_rate', [ $this, 'add_fallback_metadata_to_rate' ], 10, 3 );
592
  $rate->add_meta_data( '_fs_fallback', $this->fallback_error_message );
593
  $rate->add_meta_data( self::FS_RATE_TYPE, self::RATE_TYPE_LIVE );
602
  * @param WC_Shipping_Method $shipping_method Shipping method.
603
  * @return WC_Shipping_Rate
604
  */
605
+ public function add_free_shipping_metadata_to_rate( $rate, array $args, $shipping_method ) {
606
  remove_filter( 'woocommerce_shipping_method_add_rate', [ $this, 'add_free_shipping_metadata_to_rate' ], 10, 3 );
607
  $rate->add_meta_data( '_fs_free_shipping', 'Free shipping' );
608
  $rate->add_meta_data( self::FS_RATE_TYPE, self::RATE_TYPE_LIVE );
classes/saas/class-saas-shipping-service.php CHANGED
@@ -118,6 +118,13 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping_SaaS_Shipping_Service' ) ) {
118
  */
119
  private $integration_id;
120
 
 
 
 
 
 
 
 
121
  /**
122
  * WPDesk_Flexible_Shipping_SaaS_Shipping_Service constructor.
123
  *
@@ -759,6 +766,24 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping_SaaS_Shipping_Service' ) ) {
759
  );
760
  }
761
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
762
  }
763
 
764
  }
118
  */
119
  private $integration_id;
120
 
121
+ /**
122
+ * Collection points.
123
+ *
124
+ * @var WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points
125
+ */
126
+ private $collection_points;
127
+
128
  /**
129
  * WPDesk_Flexible_Shipping_SaaS_Shipping_Service constructor.
130
  *
766
  );
767
  }
768
 
769
+ /**
770
+ * Get collection points.
771
+ *
772
+ * @return WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points
773
+ */
774
+ public function get_collection_points() {
775
+ return $this->collection_points;
776
+ }
777
+
778
+ /**
779
+ * Set collection points.
780
+ *
781
+ * @param WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points $collection_points Collection points.
782
+ */
783
+ public function set_collection_points( $collection_points ) {
784
+ $this->collection_points = $collection_points;
785
+ }
786
+
787
  }
788
 
789
  }
classes/saas/class-saas-shipping-services-manager.php CHANGED
@@ -6,10 +6,11 @@
6
  use WPDesk\ABTesting\ABVariant;
7
 
8
  class WPDesk_Flexible_Shipping_SaaS_Services_Manager
9
- implements \WPDesk\PluginBuilder\Plugin\HookablePluginDependant
10
  {
11
 
12
  use \WPDesk\PluginBuilder\Plugin\PluginAccess;
 
13
 
14
  const OPTION_ALL_SHIPPING_SERVICES = 'fs_saas_all_shipping_servicess';
15
  const OPTION_ENABLED_SHIPPING_SERVICES = 'fs_saas_enabled_shipping_services';
@@ -64,6 +65,13 @@ class WPDesk_Flexible_Shipping_SaaS_Services_Manager
64
  */
65
  private $saas_platform_links;
66
 
 
 
 
 
 
 
 
67
  /**
68
  * Logger.
69
  *
@@ -83,16 +91,20 @@ class WPDesk_Flexible_Shipping_SaaS_Services_Manager
83
  *
84
  * @param WPDesk_Flexible_Shipping_SaaS_Connection $saas_connection Connection.
85
  * @param WPDesk_Flexible_Shipping_SaaS_Platform_Links $saas_platform_links Links.
 
 
86
  * @param \Psr\Log\LoggerInterface $logger Logger.
87
  */
88
  public function __construct(
89
  WPDesk_Flexible_Shipping_SaaS_Connection $saas_connection,
90
  WPDesk_Flexible_Shipping_SaaS_Platform_Links $saas_platform_links,
91
- \Psr\Log\LoggerInterface $logger = null,
92
- ABVariant $variant
 
93
  ) {
94
  $this->variant = $variant;
95
  $this->saas_connection = $saas_connection;
 
96
  if ( null !== $logger ) {
97
  $this->logger = $logger;
98
  } else {
@@ -130,6 +142,8 @@ class WPDesk_Flexible_Shipping_SaaS_Services_Manager
130
 
131
  add_filter( 'flexible_shipping_shipment_class', array( $this, 'flexible_shipping_shipment_class' ), 10, 2 );
132
 
 
 
133
  }
134
 
135
  /**
@@ -252,7 +266,7 @@ class WPDesk_Flexible_Shipping_SaaS_Services_Manager
252
  $shipping_service_data['promoted'] = false;
253
  }
254
 
255
- return new WPDesk_Flexible_Shipping_SaaS_Shipping_Service(
256
  $this->saas_connection,
257
  $this->saas_platform_links,
258
  $shipping_service_data['id'],
@@ -264,6 +278,8 @@ class WPDesk_Flexible_Shipping_SaaS_Services_Manager
264
  $shipping_service_data['request_fields'],
265
  $shipping_service_data['capabilities']
266
  );
 
 
267
  }
268
 
269
  /**
@@ -292,6 +308,21 @@ class WPDesk_Flexible_Shipping_SaaS_Services_Manager
292
  if ( $shipping_service->supports( 'requireUKStates' ) ) {
293
  $this->require_uk_states = true;
294
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  }
296
  }
297
  } catch ( Exception $e ) {
6
  use WPDesk\ABTesting\ABVariant;
7
 
8
  class WPDesk_Flexible_Shipping_SaaS_Services_Manager
9
+ implements \WPDesk\PluginBuilder\Plugin\HookablePluginDependant, \WPDesk\PluginBuilder\Plugin\HookableCollection
10
  {
11
 
12
  use \WPDesk\PluginBuilder\Plugin\PluginAccess;
13
+ use \WPDesk\PluginBuilder\Plugin\HookableParent;
14
 
15
  const OPTION_ALL_SHIPPING_SERVICES = 'fs_saas_all_shipping_servicess';
16
  const OPTION_ENABLED_SHIPPING_SERVICES = 'fs_saas_enabled_shipping_services';
65
  */
66
  private $saas_platform_links;
67
 
68
+ /**
69
+ * Renderer.
70
+ *
71
+ * @var WPDesk\View\Renderer\Renderer;
72
+ */
73
+ private $renderer;
74
+
75
  /**
76
  * Logger.
77
  *
91
  *
92
  * @param WPDesk_Flexible_Shipping_SaaS_Connection $saas_connection Connection.
93
  * @param WPDesk_Flexible_Shipping_SaaS_Platform_Links $saas_platform_links Links.
94
+ * @param WPDesk\View\Renderer\Renderer $renderer Renderer.
95
+ * @param ABVariant $variant AB tests variant.
96
  * @param \Psr\Log\LoggerInterface $logger Logger.
97
  */
98
  public function __construct(
99
  WPDesk_Flexible_Shipping_SaaS_Connection $saas_connection,
100
  WPDesk_Flexible_Shipping_SaaS_Platform_Links $saas_platform_links,
101
+ WPDesk\View\Renderer\Renderer $renderer,
102
+ ABVariant $variant,
103
+ \Psr\Log\LoggerInterface $logger = null
104
  ) {
105
  $this->variant = $variant;
106
  $this->saas_connection = $saas_connection;
107
+ $this->renderer = $renderer;
108
  if ( null !== $logger ) {
109
  $this->logger = $logger;
110
  } else {
142
 
143
  add_filter( 'flexible_shipping_shipment_class', array( $this, 'flexible_shipping_shipment_class' ), 10, 2 );
144
 
145
+ $this->hooks_on_hookable_objects();
146
+
147
  }
148
 
149
  /**
266
  $shipping_service_data['promoted'] = false;
267
  }
268
 
269
+ $shipping_service = new WPDesk_Flexible_Shipping_SaaS_Shipping_Service(
270
  $this->saas_connection,
271
  $this->saas_platform_links,
272
  $shipping_service_data['id'],
278
  $shipping_service_data['request_fields'],
279
  $shipping_service_data['capabilities']
280
  );
281
+
282
+ return $shipping_service;
283
  }
284
 
285
  /**
308
  if ( $shipping_service->supports( 'requireUKStates' ) ) {
309
  $this->require_uk_states = true;
310
  }
311
+
312
+ $collection_points = new WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points(
313
+ $this->saas_connection,
314
+ $shipping_service
315
+ );
316
+ $this->add_hookable( $collection_points );
317
+ $shipping_service->set_collection_points( $collection_points );
318
+
319
+ $checkout_fields = new WPDesk_Flexible_Shipping_SaaS_Shipping_Checkout_Fields_Checkout(
320
+ $shipping_service,
321
+ $collection_points,
322
+ $this->renderer
323
+ );
324
+ $this->add_hookable( $checkout_fields );
325
+
326
  }
327
  }
328
  } catch ( Exception $e ) {
classes/saas/collection-points/class-saas-collection-points-ajax-request-data.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Loads map with collection points.
5
+ *
6
+ * WPDesk_Flexible_Shipping_SaaS_Collection_Points_Ajax_Request_Data
7
+ */
8
+ class WPDesk_Flexible_Shipping_SaaS_Collection_Points_Ajax_Request_Data extends WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data {
9
+
10
+ /**
11
+ * WPDesk_Flexible_Shipping_SaaS_Collection_Points_Ajax_Request_Data.
12
+ *
13
+ * @param array $request Request.
14
+ */
15
+ public function __construct( $request ) {
16
+ parent::__construct( $request );
17
+ $this->post_data = $request;
18
+ }
19
+
20
+
21
+ }
classes/saas/collection-points/class-saas-collection-points-ajax.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Loads map with collection points.
5
+ *
6
+ * WPDesk_Flexible_Shipping_SaaS_Collection_Points_Ajax
7
+ */
8
+ class WPDesk_Flexible_Shipping_SaaS_Collection_Points_Ajax {
9
+
10
+ const STATUS_OK = 'ok';
11
+ const STATUS_ERROR = 'error';
12
+
13
+ /**
14
+ * SaaS connection.
15
+ *
16
+ * @var WPDesk_Flexible_Shipping_SaaS_Connection
17
+ */
18
+ private $saas_connection;
19
+
20
+ /**
21
+ * Shipping service.
22
+ *
23
+ * @var WPDesk_Flexible_Shipping_SaaS_Shipping_Service
24
+ */
25
+ private $shipping_service;
26
+
27
+ const NONCE_ACTION = 'fs_collection_points_map';
28
+
29
+ /**
30
+ * WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points constructor.
31
+ *
32
+ * @param WPDesk_Flexible_Shipping_SaaS_Connection $saas_connection SaaS connection.
33
+ * @param WPDesk_Flexible_Shipping_SaaS_Shipping_Service $shipping_service Shipping service.
34
+ */
35
+ public function __construct(
36
+ WPDesk_Flexible_Shipping_SaaS_Connection $saas_connection,
37
+ WPDesk_Flexible_Shipping_SaaS_Shipping_Service $shipping_service
38
+ ) {
39
+ $this->saas_connection = $saas_connection;
40
+ $this->shipping_service = $shipping_service;
41
+ }
42
+
43
+ /**
44
+ * Handle request.
45
+ *
46
+ * @param WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points $service_collection_points Service collection points.
47
+ * @throws RuntimeException Exception.
48
+ */
49
+ public function handle_request( WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points $service_collection_points ) {
50
+ if ( check_ajax_referer( self::NONCE_ACTION, 'security', false ) ) {
51
+ $response = array(
52
+ 'status' => self::STATUS_OK,
53
+ );
54
+
55
+ $request_data = new WPDesk_Flexible_Shipping_SaaS_Collection_Points_Ajax_Request_Data( $_REQUEST );
56
+
57
+ $address = new \WPDesk\SaasPlatformClient\Model\Shipment\Address();
58
+ $address->setAddressLine1( $request_data->get_shipping_address_1() );
59
+ $address->setAddressLine2( $request_data->get_shipping_address_2() );
60
+ $address->setPostalCode( $request_data->get_shipping_postcode() );
61
+ $address->setCity( $request_data->get_shipping_city() );
62
+ $address->setStateCode( $request_data->get_shipping_state() );
63
+ $address->setCountryCode( $request_data->get_shipping_country() );
64
+ try {
65
+ $collection_points = $service_collection_points->get_nearest_collection_points( $address );
66
+ $response['points'] = $collection_points->getPoints()->points;
67
+ } catch ( Exception $e ) {
68
+ $response = array(
69
+ 'status' => self::STATUS_ERROR,
70
+ 'message' => $e->getMessage(),
71
+ );
72
+ }
73
+ } else {
74
+ $response = array(
75
+ 'status' => self::STATUS_ERROR,
76
+ 'message' => __( 'Invalid nonce!', 'flexible-shipping' ),
77
+ );
78
+ }
79
+ wp_send_json( $response );
80
+ }
81
+ }
classes/saas/collection-points/class-saas-collection-points-map.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Loads map with collection points.
5
+ *
6
+ * WPDesk_Flexible_Shipping_SaaS_Collection_Points_Map_Loader
7
+ */
8
+ class WPDesk_Flexible_Shipping_SaaS_Collection_Points_Map_Loader implements \WPDesk\PluginBuilder\Plugin\HookablePluginDependant {
9
+
10
+ use \WPDesk\PluginBuilder\Plugin\PluginAccess;
11
+
12
+ const URL_MAP_PARAMETER = 'flexible-shipping-collection-point-map';
13
+ const SCRIPT_HANDLE = 'fs_collection_points_map';
14
+
15
+ /**
16
+ * Scripts version.
17
+ *
18
+ * @var string
19
+ */
20
+ private $scripts_version = FLEXIBLE_SHIPPING_VERSION . '.4';
21
+
22
+ /**
23
+ * Hooks.
24
+ */
25
+ public function hooks() {
26
+ add_action( 'init', array( $this, 'maybe_load_map' ) );
27
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
28
+ }
29
+
30
+ /**
31
+ * Admin scripts.
32
+ */
33
+ public function enqueue_scripts() {
34
+ if ( is_checkout() ) {
35
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
36
+ wp_register_script( self::SCRIPT_HANDLE,
37
+ trailingslashit( $this->plugin->get_plugin_assets_url() ) . 'js/collection-points-map' . $suffix . '.js', array( 'jquery' ),
38
+ $this->scripts_version, true
39
+ );
40
+
41
+ wp_localize_script( self::SCRIPT_HANDLE, self::SCRIPT_HANDLE, array(
42
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
43
+ 'collection_points_map_url' => site_url( '?' . self::URL_MAP_PARAMETER ),
44
+ 'loading_image' => $this->plugin->get_plugin_url() .'assets/images/ajax-loading.gif',
45
+ 'marker_icon' => $this->plugin->get_plugin_url() .'assets/images/marker-icon.png',
46
+ 'lang' => array(
47
+ 'no_points' => __( 'Points can not be found. Check the shipping address.', 'flexible-shipping'),
48
+ 'user_location' => __( 'It\'s your location', 'flexible-shipping'),
49
+ ),
50
+ 'ajax_nonce' => wp_create_nonce( WPDesk_Flexible_Shipping_SaaS_Collection_Points_Ajax::NONCE_ACTION )
51
+ ) );
52
+ wp_enqueue_script( self::SCRIPT_HANDLE );
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Maybe load map.
58
+ */
59
+ public function maybe_load_map() {
60
+ if ( isset( $_GET[ self::URL_MAP_PARAMETER ] ) ) {
61
+ include 'views/map.php';
62
+ die();
63
+ }
64
+ }
65
+
66
+ }
classes/saas/collection-points/class-saas-shipping-service-collection-points.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Handles collection points .
5
+ *
6
+ * Class WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points
7
+ */
8
+ class WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points implements \WPDesk\PluginBuilder\Plugin\Hookable {
9
+
10
+ /**
11
+ * SaaS connection.
12
+ *
13
+ * @var WPDesk_Flexible_Shipping_SaaS_Connection
14
+ */
15
+ private $saas_connection;
16
+
17
+ /**
18
+ * Shipping service.
19
+ *
20
+ * @var WPDesk_Flexible_Shipping_SaaS_Shipping_Service
21
+ */
22
+ private $shipping_service;
23
+
24
+ /**
25
+ * WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points constructor.
26
+ *
27
+ * @param WPDesk_Flexible_Shipping_SaaS_Connection $saas_connection SaaS connection.
28
+ * @param WPDesk_Flexible_Shipping_SaaS_Shipping_Service $shipping_service Shipping service.
29
+ */
30
+ public function __construct(
31
+ WPDesk_Flexible_Shipping_SaaS_Connection $saas_connection,
32
+ WPDesk_Flexible_Shipping_SaaS_Shipping_Service $shipping_service
33
+ ) {
34
+ $this->saas_connection = $saas_connection;
35
+ $this->shipping_service = $shipping_service;
36
+ }
37
+
38
+ /**
39
+ * Hooks.
40
+ */
41
+ public function hooks() {
42
+ $ajax_action = 'fs_collection_points_' . $this->shipping_service->get_id();
43
+ add_action( 'wp_ajax_' . $ajax_action, array( $this, 'handle_ajax_get_collection_points' ) );
44
+ add_action( 'wp_ajax_nopriv_' . $ajax_action, array( $this, 'handle_ajax_get_collection_points' ) );
45
+ }
46
+
47
+ /**
48
+ * Handle AJAX.
49
+ */
50
+ public function handle_ajax_get_collection_points() {
51
+ $ajax_handler = new WPDesk_Flexible_Shipping_SaaS_Collection_Points_Ajax( $this->saas_connection, $this->shipping_service );
52
+ $ajax_handler->handle_request( $this );
53
+ }
54
+
55
+ /**
56
+ * Get nearest collection points.
57
+ *
58
+ * @param \WPDesk\SaasPlatformClient\Model\Shipment\Address $address Address.
59
+ * @return \WPDesk\SaasPlatformClient\Response\ParcelCollectionPoints\PostSearchResponse
60
+ */
61
+ public function get_nearest_collection_points( \WPDesk\SaasPlatformClient\Model\Shipment\Address $address ) {
62
+ $platform = $this->saas_connection->get_platform();
63
+ $search_request = new WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints\SearchRequest();
64
+ $search_request->setAddress( $address );
65
+ $search_request->setRadius( 50 );
66
+ return $platform->requestPostSearchParcelCollectionPoints( $search_request, $this->shipping_service->get_id() );
67
+ }
68
+
69
+ /**
70
+ * Prepare collection point options for address.
71
+ *
72
+ * @param \WPDesk\SaasPlatformClient\Model\Shipment\Address $address Address.
73
+ * @return array
74
+ */
75
+ public function prepare_collection_points_options_for_address( \WPDesk\SaasPlatformClient\Model\Shipment\Address $address ) {
76
+ $collection_points = $this->get_nearest_collection_points( $address );
77
+ $collection_points_options = array();
78
+ if ( $collection_points->isCollectionPointError() ) {
79
+ $collection_points_options[''] = __( 'Cannot get data for this address!', 'flexible-shipping' );
80
+ } else {
81
+ foreach ( $collection_points->getPoints()->points as $collection_point ) {
82
+ $label = $collection_point->getName();
83
+ $label .= ', ' . $collection_point->getAddress()->getCity();
84
+ $label .= ' ' . $collection_point->getAddress()->getPostalCode();
85
+ $label .= ', ' . $collection_point->getAddress()->getAddressLine1();
86
+ $label .= ' ' . $collection_point->getAddress()->getAddressLine2();
87
+
88
+ $collection_points_options[ $collection_point->getId() ] = ucwords( strtolower( $label ) );
89
+ }
90
+ }
91
+ return $collection_points_options;
92
+ }
93
+
94
+ /**
95
+ * Get collection point.
96
+ *
97
+ * @param string $collection_point_id Collection point id.
98
+ *
99
+ * @return mixed
100
+ */
101
+ public function get_collection_point( $collection_point_id ) {
102
+ $platform = $this->saas_connection->get_platform();
103
+ $single_request = new WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints\SingleRequest();
104
+ $single_request->setId( $collection_point_id );
105
+ return $platform->requestGetSingleCollectionPoint( $single_request, $this->shipping_service->get_id() );
106
+ }
107
+
108
+ /**
109
+ * Format single point description from response.
110
+ *
111
+ * @param \WPDesk\SaasPlatformClient\Response\ParcelCollectionPoints\GetSingleResponse $response Response.
112
+ *
113
+ * @return string
114
+ */
115
+ public function format_single_point_description_from_response( \WPDesk\SaasPlatformClient\Response\ParcelCollectionPoints\GetSingleResponse $response ) {
116
+ $description = $response->getSingleResponse()->point->getName();
117
+ $description .= ', ' . $response->getSingleResponse()->point->getAddress()->getAddressLine1();
118
+ if ( ! empty( $response->getSingleResponse()->point->getAddress()->getAddressLine2() ) ) {
119
+ $description .= ' ' . $response->getSingleResponse()->point->getAddress()->getAddressLine2();
120
+ }
121
+ $description .= ', ' . $response->getSingleResponse()->point->getAddress()->getPostalCode();
122
+ $description .= ' ' . $response->getSingleResponse()->point->getAddress()->getCity();
123
+ return $description;
124
+ }
125
+
126
+ }
classes/saas/collection-points/views/map.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="pl">
3
+ <head>
4
+ <title><?php _e('Select point', 'flexible-shipping'); ?></title>
5
+ <meta charset="utf-8"/>
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <link rel="stylesheet" href="https://unpkg.com/leaflet@1.4.0/dist/leaflet.css"
8
+ integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
9
+ crossorigin=""/>
10
+ <script src="https://unpkg.com/leaflet@1.4.0/dist/leaflet.js"
11
+ integrity="sha512-QVftwZFqvtRNi0ZyCtsznlKSWOStnDORoefr1enyq5mVL4tmKB3S/EnC3rRJcxCPavG10IcrVGSmPh6Qw5lwrg=="
12
+ crossorigin=""></script>
13
+ <script src="https://code.jquery.com/jquery-3.3.1.min.js"
14
+ integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
15
+ <link href="https://unpkg.com/leaflet-geosearch@latest/assets/css/leaflet.css" rel="stylesheet"/>
16
+ <script src="https://unpkg.com/leaflet-geosearch@latest/dist/bundle.min.js"></script>
17
+ <script>
18
+ var parent = window.opener;
19
+ var ajax_url = parent.fs_collection_points_map.ajax_url;
20
+ var loading_image = parent.fs_collection_points_map.loading_image;
21
+ var marker_icon = parent.fs_collection_points_map.marker_icon;
22
+ var lang = parent.fs_collection_points_map.lang;
23
+
24
+ var OpenStreetMapProvider = window.GeoSearch.OpenStreetMapProvider;
25
+ var provider = new OpenStreetMapProvider();
26
+ var markers = [];
27
+ var selectedMarker = null;
28
+
29
+ $(document).ready(function () {
30
+ var map = L.map('map');
31
+
32
+ var userLocationIcon = L.icon({
33
+ iconUrl: marker_icon,
34
+ iconSize: [25, 41],
35
+ });
36
+ window.opener.postMessage({action: 'get_adresses_data'}, window.location.origin);
37
+ window.addEventListener('message', function (event) {
38
+ if (event.origin === window.location.origin && 'send_address_data' === event.data.action) {
39
+ var ajax_data = event.data.addresses_data;
40
+ provider
41
+ .search({query: get_shipping_address(ajax_data)})
42
+ .then(function (result) {
43
+ if (result[0].y && result[0].x) {
44
+ var userMarker = L.marker([parseFloat(result[0].y), parseFloat(result[0].x)], {title: lang.user_location, icon: userLocationIcon}).addTo(map);
45
+ userMarker.bindPopup( lang.user_location );
46
+ markers.push(userMarker);
47
+ }
48
+ });
49
+
50
+ jQuery('#map').css('background-image', 'url(' + loading_image + ')');
51
+ $.post(ajax_url, ajax_data, function (response) {
52
+ if (response.points && 'ok' === response.status) {
53
+ var points = response.points;
54
+ var group = new L.featureGroup();
55
+ if (map) {
56
+ $('#map').css('background-image', 'none');
57
+ }
58
+ L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
59
+ attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
60
+ }).addTo(map);
61
+ $.each(points, function (i, point) {
62
+ var marker = L.marker([parseFloat(point.mapLocation.lat), parseFloat(point.mapLocation.lng)], {title: point.name});
63
+ marker.bindPopup(popup_point_html(point));
64
+ markers.push(marker);
65
+ if (point.id === event.data.addresses_data.selected_point) {
66
+ selectedMarker = marker;
67
+ }
68
+ });
69
+ var group = L.featureGroup(markers).addTo(map);
70
+ map.fitBounds(group.getBounds());
71
+ if (null !== selectedMarker) {
72
+ selectedMarker.fireEvent('click');
73
+ }
74
+ } else if ('error' === response.status) {
75
+ alert(response.message);
76
+ window.close();
77
+ } else {
78
+ alert(lang.no_points);
79
+ window.close();
80
+ }
81
+ });
82
+ }
83
+ }, true);
84
+ });
85
+
86
+ function get_shipping_address(data) {
87
+ var address, city, postcode;
88
+ if (data.different_addres === true) {
89
+ address = data.shipping_address_1;
90
+ city = data.shipping_city;
91
+ postcode = data.shipping_postcode;
92
+ } else {
93
+ address = data.billing_address_1;
94
+ city = data.billing_city;
95
+ postcode = data.billing_postcode;
96
+ }
97
+ var new_address = address.split('/');
98
+ if( new_address[0] ) {
99
+ address = new_address[0];
100
+ }
101
+ return address + ', ' + postcode + ', ' + city;
102
+ }
103
+
104
+ function popup_point_html(point) {
105
+ if (point.address.addressLine2 === null) {
106
+ point.address.addressLine2 = '';
107
+ } else {
108
+ point.address.addressLine2 = '<br/>' + point.address.addressLine2;
109
+ }
110
+ var output = '<div class="point-popup">';
111
+ output += '<h4>' + point.name + '</h4>';
112
+ output += '<p>' + point.address.addressLine1 + point.address.addressLine2 + '</p>';
113
+ output += '<p>' + point.address.postalCode + '</p>';
114
+ output += '<p>' + point.address.city + '</p>';
115
+ output += '<p>' + point.description + '</p>';
116
+ output += '<p class="submit-button"><a href="javascript:select_point( \'' + point.id + '\' )"><?php _e('Select', 'flexible-shipping'); ?></a></p>';
117
+ output += '</div>';
118
+ return output;
119
+ }
120
+
121
+ function select_point(id) {
122
+ window.opener.postMessage({action: 'select_point', point_id: id}, window.location.origin);
123
+ window.close();
124
+ }
125
+ </script>
126
+ <style>
127
+ html, body {
128
+ height: 100%;
129
+ margin: 0;
130
+ }
131
+
132
+ #map {
133
+ width: 100%;
134
+ height: 100%;
135
+ background-color: #EEE;
136
+ background-repeat: no-repeat;
137
+ background-position: center;
138
+ }
139
+
140
+ .leaflet-popup-content-wrapper {
141
+ border-radius: 2px;
142
+ }
143
+
144
+ .point-popup p {
145
+ margin: 0 0 5px;
146
+ padding: 0 0;
147
+ }
148
+
149
+ .submit-button a {
150
+ display: inline-block;
151
+ text-decoration: none;
152
+ font-size: 13px;
153
+ line-height: 26px;
154
+ height: 28px;
155
+ margin: 0;
156
+ padding: 0 10px 1px;
157
+ cursor: pointer;
158
+ border-width: 1px;
159
+ border-style: solid;
160
+ -webkit-appearance: none;
161
+ border-radius: 3px;
162
+ white-space: nowrap;
163
+ box-sizing: border-box;
164
+ background: #0085ba;
165
+ border-color: #0073aa #006799 #006799;
166
+ box-shadow: 0 1px 0 #006799;
167
+ color: #fff;
168
+ }
169
+ </style>
170
+ </head>
171
+ <body>
172
+ <div id='map'></div>
173
+ </body>
174
+ </html>
classes/shipment/class-shipment-request-fields.php CHANGED
@@ -73,6 +73,20 @@ class WPDesk_Flexible_Shipping_Shipment_Request_Fields {
73
  }
74
  }
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  /**
77
  * Prepare shipment field.
78
  *
@@ -83,6 +97,7 @@ class WPDesk_Flexible_Shipping_Shipment_Request_Fields {
83
  && ( in_array( 'shipment', $field['send-with'], true )
84
  || in_array( 'label', $field['send-with'], true ) )
85
  && ! in_array( 'package', $field['send-with'], true )
 
86
  ) {
87
  if ( isset( $field['send-as'] ) ) {
88
  $this->prepare_shipment_field_from_send_as( $field, $field['send-as'], $this->shipment_request );
73
  }
74
  }
75
 
76
+ /**
77
+ * Is visible condition meet.
78
+ *
79
+ * @param array $field Field.
80
+ * @return bool
81
+ */
82
+ private function is_visible_condition_meet( array $field ) {
83
+ if ( isset( $field['visible-when'] ) ) {
84
+ $visible_when = WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When_Shipment::create_for_field( $field, $this->shipment );
85
+ return $visible_when->is_visible();
86
+ }
87
+ return true;
88
+ }
89
+
90
  /**
91
  * Prepare shipment field.
92
  *
97
  && ( in_array( 'shipment', $field['send-with'], true )
98
  || in_array( 'label', $field['send-with'], true ) )
99
  && ! in_array( 'package', $field['send-with'], true )
100
+ && $this->is_visible_condition_meet( $field )
101
  ) {
102
  if ( isset( $field['send-as'] ) ) {
103
  $this->prepare_shipment_field_from_send_as( $field, $field['send-as'], $this->shipment_request );
classes/shipment/class-shipment.php CHANGED
@@ -83,24 +83,25 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping_Shipment' ) ) {
83
  */
84
  private $order_metabox_context = 'side';
85
 
86
- /**
87
- * WPDesk_Flexible_Shipping_Shipment constructor.
88
- * @param $shipment
89
- * @param WC_Order|null $order
90
- */
91
- public function __construct( $shipment, WC_Order $order = null ) {
92
- if ( is_numeric( $shipment ) ) {
93
- $this->id = absint( $shipment );
94
- $this->post = get_post( $this->id );
95
- } elseif ( $shipment instanceof WPDesk_Flexible_Shipping_Shipment ) {
96
- $this->id = absint( $shipment->get_id() );
97
- $this->post = $shipment->get_post();
98
- } elseif ( isset( $shipment->ID ) ) {
99
- $this->id = absint( $shipment->ID );
100
- $this->post = $shipment;
101
- }
102
- $this->order = $order;
103
- }
 
104
 
105
  /**
106
  * @return mixed
83
  */
84
  private $order_metabox_context = 'side';
85
 
86
+ /**
87
+ * WPDesk_Flexible_Shipping_Shipment constructor.
88
+ *
89
+ * @param int|WP_Post|WPDesk_Flexible_Shipping_Shipment $shipment Shipment or shipment ID.
90
+ * @param WC_Order|null $order Order.
91
+ */
92
+ public function __construct( $shipment, $order = null ) {
93
+ if ( is_numeric( $shipment ) ) {
94
+ $this->id = absint( $shipment );
95
+ $this->post = get_post( $this->id );
96
+ } elseif ( $shipment instanceof WPDesk_Flexible_Shipping_Shipment ) {
97
+ $this->id = absint( $shipment->get_id() );
98
+ $this->post = $shipment->get_post();
99
+ } elseif ( isset( $shipment->ID ) ) {
100
+ $this->id = absint( $shipment->ID );
101
+ $this->post = $shipment;
102
+ }
103
+ $this->order = $order;
104
+ }
105
 
106
  /**
107
  * @return mixed
classes/shipment/cpt-shipment.php CHANGED
@@ -210,7 +210,7 @@ class WPDesk_Flexible_Shipping_Shipment_CPT {
210
  *
211
  * @return array
212
  */
213
- private function get_fs_method_from_order_shipping_method( WC_Order_Item_Shipping $shipping_method ) {
214
  $fs_method = array();
215
  if ( version_compare( WC_VERSION, '2.6', '<' ) ) {
216
  if ( isset( $shipping_method['item_meta'] )
@@ -307,7 +307,12 @@ class WPDesk_Flexible_Shipping_Shipment_CPT {
307
  }
308
  }
309
 
310
- public function woocommerce_order_details_after_order_table( WC_Order $order ) {
 
 
 
 
 
311
  if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
312
  $order_id = $order->id;
313
  }
210
  *
211
  * @return array
212
  */
213
+ private function get_fs_method_from_order_shipping_method( $shipping_method ) {
214
  $fs_method = array();
215
  if ( version_compare( WC_VERSION, '2.6', '<' ) ) {
216
  if ( isset( $shipping_method['item_meta'] )
307
  }
308
  }
309
 
310
+ /**
311
+ * Hook woocommerce_order_details_after_order_table.
312
+ *
313
+ * @param WC_Abstract_Order $order Order.
314
+ */
315
+ public function woocommerce_order_details_after_order_table( $order ) {
316
  if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
317
  $order_id = $order->id;
318
  }
classes/shipment/functions.php CHANGED
@@ -11,8 +11,13 @@ function fs_shipment_integration_exists( $integration ) {
11
  return false;
12
  }
13
 
14
-
15
- function fs_create_shipment( WC_Order $order, $fs_method ) {
 
 
 
 
 
16
  if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
17
  $order_id = $order->id;
18
  }
@@ -64,11 +69,13 @@ function fs_get_order_shipments( $order_id, $integration = null ) {
64
  }
65
 
66
  /**
67
- * @param $shipment_id
68
- * @param WC_Order|null $order
 
 
69
  * @return WPDesk_Flexible_Shipping_Shipment
70
  */
71
- function fs_get_shipment( $shipment_id, WC_Order $order = null ) {
72
  $integration = get_post_meta( $shipment_id, '_integration', true );
73
  $class_name = 'WPDesk_Flexible_Shipping_Shipment';
74
  $integration_class_name = 'WPDesk_Flexible_Shipping_Shipment' . '_' . $integration;
@@ -79,8 +86,12 @@ function fs_get_shipment( $shipment_id, WC_Order $order = null ) {
79
  return new $class_name( $shipment_id, $order );
80
  }
81
 
82
-
83
- function fs_calculate_order_weight( WC_Order $order ) {
 
 
 
 
84
  $weight = 0;
85
  if ( sizeof( $order->get_items() ) > 0 ) {
86
  foreach( $order->get_items() as $item ) {
11
  return false;
12
  }
13
 
14
+ /**
15
+ * @param WC_Abstract_Order $order Order.
16
+ * @param array $fs_method Flexible shipping method.
17
+ *
18
+ * @return WPDesk_Flexible_Shipping_Shipment
19
+ */
20
+ function fs_create_shipment( $order, $fs_method ) {
21
  if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
22
  $order_id = $order->id;
23
  }
69
  }
70
 
71
  /**
72
+ * Get shipment.
73
+ *
74
+ * @param int $shipment_id Shipment id.
75
+ * @param WC_Order|null $order Order.
76
  * @return WPDesk_Flexible_Shipping_Shipment
77
  */
78
+ function fs_get_shipment( $shipment_id, $order = null ) {
79
  $integration = get_post_meta( $shipment_id, '_integration', true );
80
  $class_name = 'WPDesk_Flexible_Shipping_Shipment';
81
  $integration_class_name = 'WPDesk_Flexible_Shipping_Shipment' . '_' . $integration;
86
  return new $class_name( $shipment_id, $order );
87
  }
88
 
89
+ /**
90
+ * @param WC_Abstract_Order $order Order.
91
+ *
92
+ * @return float
93
+ */
94
+ function fs_calculate_order_weight( $order ) {
95
  $weight = 0;
96
  if ( sizeof( $order->get_items() ) > 0 ) {
97
  foreach( $order->get_items() as $item ) {
classes/shipment/saas/class-shipment-saas-metabox.php CHANGED
@@ -21,6 +21,28 @@ class WPDesk_Flexible_Shipping_Shipment_Saas_Metabox {
21
  $this->shipment = $shipment;
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  /**
25
  * Display fieldset in order metabox.
26
  *
@@ -32,6 +54,11 @@ class WPDesk_Flexible_Shipping_Shipment_Saas_Metabox {
32
  private function display_order_metabox_fieldset( array $fieldset, $id, $disabled, $values ) {
33
  $fields = $fieldset['fields'];
34
  $is_replicable = false;
 
 
 
 
 
35
  if ( isset( $fieldset['replicable'] ) ) {
36
  $is_replicable = true;
37
  include 'views/order-metabox-fieldset-replicable.php';
21
  $this->shipment = $shipment;
22
  }
23
 
24
+ /**
25
+ * Prepare collection points options.
26
+ *
27
+ * @return array
28
+ */
29
+ private function prepare_collection_points_options() {
30
+ $shipping_service = $this->shipment->get_shipping_service();
31
+ $shipping_service_collection_points = $shipping_service->get_collection_points();
32
+
33
+ $order = $this->shipment->get_order();
34
+ $address = new \WPDesk\SaasPlatformClient\Model\Shipment\Address();
35
+ $address->setAddressLine1( $order->get_shipping_address_1() );
36
+ $address->setAddressLine2( $order->get_shipping_address_2() );
37
+ $address->setPostalCode( $order->get_shipping_postcode() );
38
+ $address->setCity( $order->get_shipping_city() );
39
+ $address->setStateCode( $order->get_shipping_state() );
40
+ $address->setCountryCode( $order->get_shipping_country() );
41
+
42
+ return $shipping_service_collection_points->prepare_collection_points_options_for_address( $address );
43
+ }
44
+
45
+
46
  /**
47
  * Display fieldset in order metabox.
48
  *
54
  private function display_order_metabox_fieldset( array $fieldset, $id, $disabled, $values ) {
55
  $fields = $fieldset['fields'];
56
  $is_replicable = false;
57
+ foreach ( $fields as $field_key => $field ) {
58
+ if ( 'parcel_collection_points' === $field['type'] ) {
59
+ $fields[ $field_key ]['access_points_options'] = $this->prepare_collection_points_options();
60
+ }
61
+ }
62
  if ( isset( $fieldset['replicable'] ) ) {
63
  $is_replicable = true;
64
  include 'views/order-metabox-fieldset-replicable.php';
classes/shipment/saas/class-shipment-saas-send.php CHANGED
@@ -31,7 +31,7 @@ class WPDesk_Flexible_Shipping_Shipment_Saas_Send {
31
  *
32
  * @return \WPDesk\SaasPlatformClient\Model\Shipment\Address
33
  */
34
- private function prepare_ship_to_address( WC_Order $order ) {
35
  $ship_to_address = new \WPDesk\SaasPlatformClient\Model\Shipment\Address();
36
  $ship_to_address->setAddressLine1( $order->get_shipping_address_1() );
37
  $ship_to_address->setAddressLine2( $order->get_shipping_address_2() );
@@ -50,12 +50,13 @@ class WPDesk_Flexible_Shipping_Shipment_Saas_Send {
50
  *
51
  * @return \WPDesk\SaasPlatformClient\Model\Shipment\Actor
52
  */
53
- private function prepare_ship_to( WC_Order $order ) {
54
  $ship_to = new \WPDesk\SaasPlatformClient\Model\Shipment\Actor();
55
  $ship_to->setAddress( $this->prepare_ship_to_address( $order ) );
56
  $ship_to->setName( trim( $order->get_shipping_first_name() . ' ' . $order->get_shipping_last_name() ) );
57
  $ship_to->setCompanyName( $order->get_shipping_company() );
58
  $ship_to->setPhoneNumber( $order->get_billing_phone() );
 
59
 
60
  return $ship_to;
61
  }
@@ -88,7 +89,7 @@ class WPDesk_Flexible_Shipping_Shipment_Saas_Send {
88
  *
89
  * @return \WPDesk\SaasPlatformClient\Model\Shipment\ClientCommodity[]
90
  */
91
- private function prepare_commodities( WC_Order $order ) {
92
  $commodities = array();
93
  /** @var WC_Order_Item_Product $order_item */
94
  foreach ( $order->get_items() as $order_item ) {
31
  *
32
  * @return \WPDesk\SaasPlatformClient\Model\Shipment\Address
33
  */
34
+ private function prepare_ship_to_address( $order ) {
35
  $ship_to_address = new \WPDesk\SaasPlatformClient\Model\Shipment\Address();
36
  $ship_to_address->setAddressLine1( $order->get_shipping_address_1() );
37
  $ship_to_address->setAddressLine2( $order->get_shipping_address_2() );
50
  *
51
  * @return \WPDesk\SaasPlatformClient\Model\Shipment\Actor
52
  */
53
+ private function prepare_ship_to( $order ) {
54
  $ship_to = new \WPDesk\SaasPlatformClient\Model\Shipment\Actor();
55
  $ship_to->setAddress( $this->prepare_ship_to_address( $order ) );
56
  $ship_to->setName( trim( $order->get_shipping_first_name() . ' ' . $order->get_shipping_last_name() ) );
57
  $ship_to->setCompanyName( $order->get_shipping_company() );
58
  $ship_to->setPhoneNumber( $order->get_billing_phone() );
59
+ $ship_to->setEmail( $order->get_billing_email() );
60
 
61
  return $ship_to;
62
  }
89
  *
90
  * @return \WPDesk\SaasPlatformClient\Model\Shipment\ClientCommodity[]
91
  */
92
+ private function prepare_commodities( $order ) {
93
  $commodities = array();
94
  /** @var WC_Order_Item_Product $order_item */
95
  foreach ( $order->get_items() as $order_item ) {
classes/shipment/saas/class-shipment-saas.php CHANGED
@@ -73,7 +73,7 @@ class WPDesk_Flexible_Shipping_Shipment_Saas
73
  * @param int $shipment_id Shipment ID.
74
  * @param WC_Order|null $order Order.
75
  */
76
- public function __construct( $shipment_id, WC_Order $order = null ) {
77
  parent::__construct( $shipment_id, $order );
78
  $shipping_methods = WC()->shipping()->get_shipping_methods();
79
  $integration = $this->get_integration();
@@ -111,9 +111,10 @@ class WPDesk_Flexible_Shipping_Shipment_Saas
111
  * @param array $field Field.
112
  * @param array $fs_method Flexible Shipping Method settings.
113
  * @param WC_Order_Item_Shipping $shipping_method Woocommerce shipping method.
 
114
  * @param float $package_weight Package weight.
115
  */
116
- private function save_field_data_from_shipping_method( array $field, array $fs_method, $shipping_method, $package_weight = 0 ) {
117
  $field_id = $field['id'];
118
  $fs_saas_data = $shipping_method->get_meta( '_fs_saas_data' );
119
  if ( ! is_array( $fs_saas_data ) ) {
@@ -134,6 +135,9 @@ class WPDesk_Flexible_Shipping_Shipment_Saas
134
  if ( isset( $fs_saas_data[ $meta_field_id ] ) ) {
135
  $this->set_meta( $field_id, $fs_saas_data[ $meta_field_id ] );
136
  }
 
 
 
137
  }
138
  }
139
 
@@ -143,11 +147,18 @@ class WPDesk_Flexible_Shipping_Shipment_Saas
143
  * @param array $fieldset Fieldset.
144
  * @param array $fs_method Flexible Shipping method.
145
  * @param WC_Order_Item_Shipping $shipping_method Woocommerce shipping method.
 
146
  * @param float $package_weight Package weight.
147
  */
148
- private function save_fieldset_data_from_shipping_method( array $fieldset, array $fs_method, $shipping_method, $package_weight ) {
 
 
 
 
 
 
149
  foreach ( $fieldset['fields'] as $field ) {
150
- $this->save_field_data_from_shipping_method( $field, $fs_method, $shipping_method, $package_weight );
151
  }
152
  }
153
 
@@ -191,6 +202,8 @@ class WPDesk_Flexible_Shipping_Shipment_Saas
191
  */
192
  public function checkout( array $fs_method, $package ) {
193
 
 
 
194
  $shipping_method = $this->get_meta_shipping_method();
195
 
196
  if ( null !== $shipping_method ) {
@@ -206,10 +219,18 @@ class WPDesk_Flexible_Shipping_Shipment_Saas
206
 
207
  try {
208
  $fields = $this->shipping_service->get_fields_for_targets( [ $order->get_shipping_country() ] );
209
-
210
  foreach ( $fields as $fieldset ) {
211
- if ( isset( $fieldset['show-in'] ) && in_array( 'metabox', $fieldset['show-in'], true ) ) {
212
- $this->save_fieldset_data_from_shipping_method( $fieldset, $fs_method, $shipping_method, $package_weight );
 
 
 
 
 
 
 
 
 
213
  }
214
  }
215
  } catch ( Exception $e ) {
@@ -588,21 +609,45 @@ class WPDesk_Flexible_Shipping_Shipment_Saas
588
  return $this->get_label_from_platform();
589
  }
590
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
591
  /**
592
  * Echo after order table.
593
  */
594
  public function get_after_order_table() {
595
  if ( $this->label_avaliable() ) {
596
- $args = array(
597
- 'shipments' => array(
598
- array(
599
- 'tracking_url' => $this->get_tracking_url(),
600
- 'tracking_number' => $this->get_tracking_number(),
601
- ),
602
- ),
603
- );
604
- echo self::$renderer->render( 'myaccount/after_order_table', $args );
605
  }
 
606
  }
607
 
608
  /**
@@ -612,16 +657,9 @@ class WPDesk_Flexible_Shipping_Shipment_Saas
612
  if ( 'yes' === $this->shipping_service->get_option_from_shipping_method( 'email_add_tracking_number' )
613
  && $this->label_avaliable()
614
  ) {
615
- $args = array(
616
- 'shipments' => array(
617
- array(
618
- 'tracking_url' => $this->get_tracking_url(),
619
- 'tracking_number' => $this->get_tracking_number(),
620
- ),
621
- ),
622
- );
623
- echo self::$renderer->render( 'email/after_order_table', $args );
624
  }
 
625
  }
626
 
627
  /**
73
  * @param int $shipment_id Shipment ID.
74
  * @param WC_Order|null $order Order.
75
  */
76
+ public function __construct( $shipment_id, $order = null ) {
77
  parent::__construct( $shipment_id, $order );
78
  $shipping_methods = WC()->shipping()->get_shipping_methods();
79
  $integration = $this->get_integration();
111
  * @param array $field Field.
112
  * @param array $fs_method Flexible Shipping Method settings.
113
  * @param WC_Order_Item_Shipping $shipping_method Woocommerce shipping method.
114
+ * @param array $post_data Post data.
115
  * @param float $package_weight Package weight.
116
  */
117
+ private function save_field_data_from_shipping_method( array $field, array $fs_method, $shipping_method, $post_data, $package_weight = 0.0 ) {
118
  $field_id = $field['id'];
119
  $fs_saas_data = $shipping_method->get_meta( '_fs_saas_data' );
120
  if ( ! is_array( $fs_saas_data ) ) {
135
  if ( isset( $fs_saas_data[ $meta_field_id ] ) ) {
136
  $this->set_meta( $field_id, $fs_saas_data[ $meta_field_id ] );
137
  }
138
+ if ( isset( $post_data[ $field_id . '_' . $this->shipping_service->get_integration_id() ] ) ) {
139
+ $this->set_meta( $field_id, $post_data[ $field_id . '_' . $this->shipping_service->get_integration_id() ] );
140
+ }
141
  }
142
  }
143
 
147
  * @param array $fieldset Fieldset.
148
  * @param array $fs_method Flexible Shipping method.
149
  * @param WC_Order_Item_Shipping $shipping_method Woocommerce shipping method.
150
+ * @param array $post_data Post data.
151
  * @param float $package_weight Package weight.
152
  */
153
+ private function save_fieldset_data_from_shipping_method(
154
+ array $fieldset,
155
+ array $fs_method,
156
+ $shipping_method,
157
+ array $post_data,
158
+ $package_weight
159
+ ) {
160
  foreach ( $fieldset['fields'] as $field ) {
161
+ $this->save_field_data_from_shipping_method( $field, $fs_method, $shipping_method, $post_data, $package_weight );
162
  }
163
  }
164
 
202
  */
203
  public function checkout( array $fs_method, $package ) {
204
 
205
+ $post_data = $_REQUEST;
206
+
207
  $shipping_method = $this->get_meta_shipping_method();
208
 
209
  if ( null !== $shipping_method ) {
219
 
220
  try {
221
  $fields = $this->shipping_service->get_fields_for_targets( [ $order->get_shipping_country() ] );
 
222
  foreach ( $fields as $fieldset ) {
223
+ if (
224
+ isset( $fieldset['show-in'] ) && in_array( 'metabox', $fieldset['show-in'], true )
225
+ || isset( $fieldset['show-in'] ) && in_array( 'checkout', $fieldset['show-in'], true )
226
+ ) {
227
+ $this->save_fieldset_data_from_shipping_method(
228
+ $fieldset,
229
+ $fs_method,
230
+ $shipping_method,
231
+ $post_data,
232
+ $package_weight
233
+ );
234
  }
235
  }
236
  } catch ( Exception $e ) {
609
  return $this->get_label_from_platform();
610
  }
611
 
612
+ /**
613
+ * Prepare args tracking data.
614
+ *
615
+ * @return array
616
+ */
617
+ private function prepare_args_tracking_data() {
618
+ return array(
619
+ 'shipments' => array(
620
+ array(
621
+ 'tracking_url' => $this->get_tracking_url(),
622
+ 'tracking_number' => $this->get_tracking_number(),
623
+ ),
624
+ ),
625
+ );
626
+ }
627
+
628
+ /**
629
+ * Display checkout fields.
630
+ *
631
+ * @param string $folder Template folder.
632
+ */
633
+ private function maybe_display_checkout_fields( $folder ) {
634
+ $checkout_fields = new WPDesk_Flexible_Shipping_SaaS_Shipping_Checkout_Fields_Shipment(
635
+ $this->shipping_service,
636
+ $this->shipping_service->get_collection_points(),
637
+ self::$renderer,
638
+ $folder
639
+ );
640
+ $checkout_fields->maybe_display_fields_for_shipment( $this );
641
+ }
642
+
643
  /**
644
  * Echo after order table.
645
  */
646
  public function get_after_order_table() {
647
  if ( $this->label_avaliable() ) {
648
+ echo self::$renderer->render( 'myaccount/after_order_table', $this->prepare_args_tracking_data() ); // phpcs:ignore
 
 
 
 
 
 
 
 
649
  }
650
+ $this->maybe_display_checkout_fields( 'myaccount' );
651
  }
652
 
653
  /**
657
  if ( 'yes' === $this->shipping_service->get_option_from_shipping_method( 'email_add_tracking_number' )
658
  && $this->label_avaliable()
659
  ) {
660
+ echo self::$renderer->render( 'email/after_order_table', $this->prepare_args_tracking_data() ); // phpcs:ignore
 
 
 
 
 
 
 
 
661
  }
662
+ $this->maybe_display_checkout_fields( 'email' );
663
  }
664
 
665
  /**
classes/shipment/saas/views/order-metabox-fieldset.php CHANGED
@@ -1,3 +1,12 @@
 
 
 
 
 
 
 
 
 
1
  <?php foreach ( $fields as $field ) : ?>
2
  <?php
3
  if ( ! empty( $field['id'] ) ) {
@@ -13,6 +22,10 @@
13
  $args['options'][ $option['value'] ] = $option['text'];
14
  }
15
  }
 
 
 
 
16
  if ( isset( $values[ $key ] ) ) {
17
  $args['value'] = $values[ $key ][0];
18
  }
@@ -28,13 +41,13 @@
28
  }
29
  }
30
  ?>
31
- <div class="<?php echo $key; ?>">
32
  <?php if ( 'checkbox' === $field['type'] ) : ?>
33
  <?php $args['label'] .= ' '; ?>
34
  <?php woocommerce_wp_checkbox( $args ); ?>
35
  <?php elseif ( 'header' === $field['type'] ) : ?>
36
- <h4><?php echo $field['name']; ?></h4>
37
- <?php elseif ( 'select' === $field['type'] ) : ?>
38
  <?php woocommerce_wp_select( $args ); ?>
39
  <?php else : ?>
40
  <?php woocommerce_wp_text_input( $args ); ?>
1
+ <?php
2
+ /**
3
+ * Display fieldset in metabox.
4
+ *
5
+ * @var array $fields
6
+ * @var array $values
7
+ * @var bool $disabled
8
+ */
9
+ ?>
10
  <?php foreach ( $fields as $field ) : ?>
11
  <?php
12
  if ( ! empty( $field['id'] ) ) {
22
  $args['options'][ $option['value'] ] = $option['text'];
23
  }
24
  }
25
+ if ( 'parcel_collection_points' === $field['type'] ) {
26
+ $args['options'] = $field['access_points_options'];
27
+ $args['class'] = 'fs_select2';
28
+ }
29
  if ( isset( $values[ $key ] ) ) {
30
  $args['value'] = $values[ $key ][0];
31
  }
41
  }
42
  }
43
  ?>
44
+ <div class="<?php echo esc_attr( $key ); ?>">
45
  <?php if ( 'checkbox' === $field['type'] ) : ?>
46
  <?php $args['label'] .= ' '; ?>
47
  <?php woocommerce_wp_checkbox( $args ); ?>
48
  <?php elseif ( 'header' === $field['type'] ) : ?>
49
+ <h4><?php echo $field['name']; /* phpcs:ignore */ ?></h4>
50
+ <?php elseif ( 'select' === $field['type'] || 'parcel_collection_points' === $field['type'] ) : ?>
51
  <?php woocommerce_wp_select( $args ); ?>
52
  <?php else : ?>
53
  <?php woocommerce_wp_text_input( $args ); ?>
flexible-shipping.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Flexible Shipping
4
  Plugin URI: https://wordpress.org/plugins/flexible-shipping/
5
  Description: Create additional shipment methods in WooCommerce and enable pricing based on cart weight or total.
6
- Version: 3.1.12
7
  Author: WP Desk
8
  Author URI: https://www.wpdesk.net/
9
  Text Domain: flexible-shipping
@@ -11,7 +11,7 @@
11
  Requires at least: 4.5
12
  Tested up to: 5.1.0
13
  WC requires at least: 3.1.0
14
- WC tested up to: 3.5.5
15
 
16
  Copyright 2017 WP Desk Ltd.
17
 
@@ -44,7 +44,7 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
44
 
45
  /* THESE TWO VARIABLES CAN BE CHANGED AUTOMATICALLY */
46
 
47
- $plugin_version = '3.1.12';
48
  $plugin_release_timestamp = '2019-02-06';
49
 
50
  $plugin_name = 'Flexible Shipping';
3
  Plugin Name: Flexible Shipping
4
  Plugin URI: https://wordpress.org/plugins/flexible-shipping/
5
  Description: Create additional shipment methods in WooCommerce and enable pricing based on cart weight or total.
6
+ Version: 3.2.0
7
  Author: WP Desk
8
  Author URI: https://www.wpdesk.net/
9
  Text Domain: flexible-shipping
11
  Requires at least: 4.5
12
  Tested up to: 5.1.0
13
  WC requires at least: 3.1.0
14
+ WC tested up to: 3.5.6
15
 
16
  Copyright 2017 WP Desk Ltd.
17
 
44
 
45
  /* THESE TWO VARIABLES CAN BE CHANGED AUTOMATICALLY */
46
 
47
+ $plugin_version = '3.2.0';
48
  $plugin_release_timestamp = '2019-02-06';
49
 
50
  $plugin_name = 'Flexible Shipping';
lang/flexible-shipping-pl_PL.mo CHANGED
Binary file
lang/flexible-shipping-pl_PL.po CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Flexible Shipping\n"
4
- "POT-Creation-Date: 2019-02-19 17:12+0100\n"
5
- "PO-Revision-Date: 2019-03-01 07:56+0100\n"
6
  "Last-Translator: Piotr Jabłonowski <piotr.jablonowski@wpdesk.net>\n"
7
  "Language-Team: Maciej Swoboda <maciej.swoboda@gmail.com>\n"
8
  "Language: pl_PL\n"
@@ -188,26 +188,26 @@ msgstr ""
188
  msgid "Bulk shipping manifest - processed orders: %d"
189
  msgstr "Zbiorcze tworzenie protokołów nadania - przetworzone zamówienia: %d"
190
 
191
- #: classes/class-flexible-shipping-plugin.php:428
192
  msgid "Settings"
193
  msgstr "Ustawienia"
194
 
195
- #: classes/class-flexible-shipping-plugin.php:430
196
  msgid "Docs"
197
  msgstr "Docs"
198
 
199
- #: classes/class-flexible-shipping-plugin.php:431
200
  msgid "Support"
201
  msgstr "Wsparcie"
202
 
203
- #: classes/class-flexible-shipping-plugin.php:437
204
  msgid "Upgrade"
205
  msgstr "Kup PRO"
206
 
207
  #: classes/class-order-add-shipping.php:38
208
  #, php-format
209
  msgid "Shipment for order %1$s, %2$s"
210
- msgstr "Przesyłka do zamówienia %1$s, %2$s"
211
 
212
  #: classes/class-order-add-shipping.php:53
213
  #, php-format
@@ -322,6 +322,7 @@ msgstr "Akcje"
322
 
323
  #: classes/manifest/cpt-shipping-manifest.php:219
324
  #: classes/manifest/cpt-shipping-manifest.php:243
 
325
  #: classes/shipment/cpt-shipment.php:188
326
  msgid "Invalid nonce!"
327
  msgstr "Błąd weryfikacji nonce!"
@@ -358,6 +359,10 @@ msgstr "Przesyłka"
358
  msgid "Order"
359
  msgstr "Zamówienie"
360
 
 
 
 
 
361
  #: classes/saas/class-saas-bad-credentials-exception.php:17
362
  #, php-format
363
  msgid ""
@@ -500,17 +505,17 @@ msgstr "%1$s (darmowa wysyłka)"
500
  msgid "%1$s (fallback)"
501
  msgstr "%1$s (stawka awaryjna)"
502
 
503
- #: classes/saas/class-saas-live-rates-handler.php:437
504
  #, php-format
505
  msgid "Flexible Shipping Fallback (%1$s): %2$s"
506
  msgstr "Stawka awaryjna Flexible Shipping (%1$s): %2$s"
507
 
508
- #: classes/saas/class-saas-live-rates-handler.php:490
509
  #, php-format
510
  msgid "Invalid live rates response! Error code: %1$s"
511
  msgstr "Nieprawidłowa odpowiedź dla stawek live! Kod błędu: %1$s"
512
 
513
- #: classes/saas/class-saas-live-rates-handler.php:509
514
  #, php-format
515
  msgid "Live rates response exception %1$s; %2$s occurred while sending request"
516
  msgstr ""
@@ -619,16 +624,16 @@ msgstr "Invalid format - contact with flexibleshipping.com administrator."
619
  msgid "Ups, something is wrong. Error code: %1$s."
620
  msgstr "Ups, coś poszło nie tak. Kod błędu: %1$s."
621
 
622
- #: classes/saas/class-saas-shipping-service.php:539
623
  msgid "Rates type"
624
  msgstr "Typ stawek"
625
 
626
- #: classes/saas/class-saas-shipping-service.php:543
627
- #: classes/saas/class-saas-shipping-service.php:555
628
  msgid "Custom"
629
  msgstr "Własne"
630
 
631
- #: classes/saas/class-saas-shipping-service.php:547
632
  #, php-format
633
  msgid ""
634
  "Choose custom rates to set a custom shipping cost (this method will be the "
@@ -639,27 +644,27 @@ msgstr ""
639
  "wysyłki będzie wybrana usługa %1$s). Wybierz stawki Live, jeśli chcesz "
640
  "prezentować usługi i stawki wg. adresu klienta."
641
 
642
- #: classes/saas/class-saas-shipping-service.php:554
643
  msgid "Live"
644
  msgstr "Live"
645
 
646
- #: classes/saas/class-saas-shipping-service.php:573
647
  msgid "Custom services"
648
  msgstr "Usługi"
649
 
650
- #: classes/saas/class-saas-shipping-service.php:577
651
  msgid "Enable services custom settings"
652
  msgstr "Włącz własne ustawienia usług"
653
 
654
- #: classes/saas/class-saas-shipping-service.php:619
655
  msgid "Fallback"
656
  msgstr "Stawka awaryjna"
657
 
658
- #: classes/saas/class-saas-shipping-service.php:620
659
  msgid "Enable fallback"
660
  msgstr "Włącz stawkę awaryjną"
661
 
662
- #: classes/saas/class-saas-shipping-service.php:622
663
  msgid ""
664
  "Enable to offer flat rate cost for shipping so that the user can still "
665
  "checkout, if API returns no matching rates."
@@ -667,12 +672,12 @@ msgstr ""
667
  "Włącz, aby oferować płaską stawkę wysyłki. Klient będzie mógł zrealizować "
668
  "zamówienia jeśli API nie zwróci żadnych usług."
669
 
670
- #: classes/saas/class-saas-shipping-service.php:755
671
  #, php-format
672
  msgid "You need to configure the service. %1$sGo to %2$s settings.%3$s"
673
  msgstr "Musisz skonfigurować usługę. %1$sPrzejdź do %2$s ustawień.%3$s"
674
 
675
- #: classes/saas/class-saas-shipping-services-manager.php:163
676
  #, php-format
677
  msgid "%1$sYour settings have been saved.%2$s"
678
  msgstr "%1$sUstawienia zostały zapisane.%2$s"
@@ -743,6 +748,26 @@ msgstr ""
743
  msgid "Unknown response code from Flexible Shipping Connect API (%s)."
744
  msgstr "Nieznany kod odpowiedzi z API Flexible Shipping Connect (%s)."
745
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
746
  #: classes/saas/views/html-boxes-content.php:4
747
  #: classes/saas/views/html-boxes-content.php:5
748
  msgid "Print Labels"
@@ -1251,7 +1276,7 @@ msgstr "Brak danych!"
1251
  msgid "Saved"
1252
  msgstr "Zapisano"
1253
 
1254
- #: classes/shipment/class-shipment.php:299
1255
  msgid "Please override shipping_column method!"
1256
  msgstr "Proszę nadpisać metodę shipping_column!"
1257
 
@@ -1348,7 +1373,7 @@ msgstr[2] "Błąd <span class=\"count\">(%s)</span>"
1348
  msgid "Shipment data"
1349
  msgstr "Dane przesyłki"
1350
 
1351
- #: classes/shipment/functions.php:23
1352
  #, php-format
1353
  msgid "Shipment for order %s, %s"
1354
  msgstr "Przesyłka do zamówienia %s, %s"
@@ -1377,27 +1402,27 @@ msgstr "Anulowana"
1377
  msgid "%1$s notice"
1378
  msgstr "%1$s komunikat"
1379
 
1380
- #: classes/shipment/saas/class-shipment-saas-send.php:187
1381
- #: classes/shipment/saas/class-shipment-saas.php:351
1382
  msgid "UPS! Something is wrong!"
1383
  msgstr "UPS! Nie działa poprawnie!"
1384
 
1385
- #: classes/shipment/saas/class-shipment-saas.php:221
1386
  #, php-format
1387
  msgid "There was problems on checkout: %1$s"
1388
  msgstr "Pojawił się problem na stronie zamówienia: %1$s"
1389
 
1390
- #: classes/shipment/saas/class-shipment-saas.php:314
1391
  #, php-format
1392
  msgid "%1$s Shipment %2$s was created."
1393
  msgstr "%1$s Przesyłka %2$s została utworzona."
1394
 
1395
- #: classes/shipment/saas/class-shipment-saas.php:332
1396
  #, php-format
1397
  msgid "%1$s Shipment %2$s was canceled."
1398
  msgstr "%1$s Przesyłka %2$s została anulowana."
1399
 
1400
- #: classes/shipment/saas/class-shipment-saas.php:586
1401
  msgid "Label is not avaliable for this shipment."
1402
  msgstr "Etykieta nie jest dostępna dla tej przesyłki."
1403
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Flexible Shipping\n"
4
+ "POT-Creation-Date: 2019-03-11 11:46+0100\n"
5
+ "PO-Revision-Date: 2019-03-11 11:47+0100\n"
6
  "Last-Translator: Piotr Jabłonowski <piotr.jablonowski@wpdesk.net>\n"
7
  "Language-Team: Maciej Swoboda <maciej.swoboda@gmail.com>\n"
8
  "Language: pl_PL\n"
188
  msgid "Bulk shipping manifest - processed orders: %d"
189
  msgstr "Zbiorcze tworzenie protokołów nadania - przetworzone zamówienia: %d"
190
 
191
+ #: classes/class-flexible-shipping-plugin.php:441
192
  msgid "Settings"
193
  msgstr "Ustawienia"
194
 
195
+ #: classes/class-flexible-shipping-plugin.php:443
196
  msgid "Docs"
197
  msgstr "Docs"
198
 
199
+ #: classes/class-flexible-shipping-plugin.php:444
200
  msgid "Support"
201
  msgstr "Wsparcie"
202
 
203
+ #: classes/class-flexible-shipping-plugin.php:450
204
  msgid "Upgrade"
205
  msgstr "Kup PRO"
206
 
207
  #: classes/class-order-add-shipping.php:38
208
  #, php-format
209
  msgid "Shipment for order %1$s, %2$s"
210
+ msgstr "Przesyłka do zamówienia %s, %s"
211
 
212
  #: classes/class-order-add-shipping.php:53
213
  #, php-format
322
 
323
  #: classes/manifest/cpt-shipping-manifest.php:219
324
  #: classes/manifest/cpt-shipping-manifest.php:243
325
+ #: classes/saas/collection-points/class-saas-collection-points-ajax.php:76
326
  #: classes/shipment/cpt-shipment.php:188
327
  msgid "Invalid nonce!"
328
  msgstr "Błąd weryfikacji nonce!"
359
  msgid "Order"
360
  msgstr "Zamówienie"
361
 
362
+ #: classes/saas/checkout-fields/class-saas-checkout-field-collection-points.php:123
363
+ msgid "Select point from map"
364
+ msgstr "Wybierz punkt z mapy"
365
+
366
  #: classes/saas/class-saas-bad-credentials-exception.php:17
367
  #, php-format
368
  msgid ""
505
  msgid "%1$s (fallback)"
506
  msgstr "%1$s (stawka awaryjna)"
507
 
508
+ #: classes/saas/class-saas-live-rates-handler.php:460
509
  #, php-format
510
  msgid "Flexible Shipping Fallback (%1$s): %2$s"
511
  msgstr "Stawka awaryjna Flexible Shipping (%1$s): %2$s"
512
 
513
+ #: classes/saas/class-saas-live-rates-handler.php:513
514
  #, php-format
515
  msgid "Invalid live rates response! Error code: %1$s"
516
  msgstr "Nieprawidłowa odpowiedź dla stawek live! Kod błędu: %1$s"
517
 
518
+ #: classes/saas/class-saas-live-rates-handler.php:532
519
  #, php-format
520
  msgid "Live rates response exception %1$s; %2$s occurred while sending request"
521
  msgstr ""
624
  msgid "Ups, something is wrong. Error code: %1$s."
625
  msgstr "Ups, coś poszło nie tak. Kod błędu: %1$s."
626
 
627
+ #: classes/saas/class-saas-shipping-service.php:546
628
  msgid "Rates type"
629
  msgstr "Typ stawek"
630
 
631
+ #: classes/saas/class-saas-shipping-service.php:550
632
+ #: classes/saas/class-saas-shipping-service.php:562
633
  msgid "Custom"
634
  msgstr "Własne"
635
 
636
+ #: classes/saas/class-saas-shipping-service.php:554
637
  #, php-format
638
  msgid ""
639
  "Choose custom rates to set a custom shipping cost (this method will be the "
644
  "wysyłki będzie wybrana usługa %1$s). Wybierz stawki Live, jeśli chcesz "
645
  "prezentować usługi i stawki wg. adresu klienta."
646
 
647
+ #: classes/saas/class-saas-shipping-service.php:561
648
  msgid "Live"
649
  msgstr "Live"
650
 
651
+ #: classes/saas/class-saas-shipping-service.php:580
652
  msgid "Custom services"
653
  msgstr "Usługi"
654
 
655
+ #: classes/saas/class-saas-shipping-service.php:584
656
  msgid "Enable services custom settings"
657
  msgstr "Włącz własne ustawienia usług"
658
 
659
+ #: classes/saas/class-saas-shipping-service.php:626
660
  msgid "Fallback"
661
  msgstr "Stawka awaryjna"
662
 
663
+ #: classes/saas/class-saas-shipping-service.php:627
664
  msgid "Enable fallback"
665
  msgstr "Włącz stawkę awaryjną"
666
 
667
+ #: classes/saas/class-saas-shipping-service.php:629
668
  msgid ""
669
  "Enable to offer flat rate cost for shipping so that the user can still "
670
  "checkout, if API returns no matching rates."
672
  "Włącz, aby oferować płaską stawkę wysyłki. Klient będzie mógł zrealizować "
673
  "zamówienia jeśli API nie zwróci żadnych usług."
674
 
675
+ #: classes/saas/class-saas-shipping-service.php:762
676
  #, php-format
677
  msgid "You need to configure the service. %1$sGo to %2$s settings.%3$s"
678
  msgstr "Musisz skonfigurować usługę. %1$sPrzejdź do %2$s ustawień.%3$s"
679
 
680
+ #: classes/saas/class-saas-shipping-services-manager.php:177
681
  #, php-format
682
  msgid "%1$sYour settings have been saved.%2$s"
683
  msgstr "%1$sUstawienia zostały zapisane.%2$s"
748
  msgid "Unknown response code from Flexible Shipping Connect API (%s)."
749
  msgstr "Nieznany kod odpowiedzi z API Flexible Shipping Connect (%s)."
750
 
751
+ #: classes/saas/collection-points/class-saas-collection-points-map.php:47
752
+ msgid "Points can not be found. Check the shipping address."
753
+ msgstr "Nie można znaleźć punktów. Sprawdź adres wysyłki."
754
+
755
+ #: classes/saas/collection-points/class-saas-collection-points-map.php:48
756
+ msgid "It's your location"
757
+ msgstr "Twoja lokalizacja"
758
+
759
+ #: classes/saas/collection-points/class-saas-shipping-service-collection-points.php:79
760
+ msgid "Cannot get data for this address!"
761
+ msgstr "Nie można uzyskać danych dla tego adresu!"
762
+
763
+ #: classes/saas/collection-points/views/map.php:4
764
+ msgid "Select point"
765
+ msgstr "Wybierz punkt"
766
+
767
+ #: classes/saas/collection-points/views/map.php:116
768
+ msgid "Select"
769
+ msgstr "Wybierz"
770
+
771
  #: classes/saas/views/html-boxes-content.php:4
772
  #: classes/saas/views/html-boxes-content.php:5
773
  msgid "Print Labels"
1276
  msgid "Saved"
1277
  msgstr "Zapisano"
1278
 
1279
+ #: classes/shipment/class-shipment.php:300
1280
  msgid "Please override shipping_column method!"
1281
  msgstr "Proszę nadpisać metodę shipping_column!"
1282
 
1373
  msgid "Shipment data"
1374
  msgstr "Dane przesyłki"
1375
 
1376
+ #: classes/shipment/functions.php:28
1377
  #, php-format
1378
  msgid "Shipment for order %s, %s"
1379
  msgstr "Przesyłka do zamówienia %s, %s"
1402
  msgid "%1$s notice"
1403
  msgstr "%1$s komunikat"
1404
 
1405
+ #: classes/shipment/saas/class-shipment-saas-send.php:191
1406
+ #: classes/shipment/saas/class-shipment-saas.php:372
1407
  msgid "UPS! Something is wrong!"
1408
  msgstr "UPS! Nie działa poprawnie!"
1409
 
1410
+ #: classes/shipment/saas/class-shipment-saas.php:242
1411
  #, php-format
1412
  msgid "There was problems on checkout: %1$s"
1413
  msgstr "Pojawił się problem na stronie zamówienia: %1$s"
1414
 
1415
+ #: classes/shipment/saas/class-shipment-saas.php:335
1416
  #, php-format
1417
  msgid "%1$s Shipment %2$s was created."
1418
  msgstr "%1$s Przesyłka %2$s została utworzona."
1419
 
1420
+ #: classes/shipment/saas/class-shipment-saas.php:353
1421
  #, php-format
1422
  msgid "%1$s Shipment %2$s was canceled."
1423
  msgstr "%1$s Przesyłka %2$s została anulowana."
1424
 
1425
+ #: classes/shipment/saas/class-shipment-saas.php:607
1426
  msgid "Label is not avaliable for this shipment."
1427
  msgstr "Etykieta nie jest dostępna dla tej przesyłki."
1428
 
plugin-load.php CHANGED
@@ -33,4 +33,4 @@ $loader_info->set_plugin_info($plugin_info);
33
  $composer_loader = new WPDesk_Composer_Loader($loader_info);
34
 
35
  $loader_manager = WPDesk_Loader_Manager_Factory::get_manager_instance();
36
- $loader_manager->attach_loader($composer_loader);
33
  $composer_loader = new WPDesk_Composer_Loader($loader_info);
34
 
35
  $loader_manager = WPDesk_Loader_Manager_Factory::get_manager_instance();
36
+ $loader_manager->attach_loader($composer_loader);
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flexibleshipping.com/table-rate/
4
  Tags: table rate, table rate shipping, woocommerce shipping, flexible shipping, woocommerce table rate shipping, cart based shipping, weight shipping, weight based shipping, totals based shipping, order based shipping, shipping zones, shipping classes
5
  Requires at least: 4.5
6
  Tested up to: 5.1.0
7
- Stable tag: 3.1.12
8
  Requires PHP: 5.6
9
  License: GPLv3 or later
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -175,6 +175,10 @@ If you are upgrading from the old Flexible Shipping version (1.3.2, woo-flexible
175
 
176
  == Changelog ==
177
 
 
 
 
 
178
  = 3.1.12 - 2019-03-05 =
179
  * Fixed inifinite method call on WooCommerce 3.1
180
 
4
  Tags: table rate, table rate shipping, woocommerce shipping, flexible shipping, woocommerce table rate shipping, cart based shipping, weight shipping, weight based shipping, totals based shipping, order based shipping, shipping zones, shipping classes
5
  Requires at least: 4.5
6
  Tested up to: 5.1.0
7
+ Stable tag: 3.2.0
8
  Requires PHP: 5.6
9
  License: GPLv3 or later
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
175
 
176
  == Changelog ==
177
 
178
+ = 3.2.0 - 2019-03-11 =
179
+ * Added support for UPS Access Points for FS Connect
180
+ * Removed argument types for WooCommerce types (ie. WC_Order)
181
+
182
  = 3.1.12 - 2019-03-05 =
183
  * Fixed inifinite method call on WooCommerce 3.1
184
 
templates/checkout/shipping-method-after.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Display collection point select.
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/flexible-shipping/checkout/shipping-method-after.php
6
+ *
7
+ * @package Flexible Shipping.
8
+ *
9
+ * @var $collection_point_label string
10
+ * @var $select_options array
11
+ * @var $selected_collection_point string
12
+ * @var $collection_point_field_name string
13
+ * @var $collection_point_description string
14
+ * @var $collection_point_map_selector_label string
15
+ * @car $collection_point_service_id string
16
+ */
17
+
18
+ ?><tr class="shipping flexible-shipping-collection-point">
19
+ <td colspan="2">
20
+ <h4><?php echo esc_html( $collection_point_label ); ?></h4>
21
+ <?php
22
+
23
+ $field_args = array(
24
+ 'type' => 'select',
25
+ 'options' => $select_options,
26
+ 'description' => $collection_point_description,
27
+ 'class' => array( 'flexible-shipping-collection-point-select' ),
28
+ );
29
+ woocommerce_form_field( $collection_point_field_name, $field_args, $selected_collection_point );
30
+ ?>
31
+ <a
32
+ class="flexible-shipping-collection-point-map-selector"
33
+ data-select-id="<?php echo esc_attr( $collection_point_field_name ); ?>" href="#<?php echo esc_attr( $collection_point_field_name ); ?>"
34
+ data-service-id="<?php echo esc_attr( $collection_point_service_id ); ?>" href="#<?php echo esc_attr( $collection_point_field_name ); ?>"
35
+ ><?php echo esc_html( $collection_point_map_selector_label ); ?></a>
36
+ <script type="text/javascript">
37
+ if (jQuery().select2) {
38
+ jQuery('#<?php echo esc_attr( $collection_point_field_name ); ?>').select2();
39
+ }
40
+ </script>
41
+ </td>
42
+ </tr>
templates/email/after_order_table_checkout_field.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Checkout field: ie. access point.
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/flexible-shipping/email/after_order_table_checkout_field.php
6
+ *
7
+ * @author WP Desk
8
+ * @version 1.0.0
9
+ * @package Flexible Shipping.
10
+ *
11
+ * @var string $field_label
12
+ * @var string $field_value
13
+ */
14
+
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit;
17
+ } // Exit if accessed directly
18
+ ?>
19
+ <h2><?php echo $field_label; /* phpcs:ignore */ ?></h2>
20
+ <p>
21
+ <?php echo $field_value; /* phpcs:ignore */ ?>
22
+ </p>
templates/myaccount/after_order_table_checkout_field.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Checkout field: ie. access point.
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/flexible-shipping/my-account/after_order_table_checkout_field.php
6
+ *
7
+ * @author WP Desk
8
+ * @version 1.0.0
9
+ * @package Flexible Shipping.
10
+ *
11
+ * @var string $field_label
12
+ * @var string $field_value
13
+ */
14
+
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit;
17
+ } // Exit if accessed directly
18
+ ?>
19
+ <h2><?php echo $field_label; /* phpcs:ignore */ ?></h2>
20
+ <p>
21
+ <?php echo $field_value; /* phpcs:ignore */ ?>
22
+ </p>
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit152e6397a0e4a8b6775cf43096e6a469::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit31450fef395a4f32c40a3045e54b4081::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -320,6 +320,12 @@ return array(
320
  'WPDesk\\SaasPlatformClient\\Model\\KeyInfo' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/KeyInfo.php',
321
  'WPDesk\\SaasPlatformClient\\Model\\Label\\Label' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/Label/Label.php',
322
  'WPDesk\\SaasPlatformClient\\Model\\LoginData' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/LoginData.php',
 
 
 
 
 
 
323
  'WPDesk\\SaasPlatformClient\\Model\\Rate\\RateRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/Rate/RateRequest.php',
324
  'WPDesk\\SaasPlatformClient\\Model\\Rate\\RateResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/Rate/RateResponse.php',
325
  'WPDesk\\SaasPlatformClient\\Model\\Rate\\SingleRate' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/Rate/SingleRate.php',
@@ -364,6 +370,8 @@ return array(
364
  'WPDesk\\SaasPlatformClient\\Request\\Cancel\\PostCancelRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/Cancel/PostCancelRequest.php',
365
  'WPDesk\\SaasPlatformClient\\Request\\Fields\\GetFieldsRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/Fields/GetFieldsRequest.php',
366
  'WPDesk\\SaasPlatformClient\\Request\\Label\\PostLabelRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/Label/PostLabelRequest.php',
 
 
367
  'WPDesk\\SaasPlatformClient\\Request\\Rate\\PostRateRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/Rate/PostRateRequest.php',
368
  'WPDesk\\SaasPlatformClient\\Request\\Request' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/Request.php',
369
  'WPDesk\\SaasPlatformClient\\Request\\Shipment\\GetUserListShipmentRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/Shipment/GetUserListShipmentRequest.php',
@@ -391,6 +399,8 @@ return array(
391
  'WPDesk\\SaasPlatformClient\\Response\\Fields\\GetFieldsResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/Fields/GetFieldsResponse.php',
392
  'WPDesk\\SaasPlatformClient\\Response\\Label\\PostLabelResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/Label/PostLabelResponse.php',
393
  'WPDesk\\SaasPlatformClient\\Response\\Maintenance\\MaintenanceResponseContext' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/Maintenance/MaintenanceResponseContext.php',
 
 
394
  'WPDesk\\SaasPlatformClient\\Response\\ProtectedResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/ProtectedResponse.php',
395
  'WPDesk\\SaasPlatformClient\\Response\\Rate\\PostRateResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/Rate/PostRateResponse.php',
396
  'WPDesk\\SaasPlatformClient\\Response\\RawResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/RawResponse.php',
@@ -430,6 +440,7 @@ return array(
430
  'WPDesk_Flexible_Shipping_Admin_Notices' => $baseDir . '/classes/admin-notices.php',
431
  'WPDesk_Flexible_Shipping_Bulk_Actions' => $baseDir . '/classes/bulk-actions.php',
432
  'WPDesk_Flexible_Shipping_Cancel_Shipment_Exception' => $baseDir . '/classes/shipment/class-cancel-shipment-exception.php',
 
433
  'WPDesk_Flexible_Shipping_Export' => $baseDir . '/classes/flexible-shipping-export.php',
434
  'WPDesk_Flexible_Shipping_Get_Label_Exception' => $baseDir . '/classes/shipment/class-get-label-exception.php',
435
  'WPDesk_Flexible_Shipping_Label_Not_Available_Exception' => $baseDir . '/classes/shipment/class-label-not-available-exception.php',
@@ -446,6 +457,10 @@ return array(
446
  'WPDesk_Flexible_Shipping_SaaS_Auth_Platform_Factory' => $baseDir . '/classes/saas/class-saas-platform-factory.php',
447
  'WPDesk_Flexible_Shipping_SaaS_Bad_Credentials_Exception' => $baseDir . '/classes/saas/class-saas-bad-credentials-exception.php',
448
  'WPDesk_Flexible_Shipping_SaaS_Cache_Settings' => $baseDir . '/classes/saas/class-saas-cache-settings.php',
 
 
 
 
449
  'WPDesk_Flexible_Shipping_SaaS_Connection' => $baseDir . '/classes/saas/class-saas-connection.php',
450
  'WPDesk_Flexible_Shipping_SaaS_Connection_Status_Ajax' => $baseDir . '/classes/saas/class-saas-connection-status-ajax.php',
451
  'WPDesk_Flexible_Shipping_SaaS_Connection_Status_Field' => $baseDir . '/classes/saas/class-saas-connection-status-field.php',
@@ -469,8 +484,14 @@ return array(
469
  'WPDesk_Flexible_Shipping_SaaS_Shipment_Auto_Create' => $baseDir . '/classes/saas/class-saas-shipment-auto-create.php',
470
  'WPDesk_Flexible_Shipping_SaaS_Shipment_Order_Auto_Complete' => $baseDir . '/classes/saas/class-saas-shipment-order-auto-complete.php',
471
  'WPDesk_Flexible_Shipping_SaaS_Shipment_Settings_Field' => $baseDir . '/classes/saas/class-saas-shipment-settings-field.php',
 
 
 
 
 
472
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Method_Integration_Settings' => $baseDir . '/classes/saas/class-saas-shipping-method-integration-settings.php',
473
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Service' => $baseDir . '/classes/saas/class-saas-shipping-service.php',
 
474
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Settings' => $baseDir . '/classes/saas/class-saas-shipping-service-settings.php',
475
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Services' => $baseDir . '/classes/saas/class-saas-shipping-services.php',
476
  'WPDesk_Flexible_Shipping_SaaS_Tracker' => $baseDir . '/classes/saas/tracker/class-saas-tracker.php',
320
  'WPDesk\\SaasPlatformClient\\Model\\KeyInfo' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/KeyInfo.php',
321
  'WPDesk\\SaasPlatformClient\\Model\\Label\\Label' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/Label/Label.php',
322
  'WPDesk\\SaasPlatformClient\\Model\\LoginData' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/LoginData.php',
323
+ 'WPDesk\\SaasPlatformClient\\Model\\ParcelCollectionPoints\\ClientCollectionPoint' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/ClientCollectionPoint.php',
324
+ 'WPDesk\\SaasPlatformClient\\Model\\ParcelCollectionPoints\\ClientMapLocation' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/ClientMapLocation.php',
325
+ 'WPDesk\\SaasPlatformClient\\Model\\ParcelCollectionPoints\\SearchRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SearchRequest.php',
326
+ 'WPDesk\\SaasPlatformClient\\Model\\ParcelCollectionPoints\\SearchResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SearchResponse.php',
327
+ 'WPDesk\\SaasPlatformClient\\Model\\ParcelCollectionPoints\\SingleRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SingleRequest.php',
328
+ 'WPDesk\\SaasPlatformClient\\Model\\ParcelCollectionPoints\\SingleResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SingleResponse.php',
329
  'WPDesk\\SaasPlatformClient\\Model\\Rate\\RateRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/Rate/RateRequest.php',
330
  'WPDesk\\SaasPlatformClient\\Model\\Rate\\RateResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/Rate/RateResponse.php',
331
  'WPDesk\\SaasPlatformClient\\Model\\Rate\\SingleRate' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Model/Rate/SingleRate.php',
370
  'WPDesk\\SaasPlatformClient\\Request\\Cancel\\PostCancelRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/Cancel/PostCancelRequest.php',
371
  'WPDesk\\SaasPlatformClient\\Request\\Fields\\GetFieldsRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/Fields/GetFieldsRequest.php',
372
  'WPDesk\\SaasPlatformClient\\Request\\Label\\PostLabelRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/Label/PostLabelRequest.php',
373
+ 'WPDesk\\SaasPlatformClient\\Request\\ParcelCollectionPoints\\GetSingleRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/ParcelCollectionPoints/GetSingleRequest.php',
374
+ 'WPDesk\\SaasPlatformClient\\Request\\ParcelCollectionPoints\\PostSearchRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/ParcelCollectionPoints/PostSearchRequest.php',
375
  'WPDesk\\SaasPlatformClient\\Request\\Rate\\PostRateRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/Rate/PostRateRequest.php',
376
  'WPDesk\\SaasPlatformClient\\Request\\Request' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/Request.php',
377
  'WPDesk\\SaasPlatformClient\\Request\\Shipment\\GetUserListShipmentRequest' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Request/Shipment/GetUserListShipmentRequest.php',
399
  'WPDesk\\SaasPlatformClient\\Response\\Fields\\GetFieldsResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/Fields/GetFieldsResponse.php',
400
  'WPDesk\\SaasPlatformClient\\Response\\Label\\PostLabelResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/Label/PostLabelResponse.php',
401
  'WPDesk\\SaasPlatformClient\\Response\\Maintenance\\MaintenanceResponseContext' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/Maintenance/MaintenanceResponseContext.php',
402
+ 'WPDesk\\SaasPlatformClient\\Response\\ParcelCollectionPoints\\GetSingleResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/ParcelCollectionPoints/GetSingleResponse.php',
403
+ 'WPDesk\\SaasPlatformClient\\Response\\ParcelCollectionPoints\\PostSearchResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/ParcelCollectionPoints/PostSearchResponse.php',
404
  'WPDesk\\SaasPlatformClient\\Response\\ProtectedResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/ProtectedResponse.php',
405
  'WPDesk\\SaasPlatformClient\\Response\\Rate\\PostRateResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/Rate/PostRateResponse.php',
406
  'WPDesk\\SaasPlatformClient\\Response\\RawResponse' => $vendorDir . '/wpdesk/wp-saas-platform-client/src/Response/RawResponse.php',
440
  'WPDesk_Flexible_Shipping_Admin_Notices' => $baseDir . '/classes/admin-notices.php',
441
  'WPDesk_Flexible_Shipping_Bulk_Actions' => $baseDir . '/classes/bulk-actions.php',
442
  'WPDesk_Flexible_Shipping_Cancel_Shipment_Exception' => $baseDir . '/classes/shipment/class-cancel-shipment-exception.php',
443
+ 'WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data' => $baseDir . '/classes/checkout/class-checkout-ajax-request-data.php',
444
  'WPDesk_Flexible_Shipping_Export' => $baseDir . '/classes/flexible-shipping-export.php',
445
  'WPDesk_Flexible_Shipping_Get_Label_Exception' => $baseDir . '/classes/shipment/class-get-label-exception.php',
446
  'WPDesk_Flexible_Shipping_Label_Not_Available_Exception' => $baseDir . '/classes/shipment/class-label-not-available-exception.php',
457
  'WPDesk_Flexible_Shipping_SaaS_Auth_Platform_Factory' => $baseDir . '/classes/saas/class-saas-platform-factory.php',
458
  'WPDesk_Flexible_Shipping_SaaS_Bad_Credentials_Exception' => $baseDir . '/classes/saas/class-saas-bad-credentials-exception.php',
459
  'WPDesk_Flexible_Shipping_SaaS_Cache_Settings' => $baseDir . '/classes/saas/class-saas-cache-settings.php',
460
+ 'WPDesk_Flexible_Shipping_SaaS_Checkout_Field_Collection_Points' => $baseDir . '/classes/saas/checkout-fields/class-saas-checkout-field-collection-points.php',
461
+ 'WPDesk_Flexible_Shipping_SaaS_Collection_Points_Ajax' => $baseDir . '/classes/saas/collection-points/class-saas-collection-points-ajax.php',
462
+ 'WPDesk_Flexible_Shipping_SaaS_Collection_Points_Ajax_Request_Data' => $baseDir . '/classes/saas/collection-points/class-saas-collection-points-ajax-request-data.php',
463
+ 'WPDesk_Flexible_Shipping_SaaS_Collection_Points_Map_Loader' => $baseDir . '/classes/saas/collection-points/class-saas-collection-points-map.php',
464
  'WPDesk_Flexible_Shipping_SaaS_Connection' => $baseDir . '/classes/saas/class-saas-connection.php',
465
  'WPDesk_Flexible_Shipping_SaaS_Connection_Status_Ajax' => $baseDir . '/classes/saas/class-saas-connection-status-ajax.php',
466
  'WPDesk_Flexible_Shipping_SaaS_Connection_Status_Field' => $baseDir . '/classes/saas/class-saas-connection-status-field.php',
484
  'WPDesk_Flexible_Shipping_SaaS_Shipment_Auto_Create' => $baseDir . '/classes/saas/class-saas-shipment-auto-create.php',
485
  'WPDesk_Flexible_Shipping_SaaS_Shipment_Order_Auto_Complete' => $baseDir . '/classes/saas/class-saas-shipment-order-auto-complete.php',
486
  'WPDesk_Flexible_Shipping_SaaS_Shipment_Settings_Field' => $baseDir . '/classes/saas/class-saas-shipment-settings-field.php',
487
+ 'WPDesk_Flexible_Shipping_SaaS_Shipping_Checkout_Fields_Checkout' => $baseDir . '/classes/saas/checkout-fields/class-saas-checkout-fields-checkout.php',
488
+ 'WPDesk_Flexible_Shipping_SaaS_Shipping_Checkout_Fields_Shipment' => $baseDir . '/classes/saas/checkout-fields/class-saas-checkout-fields-shipment.php',
489
+ 'WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When' => $baseDir . '/classes/saas/checkout-fields/class-saas-field-visible-when.php',
490
+ 'WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When_Checkout' => $baseDir . '/classes/saas/checkout-fields/class-saas-field-visible-when-checkout.php',
491
+ 'WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When_Shipment' => $baseDir . '/classes/saas/checkout-fields/class-saas-field-visible-when-shipment.php',
492
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Method_Integration_Settings' => $baseDir . '/classes/saas/class-saas-shipping-method-integration-settings.php',
493
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Service' => $baseDir . '/classes/saas/class-saas-shipping-service.php',
494
+ 'WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points' => $baseDir . '/classes/saas/collection-points/class-saas-shipping-service-collection-points.php',
495
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Settings' => $baseDir . '/classes/saas/class-saas-shipping-service-settings.php',
496
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Services' => $baseDir . '/classes/saas/class-saas-shipping-services.php',
497
  'WPDesk_Flexible_Shipping_SaaS_Tracker' => $baseDir . '/classes/saas/tracker/class-saas-tracker.php',
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit152e6397a0e4a8b6775cf43096e6a469
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit152e6397a0e4a8b6775cf43096e6a469
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit152e6397a0e4a8b6775cf43096e6a469', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit152e6397a0e4a8b6775cf43096e6a469', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
- call_user_func(\Composer\Autoload\ComposerStaticInit152e6397a0e4a8b6775cf43096e6a469::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit152e6397a0e4a8b6775cf43096e6a469
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
- $includeFiles = Composer\Autoload\ComposerStaticInit152e6397a0e4a8b6775cf43096e6a469::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
- composerRequire152e6397a0e4a8b6775cf43096e6a469($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
- function composerRequire152e6397a0e4a8b6775cf43096e6a469($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit31450fef395a4f32c40a3045e54b4081
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit31450fef395a4f32c40a3045e54b4081', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit31450fef395a4f32c40a3045e54b4081', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit31450fef395a4f32c40a3045e54b4081::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
+ $includeFiles = Composer\Autoload\ComposerStaticInit31450fef395a4f32c40a3045e54b4081::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequire31450fef395a4f32c40a3045e54b4081($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
+ function composerRequire31450fef395a4f32c40a3045e54b4081($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInit152e6397a0e4a8b6775cf43096e6a469
8
  {
9
  public static $files = array (
10
  '46ae4ad8c3479aabff48f598a0e4b93f' => __DIR__ . '/..' . '/wpdesk/wp-mutex/src/WPDesk/functions.php',
@@ -409,6 +409,12 @@ class ComposerStaticInit152e6397a0e4a8b6775cf43096e6a469
409
  'WPDesk\\SaasPlatformClient\\Model\\KeyInfo' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/KeyInfo.php',
410
  'WPDesk\\SaasPlatformClient\\Model\\Label\\Label' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/Label/Label.php',
411
  'WPDesk\\SaasPlatformClient\\Model\\LoginData' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/LoginData.php',
 
 
 
 
 
 
412
  'WPDesk\\SaasPlatformClient\\Model\\Rate\\RateRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/Rate/RateRequest.php',
413
  'WPDesk\\SaasPlatformClient\\Model\\Rate\\RateResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/Rate/RateResponse.php',
414
  'WPDesk\\SaasPlatformClient\\Model\\Rate\\SingleRate' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/Rate/SingleRate.php',
@@ -453,6 +459,8 @@ class ComposerStaticInit152e6397a0e4a8b6775cf43096e6a469
453
  'WPDesk\\SaasPlatformClient\\Request\\Cancel\\PostCancelRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/Cancel/PostCancelRequest.php',
454
  'WPDesk\\SaasPlatformClient\\Request\\Fields\\GetFieldsRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/Fields/GetFieldsRequest.php',
455
  'WPDesk\\SaasPlatformClient\\Request\\Label\\PostLabelRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/Label/PostLabelRequest.php',
 
 
456
  'WPDesk\\SaasPlatformClient\\Request\\Rate\\PostRateRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/Rate/PostRateRequest.php',
457
  'WPDesk\\SaasPlatformClient\\Request\\Request' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/Request.php',
458
  'WPDesk\\SaasPlatformClient\\Request\\Shipment\\GetUserListShipmentRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/Shipment/GetUserListShipmentRequest.php',
@@ -480,6 +488,8 @@ class ComposerStaticInit152e6397a0e4a8b6775cf43096e6a469
480
  'WPDesk\\SaasPlatformClient\\Response\\Fields\\GetFieldsResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/Fields/GetFieldsResponse.php',
481
  'WPDesk\\SaasPlatformClient\\Response\\Label\\PostLabelResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/Label/PostLabelResponse.php',
482
  'WPDesk\\SaasPlatformClient\\Response\\Maintenance\\MaintenanceResponseContext' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/Maintenance/MaintenanceResponseContext.php',
 
 
483
  'WPDesk\\SaasPlatformClient\\Response\\ProtectedResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/ProtectedResponse.php',
484
  'WPDesk\\SaasPlatformClient\\Response\\Rate\\PostRateResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/Rate/PostRateResponse.php',
485
  'WPDesk\\SaasPlatformClient\\Response\\RawResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/RawResponse.php',
@@ -519,6 +529,7 @@ class ComposerStaticInit152e6397a0e4a8b6775cf43096e6a469
519
  'WPDesk_Flexible_Shipping_Admin_Notices' => __DIR__ . '/../..' . '/classes/admin-notices.php',
520
  'WPDesk_Flexible_Shipping_Bulk_Actions' => __DIR__ . '/../..' . '/classes/bulk-actions.php',
521
  'WPDesk_Flexible_Shipping_Cancel_Shipment_Exception' => __DIR__ . '/../..' . '/classes/shipment/class-cancel-shipment-exception.php',
 
522
  'WPDesk_Flexible_Shipping_Export' => __DIR__ . '/../..' . '/classes/flexible-shipping-export.php',
523
  'WPDesk_Flexible_Shipping_Get_Label_Exception' => __DIR__ . '/../..' . '/classes/shipment/class-get-label-exception.php',
524
  'WPDesk_Flexible_Shipping_Label_Not_Available_Exception' => __DIR__ . '/../..' . '/classes/shipment/class-label-not-available-exception.php',
@@ -535,6 +546,10 @@ class ComposerStaticInit152e6397a0e4a8b6775cf43096e6a469
535
  'WPDesk_Flexible_Shipping_SaaS_Auth_Platform_Factory' => __DIR__ . '/../..' . '/classes/saas/class-saas-platform-factory.php',
536
  'WPDesk_Flexible_Shipping_SaaS_Bad_Credentials_Exception' => __DIR__ . '/../..' . '/classes/saas/class-saas-bad-credentials-exception.php',
537
  'WPDesk_Flexible_Shipping_SaaS_Cache_Settings' => __DIR__ . '/../..' . '/classes/saas/class-saas-cache-settings.php',
 
 
 
 
538
  'WPDesk_Flexible_Shipping_SaaS_Connection' => __DIR__ . '/../..' . '/classes/saas/class-saas-connection.php',
539
  'WPDesk_Flexible_Shipping_SaaS_Connection_Status_Ajax' => __DIR__ . '/../..' . '/classes/saas/class-saas-connection-status-ajax.php',
540
  'WPDesk_Flexible_Shipping_SaaS_Connection_Status_Field' => __DIR__ . '/../..' . '/classes/saas/class-saas-connection-status-field.php',
@@ -558,8 +573,14 @@ class ComposerStaticInit152e6397a0e4a8b6775cf43096e6a469
558
  'WPDesk_Flexible_Shipping_SaaS_Shipment_Auto_Create' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipment-auto-create.php',
559
  'WPDesk_Flexible_Shipping_SaaS_Shipment_Order_Auto_Complete' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipment-order-auto-complete.php',
560
  'WPDesk_Flexible_Shipping_SaaS_Shipment_Settings_Field' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipment-settings-field.php',
 
 
 
 
 
561
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Method_Integration_Settings' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipping-method-integration-settings.php',
562
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Service' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipping-service.php',
 
563
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Settings' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipping-service-settings.php',
564
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Services' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipping-services.php',
565
  'WPDesk_Flexible_Shipping_SaaS_Tracker' => __DIR__ . '/../..' . '/classes/saas/tracker/class-saas-tracker.php',
@@ -620,9 +641,9 @@ class ComposerStaticInit152e6397a0e4a8b6775cf43096e6a469
620
  public static function getInitializer(ClassLoader $loader)
621
  {
622
  return \Closure::bind(function () use ($loader) {
623
- $loader->prefixLengthsPsr4 = ComposerStaticInit152e6397a0e4a8b6775cf43096e6a469::$prefixLengthsPsr4;
624
- $loader->prefixDirsPsr4 = ComposerStaticInit152e6397a0e4a8b6775cf43096e6a469::$prefixDirsPsr4;
625
- $loader->classMap = ComposerStaticInit152e6397a0e4a8b6775cf43096e6a469::$classMap;
626
 
627
  }, null, ClassLoader::class);
628
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit31450fef395a4f32c40a3045e54b4081
8
  {
9
  public static $files = array (
10
  '46ae4ad8c3479aabff48f598a0e4b93f' => __DIR__ . '/..' . '/wpdesk/wp-mutex/src/WPDesk/functions.php',
409
  'WPDesk\\SaasPlatformClient\\Model\\KeyInfo' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/KeyInfo.php',
410
  'WPDesk\\SaasPlatformClient\\Model\\Label\\Label' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/Label/Label.php',
411
  'WPDesk\\SaasPlatformClient\\Model\\LoginData' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/LoginData.php',
412
+ 'WPDesk\\SaasPlatformClient\\Model\\ParcelCollectionPoints\\ClientCollectionPoint' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/ClientCollectionPoint.php',
413
+ 'WPDesk\\SaasPlatformClient\\Model\\ParcelCollectionPoints\\ClientMapLocation' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/ClientMapLocation.php',
414
+ 'WPDesk\\SaasPlatformClient\\Model\\ParcelCollectionPoints\\SearchRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SearchRequest.php',
415
+ 'WPDesk\\SaasPlatformClient\\Model\\ParcelCollectionPoints\\SearchResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SearchResponse.php',
416
+ 'WPDesk\\SaasPlatformClient\\Model\\ParcelCollectionPoints\\SingleRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SingleRequest.php',
417
+ 'WPDesk\\SaasPlatformClient\\Model\\ParcelCollectionPoints\\SingleResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SingleResponse.php',
418
  'WPDesk\\SaasPlatformClient\\Model\\Rate\\RateRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/Rate/RateRequest.php',
419
  'WPDesk\\SaasPlatformClient\\Model\\Rate\\RateResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/Rate/RateResponse.php',
420
  'WPDesk\\SaasPlatformClient\\Model\\Rate\\SingleRate' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Model/Rate/SingleRate.php',
459
  'WPDesk\\SaasPlatformClient\\Request\\Cancel\\PostCancelRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/Cancel/PostCancelRequest.php',
460
  'WPDesk\\SaasPlatformClient\\Request\\Fields\\GetFieldsRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/Fields/GetFieldsRequest.php',
461
  'WPDesk\\SaasPlatformClient\\Request\\Label\\PostLabelRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/Label/PostLabelRequest.php',
462
+ 'WPDesk\\SaasPlatformClient\\Request\\ParcelCollectionPoints\\GetSingleRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/ParcelCollectionPoints/GetSingleRequest.php',
463
+ 'WPDesk\\SaasPlatformClient\\Request\\ParcelCollectionPoints\\PostSearchRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/ParcelCollectionPoints/PostSearchRequest.php',
464
  'WPDesk\\SaasPlatformClient\\Request\\Rate\\PostRateRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/Rate/PostRateRequest.php',
465
  'WPDesk\\SaasPlatformClient\\Request\\Request' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/Request.php',
466
  'WPDesk\\SaasPlatformClient\\Request\\Shipment\\GetUserListShipmentRequest' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Request/Shipment/GetUserListShipmentRequest.php',
488
  'WPDesk\\SaasPlatformClient\\Response\\Fields\\GetFieldsResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/Fields/GetFieldsResponse.php',
489
  'WPDesk\\SaasPlatformClient\\Response\\Label\\PostLabelResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/Label/PostLabelResponse.php',
490
  'WPDesk\\SaasPlatformClient\\Response\\Maintenance\\MaintenanceResponseContext' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/Maintenance/MaintenanceResponseContext.php',
491
+ 'WPDesk\\SaasPlatformClient\\Response\\ParcelCollectionPoints\\GetSingleResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/ParcelCollectionPoints/GetSingleResponse.php',
492
+ 'WPDesk\\SaasPlatformClient\\Response\\ParcelCollectionPoints\\PostSearchResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/ParcelCollectionPoints/PostSearchResponse.php',
493
  'WPDesk\\SaasPlatformClient\\Response\\ProtectedResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/ProtectedResponse.php',
494
  'WPDesk\\SaasPlatformClient\\Response\\Rate\\PostRateResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/Rate/PostRateResponse.php',
495
  'WPDesk\\SaasPlatformClient\\Response\\RawResponse' => __DIR__ . '/..' . '/wpdesk/wp-saas-platform-client/src/Response/RawResponse.php',
529
  'WPDesk_Flexible_Shipping_Admin_Notices' => __DIR__ . '/../..' . '/classes/admin-notices.php',
530
  'WPDesk_Flexible_Shipping_Bulk_Actions' => __DIR__ . '/../..' . '/classes/bulk-actions.php',
531
  'WPDesk_Flexible_Shipping_Cancel_Shipment_Exception' => __DIR__ . '/../..' . '/classes/shipment/class-cancel-shipment-exception.php',
532
+ 'WPDesk_Flexible_Shipping_Checkout_Ajax_Request_Data' => __DIR__ . '/../..' . '/classes/checkout/class-checkout-ajax-request-data.php',
533
  'WPDesk_Flexible_Shipping_Export' => __DIR__ . '/../..' . '/classes/flexible-shipping-export.php',
534
  'WPDesk_Flexible_Shipping_Get_Label_Exception' => __DIR__ . '/../..' . '/classes/shipment/class-get-label-exception.php',
535
  'WPDesk_Flexible_Shipping_Label_Not_Available_Exception' => __DIR__ . '/../..' . '/classes/shipment/class-label-not-available-exception.php',
546
  'WPDesk_Flexible_Shipping_SaaS_Auth_Platform_Factory' => __DIR__ . '/../..' . '/classes/saas/class-saas-platform-factory.php',
547
  'WPDesk_Flexible_Shipping_SaaS_Bad_Credentials_Exception' => __DIR__ . '/../..' . '/classes/saas/class-saas-bad-credentials-exception.php',
548
  'WPDesk_Flexible_Shipping_SaaS_Cache_Settings' => __DIR__ . '/../..' . '/classes/saas/class-saas-cache-settings.php',
549
+ 'WPDesk_Flexible_Shipping_SaaS_Checkout_Field_Collection_Points' => __DIR__ . '/../..' . '/classes/saas/checkout-fields/class-saas-checkout-field-collection-points.php',
550
+ 'WPDesk_Flexible_Shipping_SaaS_Collection_Points_Ajax' => __DIR__ . '/../..' . '/classes/saas/collection-points/class-saas-collection-points-ajax.php',
551
+ 'WPDesk_Flexible_Shipping_SaaS_Collection_Points_Ajax_Request_Data' => __DIR__ . '/../..' . '/classes/saas/collection-points/class-saas-collection-points-ajax-request-data.php',
552
+ 'WPDesk_Flexible_Shipping_SaaS_Collection_Points_Map_Loader' => __DIR__ . '/../..' . '/classes/saas/collection-points/class-saas-collection-points-map.php',
553
  'WPDesk_Flexible_Shipping_SaaS_Connection' => __DIR__ . '/../..' . '/classes/saas/class-saas-connection.php',
554
  'WPDesk_Flexible_Shipping_SaaS_Connection_Status_Ajax' => __DIR__ . '/../..' . '/classes/saas/class-saas-connection-status-ajax.php',
555
  'WPDesk_Flexible_Shipping_SaaS_Connection_Status_Field' => __DIR__ . '/../..' . '/classes/saas/class-saas-connection-status-field.php',
573
  'WPDesk_Flexible_Shipping_SaaS_Shipment_Auto_Create' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipment-auto-create.php',
574
  'WPDesk_Flexible_Shipping_SaaS_Shipment_Order_Auto_Complete' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipment-order-auto-complete.php',
575
  'WPDesk_Flexible_Shipping_SaaS_Shipment_Settings_Field' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipment-settings-field.php',
576
+ 'WPDesk_Flexible_Shipping_SaaS_Shipping_Checkout_Fields_Checkout' => __DIR__ . '/../..' . '/classes/saas/checkout-fields/class-saas-checkout-fields-checkout.php',
577
+ 'WPDesk_Flexible_Shipping_SaaS_Shipping_Checkout_Fields_Shipment' => __DIR__ . '/../..' . '/classes/saas/checkout-fields/class-saas-checkout-fields-shipment.php',
578
+ 'WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When' => __DIR__ . '/../..' . '/classes/saas/checkout-fields/class-saas-field-visible-when.php',
579
+ 'WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When_Checkout' => __DIR__ . '/../..' . '/classes/saas/checkout-fields/class-saas-field-visible-when-checkout.php',
580
+ 'WPDesk_Flexible_Shipping_SaaS_Shipping_Field_Visible_When_Shipment' => __DIR__ . '/../..' . '/classes/saas/checkout-fields/class-saas-field-visible-when-shipment.php',
581
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Method_Integration_Settings' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipping-method-integration-settings.php',
582
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Service' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipping-service.php',
583
+ 'WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Collection_Points' => __DIR__ . '/../..' . '/classes/saas/collection-points/class-saas-shipping-service-collection-points.php',
584
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Service_Settings' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipping-service-settings.php',
585
  'WPDesk_Flexible_Shipping_SaaS_Shipping_Services' => __DIR__ . '/../..' . '/classes/saas/class-saas-shipping-services.php',
586
  'WPDesk_Flexible_Shipping_SaaS_Tracker' => __DIR__ . '/../..' . '/classes/saas/tracker/class-saas-tracker.php',
641
  public static function getInitializer(ClassLoader $loader)
642
  {
643
  return \Closure::bind(function () use ($loader) {
644
+ $loader->prefixLengthsPsr4 = ComposerStaticInit31450fef395a4f32c40a3045e54b4081::$prefixLengthsPsr4;
645
+ $loader->prefixDirsPsr4 = ComposerStaticInit31450fef395a4f32c40a3045e54b4081::$prefixDirsPsr4;
646
+ $loader->classMap = ComposerStaticInit31450fef395a4f32c40a3045e54b4081::$classMap;
647
 
648
  }, null, ClassLoader::class);
649
  }
vendor/composer/installed.json CHANGED
@@ -744,17 +744,17 @@
744
  },
745
  {
746
  "name": "wpdesk/wp-saas-platform-client",
747
- "version": "1.8.3",
748
- "version_normalized": "1.8.3.0",
749
  "source": {
750
  "type": "git",
751
  "url": "https://gitlab.com/wpdesk/wp-saas-platform-client.git",
752
- "reference": "57600a1f54f148a4b85c3484e8cd399175012d6a"
753
  },
754
  "dist": {
755
  "type": "zip",
756
- "url": "https://gitlab.com/api/v4/projects/wpdesk%2Fwp-saas-platform-client/repository/archive.zip?sha=57600a1f54f148a4b85c3484e8cd399175012d6a",
757
- "reference": "57600a1f54f148a4b85c3484e8cd399175012d6a",
758
  "shasum": ""
759
  },
760
  "require": {
@@ -772,7 +772,7 @@
772
  "squizlabs/php_codesniffer": "^3.0.2",
773
  "wp-coding-standards/wpcs": "^0.14.1"
774
  },
775
- "time": "2019-02-12T08:41:18+00:00",
776
  "type": "library",
777
  "installation-source": "dist",
778
  "autoload": {
744
  },
745
  {
746
  "name": "wpdesk/wp-saas-platform-client",
747
+ "version": "1.9.1",
748
+ "version_normalized": "1.9.1.0",
749
  "source": {
750
  "type": "git",
751
  "url": "https://gitlab.com/wpdesk/wp-saas-platform-client.git",
752
+ "reference": "7da866aac957b49e8099b53a86831ef1ace4175f"
753
  },
754
  "dist": {
755
  "type": "zip",
756
+ "url": "https://gitlab.com/api/v4/projects/wpdesk%2Fwp-saas-platform-client/repository/archive.zip?sha=7da866aac957b49e8099b53a86831ef1ace4175f",
757
+ "reference": "7da866aac957b49e8099b53a86831ef1ace4175f",
758
  "shasum": ""
759
  },
760
  "require": {
772
  "squizlabs/php_codesniffer": "^3.0.2",
773
  "wp-coding-standards/wpcs": "^0.14.1"
774
  },
775
+ "time": "2019-03-07T06:43:15+00:00",
776
  "type": "library",
777
  "installation-source": "dist",
778
  "autoload": {
vendor/wpdesk/wp-saas-platform-client/changelog.txt CHANGED
@@ -1,3 +1,9 @@
 
 
 
 
 
 
1
  = 1.8.0 - 2019-02-11 =
2
  * Customs values
3
 
1
+ = 1.9.1 - 2019-03-05 =
2
+ * Added email to actor
3
+
4
+ = 1.9.0 - 2019-03-05 =
5
+ * Added collection points
6
+
7
  = 1.8.0 - 2019-02-11 =
8
  * Customs values
9
 
vendor/wpdesk/wp-saas-platform-client/src/ApiClient/ClientImplementation.php CHANGED
@@ -15,7 +15,7 @@ use WPDesk\SaasPlatformClient\HttpClient\HttpClientRequestException;
15
 
16
  class ClientImplementation implements Client, LoggerAwareInterface
17
  {
18
- const CLIENT_VERSION = '1.8';
19
 
20
  const DEFAULT_TIMEOUT = 10;
21
 
15
 
16
  class ClientImplementation implements Client, LoggerAwareInterface
17
  {
18
+ const CLIENT_VERSION = '1.9.1';
19
 
20
  const DEFAULT_TIMEOUT = 10;
21
 
vendor/wpdesk/wp-saas-platform-client/src/ApiClient/RequestCacheInfoResolver.php CHANGED
@@ -4,13 +4,12 @@ namespace WPDesk\SaasPlatformClient\ApiClient;
4
 
5
  use WPDesk\SaasPlatformClient\Cache\CacheInfoResolver;
6
  use WPDesk\SaasPlatformClient\Cache\HowToCache;
7
- use WPDesk\SaasPlatformClient\Request\AuthRequest;
8
  use WPDesk\SaasPlatformClient\Request\BasicRequest;
9
  use WPDesk\SaasPlatformClient\Request\Request;
10
  use WPDesk\SaasPlatformClient\Request\ShippingServicesSettings\PutSettingsRequest;
11
  use WPDesk\SaasPlatformClient\Request\Status\GetStatusRequest;
12
  use WPDesk\SaasPlatformClient\Response\ApiResponse;
13
- use WPDesk\SaasPlatformClient\Response\RawResponse;
14
 
15
  class RequestCacheInfoResolver implements CacheInfoResolver
16
  {
4
 
5
  use WPDesk\SaasPlatformClient\Cache\CacheInfoResolver;
6
  use WPDesk\SaasPlatformClient\Cache\HowToCache;
7
+ use WPDesk\SaasPlatformClient\Request\Authentication\ConnectKeyInfoRequest;
8
  use WPDesk\SaasPlatformClient\Request\BasicRequest;
9
  use WPDesk\SaasPlatformClient\Request\Request;
10
  use WPDesk\SaasPlatformClient\Request\ShippingServicesSettings\PutSettingsRequest;
11
  use WPDesk\SaasPlatformClient\Request\Status\GetStatusRequest;
12
  use WPDesk\SaasPlatformClient\Response\ApiResponse;
 
13
 
14
  class RequestCacheInfoResolver implements CacheInfoResolver
15
  {
vendor/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/ClientCollectionPoint.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints;
4
+
5
+ use WPDesk\SaasPlatformClient\Model\AbstractModel;
6
+ use WPDesk\SaasPlatformClient\Model\Shipment\Address;
7
+
8
+ class ClientCollectionPoint extends AbstractModel
9
+ {
10
+
11
+ /**
12
+ * @var string
13
+ */
14
+ public $id;
15
+
16
+ /**
17
+ * @var string
18
+ */
19
+ public $name;
20
+
21
+ /**
22
+ * @var string
23
+ */
24
+ public $description;
25
+
26
+ /**
27
+ * @var Address
28
+ */
29
+ public $address;
30
+
31
+ /**
32
+ * @var ClientMapLocation
33
+ */
34
+ public $mapLocation;
35
+
36
+ /**
37
+ * ClientCollectionPoint constructor.
38
+ *
39
+ * @param array|null $data
40
+ */
41
+ public function __construct(array $data = null)
42
+ {
43
+ $this->address = new Address();
44
+ $this->mapLocation = new ClientMapLocation();
45
+
46
+ parent::__construct($data);
47
+ }
48
+
49
+ /**
50
+ * @return string
51
+ */
52
+ public function getId()
53
+ {
54
+ return $this->id;
55
+ }
56
+
57
+ /**
58
+ * @return string
59
+ */
60
+ public function getName()
61
+ {
62
+ return $this->name;
63
+ }
64
+
65
+ /**
66
+ * @return string
67
+ */
68
+ public function getDescription()
69
+ {
70
+ return $this->description;
71
+ }
72
+
73
+ /**
74
+ * @return Address
75
+ */
76
+ public function getAddress()
77
+ {
78
+ return $this->address;
79
+ }
80
+
81
+ /**
82
+ * @return ClientMapLocation
83
+ */
84
+ public function getMapLocation()
85
+ {
86
+ return $this->mapLocation;
87
+ }
88
+
89
+ }
vendor/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/ClientMapLocation.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints;
4
+
5
+ class ClientMapLocation
6
+ {
7
+
8
+ /**
9
+ * Latitude
10
+ *
11
+ * @var string
12
+ */
13
+ public $lat;
14
+
15
+ /**
16
+ * Longitude
17
+ *
18
+ * @var string
19
+ */
20
+ public $lng;
21
+
22
+ /**
23
+ * @return string
24
+ */
25
+ public function getLat()
26
+ {
27
+ return $this->lat;
28
+ }
29
+
30
+ /**
31
+ * @return string
32
+ */
33
+ public function getLng()
34
+ {
35
+ return $this->lng;
36
+ }
37
+
38
+ }
vendor/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SearchRequest.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints;
4
+
5
+ use WPDesk\SaasPlatformClient\Model\AbstractModel;
6
+ use WPDesk\SaasPlatformClient\Model\Shipment\Address;
7
+
8
+ class SearchRequest extends AbstractModel
9
+ {
10
+
11
+ /**
12
+ * @var Address
13
+ */
14
+ public $address;
15
+
16
+ /**
17
+ * @var string
18
+ */
19
+ public $serviceType;
20
+
21
+ /**
22
+ * How close to address should search for AP in KM
23
+ *
24
+ * @var int
25
+ */
26
+ public $radius;
27
+
28
+ /**
29
+ * @param Address $address
30
+ */
31
+ public function setAddress($address)
32
+ {
33
+ $this->address = $address;
34
+ }
35
+
36
+ /**
37
+ * @param string $serviceType
38
+ */
39
+ public function setServiceType($serviceType)
40
+ {
41
+ $this->serviceType = $serviceType;
42
+ }
43
+
44
+ /**
45
+ * @param int $radius
46
+ */
47
+ public function setRadius($radius)
48
+ {
49
+ $this->radius = $radius;
50
+ }
51
+
52
+ }
vendor/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SearchResponse.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints;
4
+
5
+ use WPDesk\SaasPlatformClient\Model\AbstractModel;
6
+
7
+ class SearchResponse extends AbstractModel
8
+ {
9
+
10
+ /**
11
+ * @var ClientCollectionPoint[]
12
+ */
13
+ public $points = [];
14
+
15
+ /** @var array */
16
+ public $messageStack = [];
17
+
18
+ /**
19
+ * From array.
20
+ *
21
+ * @param array $data Data.
22
+ */
23
+ public function fromArray(array $data)
24
+ {
25
+ if ($data['points'] && count($data['points']) > 0) {
26
+ foreach ($data['points'] as $point) {
27
+ $this->points[] = new ClientCollectionPoint($point);
28
+ }
29
+ }
30
+ if (isset($data['messageStack'])) {
31
+ $this->messageStack = $data['messageStack'];
32
+ }
33
+ }
34
+ }
vendor/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SingleRequest.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints;
4
+
5
+ use WPDesk\SaasPlatformClient\Model\AbstractModel;
6
+
7
+ class SingleRequest extends AbstractModel
8
+ {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ public $id;
14
+
15
+ /**
16
+ * @param string $id
17
+ */
18
+ public function setId($id)
19
+ {
20
+ $this->id = $id;
21
+ }
22
+
23
+ }
vendor/wpdesk/wp-saas-platform-client/src/Model/ParcelCollectionPoints/SingleResponse.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints;
4
+
5
+ use WPDesk\SaasPlatformClient\Model\AbstractModel;
6
+
7
+ class SingleResponse extends AbstractModel
8
+ {
9
+
10
+ /**
11
+ * @var ClientCollectionPoint
12
+ */
13
+ public $point;
14
+
15
+ /** @var array */
16
+ public $messageStack = [];
17
+
18
+
19
+ /**
20
+ * From array.
21
+ *
22
+ * @param array $data Data.
23
+ */
24
+ public function fromArray(array $data)
25
+ {
26
+ if (isset($data['point'])) {
27
+ $this->point = new ClientCollectionPoint($data['point']);
28
+ }
29
+ if (isset($data['messageStack'])) {
30
+ $this->messageStack = $data['messageStack'];
31
+ }
32
+ }
33
+
34
+ }
vendor/wpdesk/wp-saas-platform-client/src/Model/Rate/RateRequest.php CHANGED
@@ -6,4 +6,5 @@ use WPDesk\SaasPlatformClient\Model\Shipment\ShipmentRequest;
6
 
7
  class RateRequest extends ShipmentRequest
8
  {
 
9
  }
6
 
7
  class RateRequest extends ShipmentRequest
8
  {
9
+
10
  }
vendor/wpdesk/wp-saas-platform-client/src/Model/Shipment/Actor.php CHANGED
@@ -31,6 +31,11 @@ class Actor extends AbstractModel
31
  */
32
  protected $phoneNumber;
33
 
 
 
 
 
 
34
  /**
35
  * @param Address $address
36
  */
@@ -62,4 +67,13 @@ class Actor extends AbstractModel
62
  {
63
  $this->phoneNumber = $phoneNumber;
64
  }
 
 
 
 
 
 
 
 
 
65
  }
31
  */
32
  protected $phoneNumber;
33
 
34
+ /**
35
+ * @var string
36
+ */
37
+ protected $email;
38
+
39
  /**
40
  * @param Address $address
41
  */
67
  {
68
  $this->phoneNumber = $phoneNumber;
69
  }
70
+
71
+ /**
72
+ * @param string $email
73
+ */
74
+ public function setEmail($email)
75
+ {
76
+ $this->email = $email;
77
+ }
78
+
79
  }
vendor/wpdesk/wp-saas-platform-client/src/Model/Shipment/Address.php CHANGED
@@ -13,36 +13,84 @@ class Address extends AbstractModel
13
  *
14
  * @var string
15
  */
16
- protected $addressLine1;
17
 
18
  /** @var string */
19
- protected $addressLine2;
20
 
21
  /**
22
  * @Constraints\NotBlank
23
  *
24
  * @var string
25
  */
26
- protected $postalCode;
27
 
28
  /**
29
  * @Constraints\NotBlank
30
  *
31
  * @var string
32
  */
33
- protected $city;
34
 
35
  /**
36
  * @var string
37
  */
38
- protected $stateCode;
39
 
40
  /**
41
  * @Constraints\NotBlank
42
  *
43
  * @var string
44
  */
45
- protected $countryCode;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  /**
48
  * @param string $addressLine1
13
  *
14
  * @var string
15
  */
16
+ public $addressLine1;
17
 
18
  /** @var string */
19
+ public $addressLine2;
20
 
21
  /**
22
  * @Constraints\NotBlank
23
  *
24
  * @var string
25
  */
26
+ public $postalCode;
27
 
28
  /**
29
  * @Constraints\NotBlank
30
  *
31
  * @var string
32
  */
33
+ public $city;
34
 
35
  /**
36
  * @var string
37
  */
38
+ public $stateCode;
39
 
40
  /**
41
  * @Constraints\NotBlank
42
  *
43
  * @var string
44
  */
45
+ public $countryCode;
46
+
47
+ /**
48
+ * @return string
49
+ */
50
+ public function getAddressLine1()
51
+ {
52
+ return $this->addressLine1;
53
+ }
54
+
55
+ /**
56
+ * @return string
57
+ */
58
+ public function getAddressLine2()
59
+ {
60
+ return $this->addressLine2;
61
+ }
62
+
63
+ /**
64
+ * @return string
65
+ */
66
+ public function getPostalCode()
67
+ {
68
+ return $this->postalCode;
69
+ }
70
+
71
+ /**
72
+ * @return string
73
+ */
74
+ public function getCity()
75
+ {
76
+ return $this->city;
77
+ }
78
+
79
+ /**
80
+ * @return string
81
+ */
82
+ public function getStateCode()
83
+ {
84
+ return $this->stateCode;
85
+ }
86
+
87
+ /**
88
+ * @return string
89
+ */
90
+ public function getCountryCode()
91
+ {
92
+ return $this->countryCode;
93
+ }
94
 
95
  /**
96
  * @param string $addressLine1
vendor/wpdesk/wp-saas-platform-client/src/Model/Shipment/ShipmentRequest.php CHANGED
@@ -64,6 +64,13 @@ class ShipmentRequest extends AbstractModel
64
  */
65
  protected $shopFlow;
66
 
 
 
 
 
 
 
 
67
  /**
68
  * @param \WPDesk\SaasPlatformClient\Model\Shipment\Actor $shipTo
69
  */
@@ -168,4 +175,21 @@ class ShipmentRequest extends AbstractModel
168
  $this->shopFlow = $shopFlow;
169
  }
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  }
64
  */
65
  protected $shopFlow;
66
 
67
+ /**
68
+ * Id of selected collection point
69
+ *
70
+ * @var string
71
+ */
72
+ protected $collectionPointId;
73
+
74
  /**
75
  * @param \WPDesk\SaasPlatformClient\Model\Shipment\Actor $shipTo
76
  */
175
  $this->shopFlow = $shopFlow;
176
  }
177
 
178
+ /**
179
+ * @return string
180
+ */
181
+ public function getCollectionPointId()
182
+ {
183
+ return $this->collectionPointId;
184
+ }
185
+
186
+ /**
187
+ * @param string $collectionPointId
188
+ */
189
+ public function setCollectionPointId($collectionPointId)
190
+ {
191
+ $this->collectionPointId = $collectionPointId;
192
+ }
193
+
194
+
195
  }
vendor/wpdesk/wp-saas-platform-client/src/Platform.php CHANGED
@@ -10,6 +10,10 @@ use WPDesk\SaasPlatformClient\Authentication\JWTSaasToken;
10
  use WPDesk\SaasPlatformClient\Authentication\NullToken;
11
  use WPDesk\SaasPlatformClient\Authentication\Token;
12
  use WPDesk\SaasPlatformClient\ApiClient\Client;
 
 
 
 
13
  use WPDesk\SaasPlatformClient\Model\Rate\RateRequest;
14
  use WPDesk\SaasPlatformClient\Model\Shipment\ShipmentRequest;
15
  use WPDesk\SaasPlatformClient\Model\ShippingServiceSetting;
@@ -18,6 +22,8 @@ use WPDesk\SaasPlatformClient\Request\AuthRequest;
18
  use WPDesk\SaasPlatformClient\Request\Cancel\PostCancelRequest;
19
  use WPDesk\SaasPlatformClient\Request\Fields\GetFieldsRequest;
20
  use WPDesk\SaasPlatformClient\Request\Label\PostLabelRequest;
 
 
21
  use WPDesk\SaasPlatformClient\Request\Rate\PostRateRequest;
22
  use WPDesk\SaasPlatformClient\Request\ShippingServices\GetListRequest;
23
  use WPDesk\SaasPlatformClient\Request\ShippingServices\GetServiceRequest;
@@ -33,6 +39,8 @@ use WPDesk\SaasPlatformClient\Response\Authentication\RegisterResponse;
33
  use WPDesk\SaasPlatformClient\Request\Authentication\TokenRequest;
34
  use WPDesk\SaasPlatformClient\Response\Fields\GetFieldsResponse;
35
  use WPDesk\SaasPlatformClient\Response\Label\PostLabelResponse;
 
 
36
  use WPDesk\SaasPlatformClient\Response\ProtectedResponse;
37
  use WPDesk\SaasPlatformClient\Response\Response;
38
  use WPDesk\SaasPlatformClient\Response\Cancel\PostCancelResponse;
@@ -196,6 +204,55 @@ class Platform implements LoggerAwareInterface
196
  return new PostRateResponse(new ProtectedResponse($response));
197
  }
198
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  /**
200
  * Get label. Request is POST because it can - and probably would change the shipment state in remote service
201
  *
10
  use WPDesk\SaasPlatformClient\Authentication\NullToken;
11
  use WPDesk\SaasPlatformClient\Authentication\Token;
12
  use WPDesk\SaasPlatformClient\ApiClient\Client;
13
+ use WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints\SearchRequest;
14
+ use WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints\SearchResponse;
15
+ use WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints\SingleRequest;
16
+ use WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints\SingleResponse;
17
  use WPDesk\SaasPlatformClient\Model\Rate\RateRequest;
18
  use WPDesk\SaasPlatformClient\Model\Shipment\ShipmentRequest;
19
  use WPDesk\SaasPlatformClient\Model\ShippingServiceSetting;
22
  use WPDesk\SaasPlatformClient\Request\Cancel\PostCancelRequest;
23
  use WPDesk\SaasPlatformClient\Request\Fields\GetFieldsRequest;
24
  use WPDesk\SaasPlatformClient\Request\Label\PostLabelRequest;
25
+ use WPDesk\SaasPlatformClient\Request\ParcelCollectionPoints\GetSingleRequest;
26
+ use WPDesk\SaasPlatformClient\Request\ParcelCollectionPoints\PostSearchRequest;
27
  use WPDesk\SaasPlatformClient\Request\Rate\PostRateRequest;
28
  use WPDesk\SaasPlatformClient\Request\ShippingServices\GetListRequest;
29
  use WPDesk\SaasPlatformClient\Request\ShippingServices\GetServiceRequest;
39
  use WPDesk\SaasPlatformClient\Request\Authentication\TokenRequest;
40
  use WPDesk\SaasPlatformClient\Response\Fields\GetFieldsResponse;
41
  use WPDesk\SaasPlatformClient\Response\Label\PostLabelResponse;
42
+ use WPDesk\SaasPlatformClient\Response\ParcelCollectionPoints\GetSingleResponse;
43
+ use WPDesk\SaasPlatformClient\Response\ParcelCollectionPoints\PostSearchResponse;
44
  use WPDesk\SaasPlatformClient\Response\ProtectedResponse;
45
  use WPDesk\SaasPlatformClient\Response\Response;
46
  use WPDesk\SaasPlatformClient\Response\Cancel\PostCancelResponse;
204
  return new PostRateResponse(new ProtectedResponse($response));
205
  }
206
 
207
+ /**
208
+ * Search Parcel Collection Points
209
+ *
210
+ * @param SearchRequest $searchParcelCollectionPointsRequest
211
+ * @param int $serviceId
212
+ * @return PostSearchResponse
213
+ */
214
+ public function requestPostSearchParcelCollectionPoints(
215
+ SearchRequest $searchParcelCollectionPointsRequest,
216
+ $serviceId
217
+ ) {
218
+ $saasToken = new JWTSaasToken($this->getToken());
219
+
220
+ $postRateRequest = new PostSearchRequest(
221
+ $this->getToken(),
222
+ $serviceId,
223
+ $saasToken->getShopId(),
224
+ $searchParcelCollectionPointsRequest
225
+ );
226
+ $response = $this->sendRequestWithInvalidTokenHandling($postRateRequest);
227
+
228
+ /** @noinspection PhpMethodParametersCountMismatchInspection PHPStorm bug with wrapped traits */
229
+ return new PostSearchResponse(new ProtectedResponse($response));
230
+ }
231
+
232
+ /**
233
+ * Get single collection point
234
+ *
235
+ * @param SingleRequest $singleRequest
236
+ * @param int $shippingServiceId
237
+ * @return GetSingleResponse
238
+ */
239
+ public function requestGetSingleCollectionPoint(
240
+ SingleRequest $singleRequest,
241
+ $shippingServiceId
242
+ ) {
243
+ $saasToken = new JWTSaasToken($this->getToken());
244
+
245
+ $getSingleRequest = new GetSingleRequest(
246
+ $saasToken,
247
+ $shippingServiceId,
248
+ $saasToken->getShopId(),
249
+ $singleRequest->id
250
+ );
251
+ $response = $this->sendRequestWithInvalidTokenHandling($getSingleRequest);
252
+ /** @noinspection PhpMethodParametersCountMismatchInspection PHPStorm bug with wrapped traits */
253
+ return new GetSingleResponse(new ProtectedResponse($response));
254
+ }
255
+
256
  /**
257
  * Get label. Request is POST because it can - and probably would change the shipment state in remote service
258
  *
vendor/wpdesk/wp-saas-platform-client/src/Request/ParcelCollectionPoints/GetSingleRequest.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPDesk\SaasPlatformClient\Request\ParcelCollectionPoints;
4
+
5
+ use WPDesk\SaasPlatformClient\Authentication\Token;
6
+ use WPDesk\SaasPlatformClient\Request\AuthRequest;
7
+
8
+ final class GetSingleRequest extends AuthRequest
9
+ {
10
+ /** @var string */
11
+ protected $method = 'GET';
12
+
13
+ /** @var string */
14
+ protected $endPoint = '/shops/{shop}/shipping_services/{service}/ap/{id}';
15
+
16
+ const ZONE_TARGETS_DELIMITER = ',';
17
+
18
+
19
+ public function __construct(
20
+ Token $token,
21
+ $shippingServiceId,
22
+ $shopId,
23
+ $collectionPointId
24
+ ) {
25
+ parent::__construct($token);
26
+
27
+ $this->endPoint = str_replace(
28
+ ['{shop}', '{service}', '{id}'],
29
+ [$shopId, $shippingServiceId, $collectionPointId],
30
+ $this->endPoint
31
+ );
32
+ }
33
+ }
vendor/wpdesk/wp-saas-platform-client/src/Request/ParcelCollectionPoints/PostSearchRequest.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPDesk\SaasPlatformClient\Request\ParcelCollectionPoints;
4
+
5
+ use WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints\SearchRequest;
6
+ use WPDesk\SaasPlatformClient\Authentication\Token;
7
+ use WPDesk\SaasPlatformClient\Request\AuthRequest;
8
+
9
+ final class PostSearchRequest extends AuthRequest
10
+ {
11
+
12
+ /** @var string */
13
+ protected $method = 'POST';
14
+
15
+ /** @var string */
16
+ protected $endPoint = '/shops/{shop}/shipping_services/{service}/ap';
17
+
18
+ /**
19
+ * PostRateRequest constructor.
20
+ * @param Token $token
21
+ * @param int $shippingServiceId
22
+ * @param int $shopId
23
+ * @param SearchRequest $request
24
+ */
25
+ public function __construct(
26
+ Token $token,
27
+ $shippingServiceId,
28
+ $shopId,
29
+ SearchRequest $request
30
+ ) {
31
+ parent::__construct($token);
32
+
33
+ $this->endPoint = str_replace(['{shop}', '{service}'], [$shopId, $shippingServiceId], $this->endPoint);
34
+
35
+ $this->data = $request->toArray();
36
+ }
37
+
38
+ }
vendor/wpdesk/wp-saas-platform-client/src/Response/ParcelCollectionPoints/GetSingleResponse.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPDesk\SaasPlatformClient\Response\ParcelCollectionPoints;
4
+
5
+ use WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints\SingleResponse;
6
+ use WPDesk\SaasPlatformClient\Response\ApiResponse;
7
+ use WPDesk\SaasPlatformClient\Response\Traits\AuthApiResponseDecorator;
8
+
9
+ final class GetSingleResponse implements ApiResponse
10
+ {
11
+
12
+ use AuthApiResponseDecorator;
13
+
14
+ /**
15
+ * @return SingleResponse
16
+ */
17
+ public function getSingleResponse()
18
+ {
19
+ return new SingleResponse($this->getResponseBody());
20
+ }
21
+
22
+
23
+ }
vendor/wpdesk/wp-saas-platform-client/src/Response/ParcelCollectionPoints/PostSearchResponse.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPDesk\SaasPlatformClient\Response\ParcelCollectionPoints;
4
+
5
+ use WPDesk\SaasPlatformClient\Model\ParcelCollectionPoints\SearchResponse;
6
+ use WPDesk\SaasPlatformClient\Response\ApiResponse;
7
+ use WPDesk\SaasPlatformClient\Response\Traits\AuthApiResponseDecorator;
8
+
9
+ class PostSearchResponse implements ApiResponse
10
+ {
11
+
12
+ use AuthApiResponseDecorator;
13
+
14
+ const RESPONSE_CODE_COLLECTION_POINT_FAILED = 476;
15
+
16
+ /**
17
+ * @return SearchResponse
18
+ */
19
+ public function getPoints()
20
+ {
21
+ return new SearchResponse($this->getResponseBody());
22
+ }
23
+
24
+ /**
25
+ * Platform can't respond in meaningful way about rates
26
+ *
27
+ * @return bool
28
+ */
29
+ public function isCollectionPointError()
30
+ {
31
+ return $this->rawResponse->getResponseCode() === self::RESPONSE_CODE_COLLECTION_POINT_FAILED;
32
+ }
33
+
34
+
35
+ }
vendor/wpdesk/wp-saas-platform-client/src/Response/Rate/PostRateResponse.php CHANGED
@@ -25,7 +25,8 @@ class PostRateResponse implements ApiResponse
25
  *
26
  * @return bool
27
  */
28
- public function isRateFailedError() {
 
29
  return $this->rawResponse->getResponseCode() === self::RESPONSE_CODE_RATE_FAILED;
30
  }
31
  }
25
  *
26
  * @return bool
27
  */
28
+ public function isRateFailedError()
29
+ {
30
  return $this->rawResponse->getResponseCode() === self::RESPONSE_CODE_RATE_FAILED;
31
  }
32
  }