Flexible Shipping for WooCommerce - Version 3.12.0

Version Description

  • 2020-09-03 =
  • Added free shipping notice
  • Removed Integrations settings when no integrations available
Download this release

Release Info

Developer wpdesk
Plugin Icon 128x128 Flexible Shipping for WooCommerce
Version 3.12.0
Comparing to
See all releases

Code changes from version 3.11.4 to 3.12.0

assets/js/contextual-info.js CHANGED
@@ -16,8 +16,9 @@
16
  let config = $.extend(
17
  {
18
  'id': '',
19
- 'phrases': [],
20
  'info_html': '',
 
21
  },
22
  settings
23
  );
@@ -66,12 +67,21 @@
66
  function toggleInfoElement($element) {
67
  let element_value = $element.val().toLowerCase();
68
  let show_info = false;
69
- $( config.phrases ).each(
 
 
 
70
  function( index, value ) {
71
  let phrase_value = value.toLowerCase();
72
  show_info = show_info || element_value.indexOf( phrase_value ) !== -1;
73
  }
74
  );
 
 
 
 
 
 
75
  $( '#' + $element.attr( 'id' ) + "_" + config.id ).toggle( show_info );
76
  }
77
  }
16
  let config = $.extend(
17
  {
18
  'id': '',
19
+ 'phrases_in': [],
20
  'info_html': '',
21
+ 'phrases_not_in': [],
22
  },
23
  settings
24
  );
67
  function toggleInfoElement($element) {
68
  let element_value = $element.val().toLowerCase();
69
  let show_info = false;
70
+ if ( config.phrases_in.length === 0 ) {
71
+ show_info = true;
72
+ }
73
+ $( config.phrases_in ).each(
74
  function( index, value ) {
75
  let phrase_value = value.toLowerCase();
76
  show_info = show_info || element_value.indexOf( phrase_value ) !== -1;
77
  }
78
  );
79
+ $( config.phrases_not_in ).each(
80
+ function( index, value ) {
81
+ let phrase_value = value.toLowerCase();
82
+ show_info = show_info && element_value.indexOf( phrase_value ) === -1;
83
+ }
84
+ );
85
  $( '#' + $element.attr( 'id' ) + "_" + config.id ).toggle( show_info );
86
  }
87
  }
assets/js/contextual-info.min.js CHANGED
@@ -1 +1 @@
1
- (function(a){a.fn.contextualInfo=function(d){let config=a.extend({id:"",phrases:[],info_html:""},d);return this.each(function(){let $element=a(this);b($element);e($element);$element.keyup(function(){e($element)})});function c(f){return f.attr("id")+"_"+config.id}function b(f){a(f).after(function(){return'<p class="description" id="'+c(f)+'" style="display: none;">'+config.info_html+"</p>"})}function e(f){let element_value=f.val().toLowerCase();let show_info=false;a(config.phrases).each(function(g,h){let phrase_value=h.toLowerCase();show_info=show_info||element_value.indexOf(phrase_value)!==-1});a("#"+f.attr("id")+"_"+config.id).toggle(show_info)}}})(jQuery);
1
+ (function(a){a.fn.contextualInfo=function(d){let config=a.extend({id:"",phrases_in:[],info_html:"",phrases_not_in:[]},d);return this.each(function(){let $element=a(this);b($element);e($element);$element.keyup(function(){e($element)})});function c(f){return f.attr("id")+"_"+config.id}function b(f){a(f).after(function(){return'<p class="description" id="'+c(f)+'" style="display: none;">'+config.info_html+"</p>"})}function e(f){let element_value=f.val().toLowerCase();let show_info=false;if(config.phrases_in.length===0){show_info=true}a(config.phrases_in).each(function(g,h){let phrase_value=h.toLowerCase();show_info=show_info||element_value.indexOf(phrase_value)!==-1});a(config.phrases_not_in).each(function(g,h){let phrase_value=h.toLowerCase();show_info=show_info&&element_value.indexOf(phrase_value)===-1});a("#"+f.attr("id")+"_"+config.id).toggle(show_info)}}})(jQuery);
classes/Flexible_Shipping_Contextual_Info.php CHANGED
@@ -27,9 +27,9 @@ class Flexible_Shipping_Contextual_Info implements \FSVendor\WPDesk\PluginBuilde
27
  /**
28
  * .
29
  *
30
- * @var array
31
  */
32
- private $phrases;
33
 
34
  /**
35
  * .
@@ -38,19 +38,32 @@ class Flexible_Shipping_Contextual_Info implements \FSVendor\WPDesk\PluginBuilde
38
  */
39
  private $info_html;
40
 
 
 
 
 
 
41
  /**
42
  * Flexible_Shipping_Contextual_Info constructor.
43
  *
44
  * @param string $html_elements_ids Comma separated HTML element IDs to add contextual info.
45
  * @param string $info_id Info element ID.
46
- * @param array $phrases Phrases to display contextual info.
47
  * @param string $info_html HTML code to display as info.
 
48
  */
49
- public function __construct( $html_elements_ids, $info_id, array $phrases, $info_html ) {
 
 
 
 
 
 
50
  $this->html_elements_ids = $html_elements_ids;
51
  $this->info_id = $info_id;
52
- $this->phrases = $phrases;
53
  $this->info_html = $info_html;
 
54
  }
55
 
56
  /**
@@ -66,8 +79,9 @@ class Flexible_Shipping_Contextual_Info implements \FSVendor\WPDesk\PluginBuilde
66
  public function add_contextual_info_script() {
67
  $html_elements_ids = '#' . implode( ',#', explode( ',', $this->html_elements_ids ) );
68
  $info_id = $this->info_id;
69
- $phrases = $this->phrases;
70
  $info_html = $this->info_html;
 
71
  include __DIR__ . '/views/contextual-info-script.php';
72
  }
73
 
27
  /**
28
  * .
29
  *
30
+ * @var string[]
31
  */
32
+ private $phrases_in;
33
 
34
  /**
35
  * .
38
  */
39
  private $info_html;
40
 
41
+ /**
42
+ * @var string[]
43
+ */
44
+ private $phrases_not_in;
45
+
46
  /**
47
  * Flexible_Shipping_Contextual_Info constructor.
48
  *
49
  * @param string $html_elements_ids Comma separated HTML element IDs to add contextual info.
50
  * @param string $info_id Info element ID.
51
+ * @param array $phrases_in Phrases to display contextual info.
52
  * @param string $info_html HTML code to display as info.
53
+ * @param array $phrases_not_in Phrases to not display contextual info.
54
  */
55
+ public function __construct(
56
+ $html_elements_ids,
57
+ $info_id,
58
+ array $phrases_in,
59
+ $info_html,
60
+ array $phrases_not_in = array()
61
+ ) {
62
  $this->html_elements_ids = $html_elements_ids;
63
  $this->info_id = $info_id;
64
+ $this->phrases_in = $phrases_in;
65
  $this->info_html = $info_html;
66
+ $this->phrases_not_in = $phrases_not_in;
67
  }
68
 
69
  /**
79
  public function add_contextual_info_script() {
80
  $html_elements_ids = '#' . implode( ',#', explode( ',', $this->html_elements_ids ) );
81
  $info_id = $this->info_id;
82
+ $phrases_in = $this->phrases_in;
83
  $info_html = $this->info_html;
84
+ $phrases_not_in = $this->phrases_not_in;
85
  include __DIR__ . '/views/contextual-info-script.php';
86
  }
87
 
classes/class-flexible-shipping-plugin.php CHANGED
@@ -23,6 +23,8 @@ use FSVendor\WPDesk\View\Resolver\WPThemeResolver;
23
  use FSVendor\WPDesk\WooCommerce\CurrencySwitchers\ShippingIntegrations;
24
  use Psr\Log\LoggerInterface;
25
  use Psr\Log\NullLogger;
 
 
26
  use WPDesk\FS\TableRate\NewRulesTableBanner\RulesBannerClickedOption;
27
  use WPDesk\FS\TableRate\NewRulesTableBanner\RulesBannerLikeOption;
28
  use WPDesk\FS\TableRate\NewRulesTableBanner\RulesPointerBannerForNewTable;
@@ -32,6 +34,7 @@ use WPDesk\FS\TableRate\NewRulesTablePointer\RulesPointerMessage;
32
  use WPDesk\FS\TableRate\NewRulesTablePointer\RulesPointerOption;
33
  use WPDesk\FS\TableRate\NewRulesTableTracker;
34
  use WPDesk\FS\TableRate\UserFeedback;
 
35
 
36
  /**
37
  * Class Flexible_Shipping_Plugin
@@ -208,42 +211,10 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
208
  * Init contextual info on Flexible Shipping settings fields.
209
  */
210
  private function init_contextual_info() {
211
- if ( ! defined( 'FLEXIBLE_SHIPPING_DHL_EXPRESS_VERSION' ) && ! defined( 'FLEXIBLE_SHIPPING_DHL_EXPRESS_PRO_VERSION' ) ) {
212
- $this->add_hookable( new Flexible_Shipping_Contextual_Info(
213
- 'woocommerce_flexible_shipping_method_title,woocommerce_flexible_shipping_method_description',
214
- 'dhl',
215
- array( 'dhl', 'dhl express' ),
216
- sprintf(
217
- __( 'Want to show your customers the DHL Express live rates? %1$sCheck our DHL Express plugin →%2$s', 'flexible-shipping' ),
218
- '<a href="https://wpde.sk/fs-up-dhl-express" target="_blank">',
219
- '</a>'
220
- )
221
- ) );
222
- }
223
- if ( ! defined( 'FLEXIBLE_SHIPPING_FEDEX_VERSION' ) && ! defined( 'FLEXIBLE_SHIPPING_FEDEX_PRO_VERSION' ) ) {
224
- $this->add_hookable( new Flexible_Shipping_Contextual_Info(
225
- 'woocommerce_flexible_shipping_method_title,woocommerce_flexible_shipping_method_description',
226
- 'fedex',
227
- array( 'fedex' ),
228
- sprintf(
229
- __( 'Want to show your customers the FedEx live rates? %1$sCheck our FedEx plugin →%2$s', 'flexible-shipping' ),
230
- '<a href="https://wpde.sk/fs-up-fedex" target="_blank">',
231
- '</a>'
232
- )
233
- ) );
234
- }
235
- if ( ! defined( 'FLEXIBLE_SHIPPING_UPS_VERSION' ) && ! defined( 'FLEXIBLE_SHIPPING_UPS_PRO_VERSION' ) ) {
236
- $this->add_hookable( new Flexible_Shipping_Contextual_Info(
237
- 'woocommerce_flexible_shipping_method_title,woocommerce_flexible_shipping_method_description',
238
- 'ups',
239
- array( 'ups' ),
240
- sprintf(
241
- __( 'Want to show your customers the UPS live rates? %1$sCheck our UPS plugin →%2$s', 'flexible-shipping' ),
242
- '<a href="https://wpde.sk/fs-up-ups" target="_blank">',
243
- '</a>'
244
- )
245
- ) );
246
- }
247
  }
248
 
249
  /**
@@ -341,10 +312,26 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
341
 
342
  add_action( 'admin_init', array( $this, 'init_deactivation_tracker' ) );
343
 
 
 
344
  $this->hooks_on_hookable_objects();
345
 
346
  }
347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  /**
349
  * Init deactivation tracker.
350
  */
23
  use FSVendor\WPDesk\WooCommerce\CurrencySwitchers\ShippingIntegrations;
24
  use Psr\Log\LoggerInterface;
25
  use Psr\Log\NullLogger;
26
+ use WPDesk\FS\TableRate\FreeShipping\FreeShippingNotice;
27
+ use WPDesk\FS\TableRate\FreeShipping\FreeShippingNoticeGenerator;
28
  use WPDesk\FS\TableRate\NewRulesTableBanner\RulesBannerClickedOption;
29
  use WPDesk\FS\TableRate\NewRulesTableBanner\RulesBannerLikeOption;
30
  use WPDesk\FS\TableRate\NewRulesTableBanner\RulesPointerBannerForNewTable;
34
  use WPDesk\FS\TableRate\NewRulesTablePointer\RulesPointerOption;
35
  use WPDesk\FS\TableRate\NewRulesTableTracker;
36
  use WPDesk\FS\TableRate\UserFeedback;
37
+ use WPDesk\FS\TableRate\ContextualInfo;
38
 
39
  /**
40
  * Class Flexible_Shipping_Plugin
211
  * Init contextual info on Flexible Shipping settings fields.
212
  */
213
  private function init_contextual_info() {
214
+ $base_location = wc_get_base_location();
215
+ $contextual_info_creator = new ContextualInfo\Creator( $base_location['country'] );
216
+ $this->add_hookable( $contextual_info_creator );
217
+ $contextual_info_creator->create_contextual_info();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  }
219
 
220
  /**
312
 
313
  add_action( 'admin_init', array( $this, 'init_deactivation_tracker' ) );
314
 
315
+ add_action( 'woocommerce_init', array( $this, 'init_free_shipping_notice' ) );
316
+
317
  $this->hooks_on_hookable_objects();
318
 
319
  }
320
 
321
+ /**
322
+ * Init free shipping notice.
323
+ *
324
+ * @internal
325
+ */
326
+ public function init_free_shipping_notice() {
327
+ $cart = WC()->cart;
328
+ $session = WC()->session;
329
+ if ( null !== $cart && null !== $session ) {
330
+ ( new FreeShippingNoticeGenerator( $cart, $session ) )->hooks();
331
+ ( new FreeShippingNotice( $session ) )->hooks();
332
+ }
333
+ }
334
+
335
  /**
336
  * Init deactivation tracker.
337
  */
classes/table-rate/settings/shipping-method-form.php CHANGED
@@ -22,21 +22,8 @@ foreach ( WC()->shipping->get_shipping_classes() as $shipping_class ) {
22
  $base_location = wc_get_base_location();
23
 
24
  $integrations = '';
25
-
26
- switch ( $base_location['country'] ) {
27
- case 'PL':
28
- $integrations = __( 'Integrate with DPD, DHL, InPost, eNadawca Poczta Polska, Paczka w Ruchu.', 'flexible-shipping' ) . '&nbsp;&nbsp;' .
29
- // Translators: link.
30
- sprintf( __( '%1$sAdd integrations%2$s', 'flexible-shipping' ), '<a class="button button-primary" href="https://www.wpdesk.pl/kategoria-produktu/wysylka/?utm_source=flexible-shipping-method&utm_medium=button&utm_campaign=flexible-shipping-integrations" target="_blank">', ' &rarr;</a>' );
31
- break;
32
- default:
33
- $integrations = __( 'Integrate with DPD.', 'flexible-shipping' ) . '&nbsp;&nbsp;' .
34
- // Translators: link.
35
- sprintf( __( '%1$sAdd integration%2$s', 'flexible-shipping' ), '<a class="button button-primary" href="https://flexibleshipping.com/products/dpd-uk-dpd-local-woocommerce/?utm_source=flexible-shipping-method&utm_medium=button&utm_campaign=flexible-shipping-integrations" target="_blank">', ' &rarr;</a>' );
36
- break;
37
- }
38
-
39
- $integrations_tip = $integrations ? false : true;
40
 
41
  if ( ! isset( $shipping_method['method_free_shipping_label'] ) ) {
42
  $shipping_method['method_free_shipping_label'] = __( 'Free', 'flexible-shipping' );
@@ -64,7 +51,6 @@ $settings = array(
64
  'title' => __( 'Method Title', 'flexible-shipping' ),
65
  'type' => 'text',
66
  'description' => __( 'This controls the title which the user sees during checkout.', 'flexible-shipping' ),
67
- 'default' => __( 'Flexible Shipping', 'flexible-shipping' ),
68
  'desc_tip' => true,
69
  'default' => $shipping_method['method_title'],
70
  'custom_attributes' => array( 'required' => true ),
@@ -73,7 +59,6 @@ $settings = array(
73
  'title' => __( 'Method Description', 'flexible-shipping' ),
74
  'type' => 'text',
75
  'description' => __( 'This controls method description which the user sees during checkout.', 'flexible-shipping' ),
76
- 'default' => '',
77
  'desc_tip' => true,
78
  'default' => $shipping_method['method_description'],
79
  ),
@@ -96,6 +81,14 @@ $settings = array(
96
  'description' => __( 'Enter additional label for shipment when free shipment available.', 'flexible-shipping' ),
97
  'desc_tip' => true,
98
  ),
 
 
 
 
 
 
 
 
99
  array(
100
  'title' => '',
101
  'type' => 'title',
@@ -121,15 +114,17 @@ $settings = array(
121
  'default' => $shipping_method['method_default'],
122
  'label' => __( 'Check the box to set this option as the default selected choice on the cart page.', 'flexible-shipping' ),
123
  ),
124
- 'method_integration' => array(
 
 
 
125
  'title' => __( 'Integration', 'flexible-shipping' ),
126
  'type' => 'select',
127
- 'description' => __( 'Select integration. ', 'flexible-shipping' ) . $integrations,
128
  'desc_tip' => $integrations_tip,
129
  'default' => $shipping_method['method_integration'],
130
- 'options' => apply_filters( 'flexible_shipping_integration_options', array( '' => __( 'None', 'flexible-shipping' ) ) ),
131
- ),
132
- );
133
 
134
  $settings = apply_filters( 'flexible_shipping_method_settings', $settings, $shipping_method );
135
 
@@ -148,28 +143,6 @@ if ( version_compare( WC()->version, '2.6' ) < 0 ) {
148
  unset( $settings['method_free_shipping_label'] );
149
  }
150
 
151
- if ( class_exists( 'WC_Shipping_Zones1' ) ) {
152
- $shipping_zones = WC_Shipping_Zones::get_zones();
153
- $shipping_zones_options = array();
154
- foreach ( $shipping_zones as $shipping_zone ) {
155
- $shipping_zones_options[ $shipping_zone['zone_id'] ] = $shipping_zone['zone_name'];
156
- }
157
- $settings_with_zones = array();
158
- foreach ( $settings as $key => $setting ) {
159
- $settings_with_zones[ $key ] = $setting;
160
- if ( 'method_title' === $key ) {
161
- $settings_with_zones['method_shipping_zone'] = array(
162
- 'title' => __( 'Shipping Zone', 'flexible-shipping' ),
163
- 'type' => 'select',
164
- 'default' => $shipping_method['method_shipping_zone'],
165
- 'options' => $shipping_zones_options,
166
- );
167
- }
168
- }
169
-
170
- return $settings_with_zones;
171
- }
172
-
173
  $docs_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/' : 'https://docs.flexibleshipping.com/article/29-shipping-methods/';
174
 
175
  $docs_link .= '?utm_campaign=flexible-shipping&utm_source=user-site&utm_medium=link&utm_term=configure-shipment-methods&utm_content=fs-shippingzone-addnew-seehow';
22
  $base_location = wc_get_base_location();
23
 
24
  $integrations = '';
25
+ $integrations_tip = false;
26
+ $integrations_options = apply_filters( 'flexible_shipping_integration_options', array( '' => __( 'None', 'flexible-shipping' ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  if ( ! isset( $shipping_method['method_free_shipping_label'] ) ) {
29
  $shipping_method['method_free_shipping_label'] = __( 'Free', 'flexible-shipping' );
51
  'title' => __( 'Method Title', 'flexible-shipping' ),
52
  'type' => 'text',
53
  'description' => __( 'This controls the title which the user sees during checkout.', 'flexible-shipping' ),
 
54
  'desc_tip' => true,
55
  'default' => $shipping_method['method_title'],
56
  'custom_attributes' => array( 'required' => true ),
59
  'title' => __( 'Method Description', 'flexible-shipping' ),
60
  'type' => 'text',
61
  'description' => __( 'This controls method description which the user sees during checkout.', 'flexible-shipping' ),
 
62
  'desc_tip' => true,
63
  'default' => $shipping_method['method_description'],
64
  ),
81
  'description' => __( 'Enter additional label for shipment when free shipment available.', 'flexible-shipping' ),
82
  'desc_tip' => true,
83
  ),
84
+ WPDesk_Flexible_Shipping::SETTING_METHOD_FREE_SHIPPING_NOTICE => array(
85
+ 'title' => __( '\'Left to free shipping\' notice', 'flexible-shipping' ),
86
+ 'type' => 'checkbox',
87
+ 'default' => isset( $shipping_method[ WPDesk_Flexible_Shipping::SETTING_METHOD_FREE_SHIPPING_NOTICE ] ) ? $shipping_method[ WPDesk_Flexible_Shipping::SETTING_METHOD_FREE_SHIPPING_NOTICE ] : 'no',
88
+ 'label' => __( 'Display the notice with the amount of price left to free shipping', 'flexible-shipping' ),
89
+ 'description' => __( 'Tick this option to display the notice in the cart and on the checkout page.', 'flexible-shipping' ),
90
+ 'desc_tip' => true,
91
+ ),
92
  array(
93
  'title' => '',
94
  'type' => 'title',
114
  'default' => $shipping_method['method_default'],
115
  'label' => __( 'Check the box to set this option as the default selected choice on the cart page.', 'flexible-shipping' ),
116
  ),
117
+ );
118
+
119
+ if ( 1 < count( $integrations_options ) ) {
120
+ $settings['method_integration'] = array(
121
  'title' => __( 'Integration', 'flexible-shipping' ),
122
  'type' => 'select',
 
123
  'desc_tip' => $integrations_tip,
124
  'default' => $shipping_method['method_integration'],
125
+ 'options' => $integrations_options,
126
+ );
127
+ }
128
 
129
  $settings = apply_filters( 'flexible_shipping_method_settings', $settings, $shipping_method );
130
 
143
  unset( $settings['method_free_shipping_label'] );
144
  }
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  $docs_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/' : 'https://docs.flexibleshipping.com/article/29-shipping-methods/';
147
 
148
  $docs_link .= '?utm_campaign=flexible-shipping&utm_source=user-site&utm_medium=link&utm_term=configure-shipment-methods&utm_content=fs-shippingzone-addnew-seehow';
classes/table-rate/shipping-method.php CHANGED
@@ -8,6 +8,8 @@ use WPDesk\FS\TableRate\RulesSettingsField;
8
 
9
  class WPDesk_Flexible_Shipping extends WC_Shipping_Method {
10
 
 
 
11
  const FIELD_METHOD_FREE_SHIPPING = 'method_free_shipping';
12
 
13
  const META_DEFAULT = '_default';
@@ -16,6 +18,8 @@ class WPDesk_Flexible_Shipping extends WC_Shipping_Method {
16
 
17
  const SETTING_METHOD_RULES = 'method_rules';
18
 
 
 
19
  /**
20
  * Message added.
21
  *
@@ -32,7 +36,7 @@ class WPDesk_Flexible_Shipping extends WC_Shipping_Method {
32
  */
33
  public function __construct( $instance_id = 0 ) {
34
  $this->instance_id = absint( $instance_id );
35
- $this->id = 'flexible_shipping';
36
  $this->shipping_methods_option = 'flexible_shipping_methods_' . $this->instance_id;
37
  $this->shipping_method_order_option = 'flexible_shipping_method_order_' . $this->instance_id;
38
  $this->section_name = 'flexible_shipping';
@@ -295,10 +299,17 @@ class WPDesk_Flexible_Shipping extends WC_Shipping_Method {
295
  if ( version_compare( WC()->version, '2.6' ) >= 0 ) {
296
  $shipping_method['method_free_shipping_label'] = sanitize_text_field( wp_unslash( $_POST['woocommerce_' . $this->id . '_method_free_shipping_label'] ) );
297
  }
 
 
 
 
 
 
298
  $shipping_method['method_calculation_method'] = sanitize_text_field( wp_unslash( $_POST['woocommerce_' . $this->id . '_method_calculation_method'] ) );
299
  $shipping_method['method_visibility'] = 'no';
300
- if ( isset( $_POST['woocommerce_' . $this->id . '_method_visibility'] ) && $_POST['woocommerce_' . $this->id . '_method_visibility'] == 1 )
301
- {$shipping_method['method_visibility'] = 'yes';}
 
302
  //
303
  $shipping_method['method_default'] = 'no';
304
  if ( isset( $_POST['woocommerce_' . $this->id . '_method_default'] ) && $_POST['woocommerce_' . $this->id . '_method_default'] == 1 )
8
 
9
  class WPDesk_Flexible_Shipping extends WC_Shipping_Method {
10
 
11
+ const METHOD_ID = 'flexible_shipping';
12
+
13
  const FIELD_METHOD_FREE_SHIPPING = 'method_free_shipping';
14
 
15
  const META_DEFAULT = '_default';
18
 
19
  const SETTING_METHOD_RULES = 'method_rules';
20
 
21
+ const SETTING_METHOD_FREE_SHIPPING_NOTICE = 'method_free_shipping_cart_notice';
22
+
23
  /**
24
  * Message added.
25
  *
36
  */
37
  public function __construct( $instance_id = 0 ) {
38
  $this->instance_id = absint( $instance_id );
39
+ $this->id = self::METHOD_ID;
40
  $this->shipping_methods_option = 'flexible_shipping_methods_' . $this->instance_id;
41
  $this->shipping_method_order_option = 'flexible_shipping_method_order_' . $this->instance_id;
42
  $this->section_name = 'flexible_shipping';
299
  if ( version_compare( WC()->version, '2.6' ) >= 0 ) {
300
  $shipping_method['method_free_shipping_label'] = sanitize_text_field( wp_unslash( $_POST['woocommerce_' . $this->id . '_method_free_shipping_label'] ) );
301
  }
302
+
303
+ $shipping_method[ WPDesk_Flexible_Shipping::SETTING_METHOD_FREE_SHIPPING_NOTICE ] = 'no';
304
+ if ( isset( $_POST[ 'woocommerce_' . $this->id . '_' . self::SETTING_METHOD_FREE_SHIPPING_NOTICE ] ) && intval( $_POST[ 'woocommerce_' . $this->id . '_' . self::SETTING_METHOD_FREE_SHIPPING_NOTICE ] ) === 1 ) {
305
+ $shipping_method[ WPDesk_Flexible_Shipping::SETTING_METHOD_FREE_SHIPPING_NOTICE ] = 'yes';
306
+ }
307
+
308
  $shipping_method['method_calculation_method'] = sanitize_text_field( wp_unslash( $_POST['woocommerce_' . $this->id . '_method_calculation_method'] ) );
309
  $shipping_method['method_visibility'] = 'no';
310
+ if ( isset( $_POST['woocommerce_' . $this->id . '_method_visibility'] ) && $_POST['woocommerce_' . $this->id . '_method_visibility'] == 1 ) {
311
+ $shipping_method['method_visibility'] = 'yes';
312
+ }
313
  //
314
  $shipping_method['method_default'] = 'no';
315
  if ( isset( $_POST['woocommerce_' . $this->id . '_method_default'] ) && $_POST['woocommerce_' . $this->id . '_method_default'] == 1 )
classes/tracker/tracker.php CHANGED
@@ -1,11 +1,14 @@
1
  <?php
 
 
 
 
 
2
 
3
  use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable;
4
 
5
  /**
6
- * Handle Tracker actions and filrers.
7
- *
8
- * Class WPDesk_Flexible_Shipping_Tracker
9
  */
10
  class WPDesk_Flexible_Shipping_Tracker implements Hookable {
11
 
@@ -46,21 +49,22 @@ class WPDesk_Flexible_Shipping_Tracker implements Hookable {
46
 
47
  $flexible_shipping = $all_shipping_methods['flexible_shipping'];
48
 
49
- $flexible_shipping_rates = $flexible_shipping->get_all_rates();
50
- $data['flexible_shipping'] = array();
51
- $data['flexible_shipping']['total_shipping_methods'] = 0;
52
- $data['flexible_shipping']['avg_rules'] = 0;
53
- $data['flexible_shipping']['max_rules'] = 0;
54
- $data['flexible_shipping']['integrations'] = array();
55
- $data['flexible_shipping']['free_shipping_requires'] = array();
56
- $data['flexible_shipping']['calculation_methods'] = array();
57
- $data['flexible_shipping']['based_on'] = array();
58
- $data['flexible_shipping']['shipping_class_option'] = array();
59
- $data['flexible_shipping']['method_description_count'] = 0;
60
- $data['flexible_shipping']['free_shipping_label_count'] = 0;
61
- $data['flexible_shipping']['max_cost_count'] = 0;
62
- $data['flexible_shipping']['visibility_count'] = 0;
63
- $data['flexible_shipping']['default_count'] = 0;
 
64
 
65
  $data['flexible_shipping']['additional_cost_count'] = 0;
66
 
@@ -108,6 +112,12 @@ class WPDesk_Flexible_Shipping_Tracker implements Hookable {
108
  $data['flexible_shipping']['free_shipping_label_count'] ++;
109
  }
110
 
 
 
 
 
 
 
111
  if ( ! empty( $flexible_shipping_rate['method_max_cost'] ) ) {
112
  $data['flexible_shipping']['max_cost_count'] ++;
113
  }
1
  <?php
2
+ /**
3
+ * Tracker.
4
+ *
5
+ * @package Flexible Shipping.
6
+ */
7
 
8
  use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable;
9
 
10
  /**
11
+ * Handle Tracker actions and filters.
 
 
12
  */
13
  class WPDesk_Flexible_Shipping_Tracker implements Hookable {
14
 
49
 
50
  $flexible_shipping = $all_shipping_methods['flexible_shipping'];
51
 
52
+ $flexible_shipping_rates = $flexible_shipping->get_all_rates();
53
+ $data['flexible_shipping'] = array();
54
+ $data['flexible_shipping']['total_shipping_methods'] = 0;
55
+ $data['flexible_shipping']['avg_rules'] = 0;
56
+ $data['flexible_shipping']['max_rules'] = 0;
57
+ $data['flexible_shipping']['integrations'] = array();
58
+ $data['flexible_shipping']['free_shipping_requires'] = array();
59
+ $data['flexible_shipping']['calculation_methods'] = array();
60
+ $data['flexible_shipping']['based_on'] = array();
61
+ $data['flexible_shipping']['shipping_class_option'] = array();
62
+ $data['flexible_shipping']['method_description_count'] = 0;
63
+ $data['flexible_shipping']['free_shipping_label_count'] = 0;
64
+ $data['flexible_shipping']['free_shipping_cart_notice_count'] = 0;
65
+ $data['flexible_shipping']['max_cost_count'] = 0;
66
+ $data['flexible_shipping']['visibility_count'] = 0;
67
+ $data['flexible_shipping']['default_count'] = 0;
68
 
69
  $data['flexible_shipping']['additional_cost_count'] = 0;
70
 
112
  $data['flexible_shipping']['free_shipping_label_count'] ++;
113
  }
114
 
115
+ if ( ! empty( $flexible_shipping_rate[ WPDesk_Flexible_Shipping::SETTING_METHOD_FREE_SHIPPING_NOTICE ] )
116
+ && 'yes' === $flexible_shipping_rate[ WPDesk_Flexible_Shipping::SETTING_METHOD_FREE_SHIPPING_NOTICE ]
117
+ ) {
118
+ $data['flexible_shipping']['free_shipping_cart_notice_count'] ++;
119
+ }
120
+
121
  if ( ! empty( $flexible_shipping_rate['method_max_cost'] ) ) {
122
  $data['flexible_shipping']['max_cost_count'] ++;
123
  }
classes/views/contextual-info-script.php CHANGED
@@ -6,17 +6,20 @@
6
  *
7
  * @var $html_elements_ids string
8
  * @var $info_id string
9
- * @var $phrases array
10
  * @var $info_html string
 
11
  */
 
12
  ?><script type="text/javascript">
13
  jQuery( document ).ready(
14
  function(){
15
  jQuery( "<?php echo esc_attr( $html_elements_ids ); ?>" ).contextualInfo(
16
  {
17
  'id': '<?php echo esc_attr( $info_id ); ?>',
18
- 'phrases': <?php echo json_encode( $phrases ); // phpcs:ignore ?>,
19
- 'info_html': <?php echo json_encode( $info_html ); // phpcs:ignore ?>
 
20
  }
21
  );
22
  }
6
  *
7
  * @var $html_elements_ids string
8
  * @var $info_id string
9
+ * @var $phrases_in string[]
10
  * @var $info_html string
11
+ * @var $phrases_not_in string[]
12
  */
13
+
14
  ?><script type="text/javascript">
15
  jQuery( document ).ready(
16
  function(){
17
  jQuery( "<?php echo esc_attr( $html_elements_ids ); ?>" ).contextualInfo(
18
  {
19
  'id': '<?php echo esc_attr( $info_id ); ?>',
20
+ 'phrases_in': <?php echo json_encode( $phrases_in ); // phpcs:ignore ?>,
21
+ 'info_html': <?php echo json_encode( $info_html ); // phpcs:ignore ?>,
22
+ 'phrases_not_in': <?php echo json_encode( $phrases_not_in ); // phpcs:ignore ?>
23
  }
24
  );
25
  }
composer.lock CHANGED
@@ -328,16 +328,16 @@
328
  },
329
  {
330
  "name": "codeception/codeception",
331
- "version": "4.1.6",
332
  "source": {
333
  "type": "git",
334
  "url": "https://github.com/Codeception/Codeception.git",
335
- "reference": "5515b6a6c6f1e1c909aaff2e5f3a15c177dfd1a9"
336
  },
337
  "dist": {
338
  "type": "zip",
339
- "url": "https://api.github.com/repos/Codeception/Codeception/zipball/5515b6a6c6f1e1c909aaff2e5f3a15c177dfd1a9",
340
- "reference": "5515b6a6c6f1e1c909aaff2e5f3a15c177dfd1a9",
341
  "shasum": ""
342
  },
343
  "require": {
@@ -415,24 +415,25 @@
415
  "type": "open_collective"
416
  }
417
  ],
418
- "time": "2020-06-07T16:31:51+00:00"
419
  },
420
  {
421
  "name": "codeception/lib-asserts",
422
- "version": "1.12.0",
423
  "source": {
424
  "type": "git",
425
  "url": "https://github.com/Codeception/lib-asserts.git",
426
- "reference": "acd0dc8b394595a74b58dcc889f72569ff7d8e71"
427
  },
428
  "dist": {
429
  "type": "zip",
430
- "url": "https://api.github.com/repos/Codeception/lib-asserts/zipball/acd0dc8b394595a74b58dcc889f72569ff7d8e71",
431
- "reference": "acd0dc8b394595a74b58dcc889f72569ff7d8e71",
432
  "shasum": ""
433
  },
434
  "require": {
435
  "codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.0.3 | ^9.0",
 
436
  "php": ">=5.6.0 <8.0"
437
  },
438
  "type": "library",
@@ -453,14 +454,18 @@
453
  },
454
  {
455
  "name": "Gintautas Miselis"
 
 
 
 
456
  }
457
  ],
458
  "description": "Assertion methods used by Codeception core and Asserts module",
459
- "homepage": "http://codeception.com/",
460
  "keywords": [
461
  "codeception"
462
  ],
463
- "time": "2020-04-17T18:20:46+00:00"
464
  },
465
  {
466
  "name": "codeception/lib-innerbrowser",
@@ -520,21 +525,21 @@
520
  },
521
  {
522
  "name": "codeception/module-asserts",
523
- "version": "1.2.1",
524
  "source": {
525
  "type": "git",
526
  "url": "https://github.com/Codeception/module-asserts.git",
527
- "reference": "79f13d05b63f2fceba4d0e78044bab668c9b2a6b"
528
  },
529
  "dist": {
530
  "type": "zip",
531
- "url": "https://api.github.com/repos/Codeception/module-asserts/zipball/79f13d05b63f2fceba4d0e78044bab668c9b2a6b",
532
- "reference": "79f13d05b63f2fceba4d0e78044bab668c9b2a6b",
533
  "shasum": ""
534
  },
535
  "require": {
536
  "codeception/codeception": "*@dev",
537
- "codeception/lib-asserts": "^1.12.0",
538
  "php": ">=5.6.0 <8.0"
539
  },
540
  "conflict": {
@@ -559,16 +564,20 @@
559
  },
560
  {
561
  "name": "Gintautas Miselis"
 
 
 
 
562
  }
563
  ],
564
  "description": "Codeception module containing various assertions",
565
- "homepage": "http://codeception.com/",
566
  "keywords": [
567
  "assertions",
568
  "asserts",
569
  "codeception"
570
  ],
571
- "time": "2020-04-20T07:26:11+00:00"
572
  },
573
  {
574
  "name": "codeception/module-cli",
@@ -777,16 +786,16 @@
777
  },
778
  {
779
  "name": "codeception/module-rest",
780
- "version": "1.2.1",
781
  "source": {
782
  "type": "git",
783
  "url": "https://github.com/Codeception/module-rest.git",
784
- "reference": "3664989d35003e182631cd9f4bc055fec009f5be"
785
  },
786
  "dist": {
787
  "type": "zip",
788
- "url": "https://api.github.com/repos/Codeception/module-rest/zipball/3664989d35003e182631cd9f4bc055fec009f5be",
789
- "reference": "3664989d35003e182631cd9f4bc055fec009f5be",
790
  "shasum": ""
791
  },
792
  "require": {
@@ -824,20 +833,20 @@
824
  "codeception",
825
  "rest"
826
  ],
827
- "time": "2020-07-05T15:40:45+00:00"
828
  },
829
  {
830
  "name": "codeception/module-webdriver",
831
- "version": "1.1.0",
832
  "source": {
833
  "type": "git",
834
  "url": "https://github.com/Codeception/module-webdriver.git",
835
- "reference": "09c167817393090ce3dbce96027d94656b1963ce"
836
  },
837
  "dist": {
838
  "type": "zip",
839
- "url": "https://api.github.com/repos/Codeception/module-webdriver/zipball/09c167817393090ce3dbce96027d94656b1963ce",
840
- "reference": "09c167817393090ce3dbce96027d94656b1963ce",
841
  "shasum": ""
842
  },
843
  "require": {
@@ -879,7 +888,7 @@
879
  "browser-testing",
880
  "codeception"
881
  ],
882
- "time": "2020-05-31T08:47:24+00:00"
883
  },
884
  {
885
  "name": "codeception/phpunit-wrapper",
@@ -992,16 +1001,16 @@
992
  },
993
  {
994
  "name": "composer/ca-bundle",
995
- "version": "1.2.7",
996
  "source": {
997
  "type": "git",
998
  "url": "https://github.com/composer/ca-bundle.git",
999
- "reference": "95c63ab2117a72f48f5a55da9740a3273d45b7fd"
1000
  },
1001
  "dist": {
1002
  "type": "zip",
1003
- "url": "https://api.github.com/repos/composer/ca-bundle/zipball/95c63ab2117a72f48f5a55da9740a3273d45b7fd",
1004
- "reference": "95c63ab2117a72f48f5a55da9740a3273d45b7fd",
1005
  "shasum": ""
1006
  },
1007
  "require": {
@@ -1049,12 +1058,16 @@
1049
  "url": "https://packagist.com",
1050
  "type": "custom"
1051
  },
 
 
 
 
1052
  {
1053
  "url": "https://tidelift.com/funding/github/packagist/composer/composer",
1054
  "type": "tidelift"
1055
  }
1056
  ],
1057
- "time": "2020-04-08T08:27:21+00:00"
1058
  },
1059
  {
1060
  "name": "composer/composer",
@@ -2225,16 +2238,16 @@
2225
  },
2226
  {
2227
  "name": "lucatume/wp-browser",
2228
- "version": "2.6.7",
2229
  "source": {
2230
  "type": "git",
2231
  "url": "https://github.com/lucatume/wp-browser.git",
2232
- "reference": "0323640f8120900eac034ded2bd0cffb2ccbebfa"
2233
  },
2234
  "dist": {
2235
  "type": "zip",
2236
- "url": "https://api.github.com/repos/lucatume/wp-browser/zipball/0323640f8120900eac034ded2bd0cffb2ccbebfa",
2237
- "reference": "0323640f8120900eac034ded2bd0cffb2ccbebfa",
2238
  "shasum": ""
2239
  },
2240
  "require": {
@@ -2247,7 +2260,7 @@
2247
  "ext-pdo": "*",
2248
  "mikemclin/laravel-wp-password": "~2.0.0",
2249
  "php": ">=5.6.0",
2250
- "symfony/filesystem": "^3.0",
2251
  "symfony/process": ">=2.7 <5.0",
2252
  "vria/nodiacritic": "^0.1.2",
2253
  "wp-cli/wp-cli-bundle": ">=2.0 <3.0.0",
@@ -2304,7 +2317,7 @@
2304
  "codeception",
2305
  "wordpress"
2306
  ],
2307
- "time": "2020-08-14T14:42:07+00:00"
2308
  },
2309
  {
2310
  "name": "matthiasmullie/minify",
@@ -4430,16 +4443,16 @@
4430
  },
4431
  {
4432
  "name": "seld/jsonlint",
4433
- "version": "1.8.1",
4434
  "source": {
4435
  "type": "git",
4436
  "url": "https://github.com/Seldaek/jsonlint.git",
4437
- "reference": "3d5eb71705adfa34bd34b993400622932b2f62fd"
4438
  },
4439
  "dist": {
4440
  "type": "zip",
4441
- "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/3d5eb71705adfa34bd34b993400622932b2f62fd",
4442
- "reference": "3d5eb71705adfa34bd34b993400622932b2f62fd",
4443
  "shasum": ""
4444
  },
4445
  "require": {
@@ -4485,7 +4498,7 @@
4485
  "type": "tidelift"
4486
  }
4487
  ],
4488
- "time": "2020-08-13T09:07:59+00:00"
4489
  },
4490
  {
4491
  "name": "seld/phar-utils",
@@ -4584,7 +4597,7 @@
4584
  },
4585
  {
4586
  "name": "symfony/browser-kit",
4587
- "version": "v3.4.43",
4588
  "source": {
4589
  "type": "git",
4590
  "url": "https://github.com/symfony/browser-kit.git",
@@ -4655,16 +4668,16 @@
4655
  },
4656
  {
4657
  "name": "symfony/console",
4658
- "version": "v3.4.43",
4659
  "source": {
4660
  "type": "git",
4661
  "url": "https://github.com/symfony/console.git",
4662
- "reference": "afc7189694d2c59546cf24ea606a236fa46a966e"
4663
  },
4664
  "dist": {
4665
  "type": "zip",
4666
- "url": "https://api.github.com/repos/symfony/console/zipball/afc7189694d2c59546cf24ea606a236fa46a966e",
4667
- "reference": "afc7189694d2c59546cf24ea606a236fa46a966e",
4668
  "shasum": ""
4669
  },
4670
  "require": {
@@ -4737,11 +4750,11 @@
4737
  "type": "tidelift"
4738
  }
4739
  ],
4740
- "time": "2020-07-06T08:57:31+00:00"
4741
  },
4742
  {
4743
  "name": "symfony/css-selector",
4744
- "version": "v3.4.43",
4745
  "source": {
4746
  "type": "git",
4747
  "url": "https://github.com/symfony/css-selector.git",
@@ -4808,16 +4821,16 @@
4808
  },
4809
  {
4810
  "name": "symfony/debug",
4811
- "version": "v3.4.43",
4812
  "source": {
4813
  "type": "git",
4814
  "url": "https://github.com/symfony/debug.git",
4815
- "reference": "7ce874f4432d8b11cc45a80cc5130a6e2609728d"
4816
  },
4817
  "dist": {
4818
  "type": "zip",
4819
- "url": "https://api.github.com/repos/symfony/debug/zipball/7ce874f4432d8b11cc45a80cc5130a6e2609728d",
4820
- "reference": "7ce874f4432d8b11cc45a80cc5130a6e2609728d",
4821
  "shasum": ""
4822
  },
4823
  "require": {
@@ -4874,20 +4887,20 @@
4874
  "type": "tidelift"
4875
  }
4876
  ],
4877
- "time": "2020-07-16T09:41:49+00:00"
4878
  },
4879
  {
4880
  "name": "symfony/dom-crawler",
4881
- "version": "v3.4.43",
4882
  "source": {
4883
  "type": "git",
4884
  "url": "https://github.com/symfony/dom-crawler.git",
4885
- "reference": "fc66039e3138db2fc54ee9ad30646d99c4495691"
4886
  },
4887
  "dist": {
4888
  "type": "zip",
4889
- "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/fc66039e3138db2fc54ee9ad30646d99c4495691",
4890
- "reference": "fc66039e3138db2fc54ee9ad30646d99c4495691",
4891
  "shasum": ""
4892
  },
4893
  "require": {
@@ -4945,20 +4958,20 @@
4945
  "type": "tidelift"
4946
  }
4947
  ],
4948
- "time": "2020-07-16T09:41:49+00:00"
4949
  },
4950
  {
4951
  "name": "symfony/event-dispatcher",
4952
- "version": "v3.4.43",
4953
  "source": {
4954
  "type": "git",
4955
  "url": "https://github.com/symfony/event-dispatcher.git",
4956
- "reference": "14d978f8e8555f2de719c00eb65376be7d2e9081"
4957
  },
4958
  "dist": {
4959
  "type": "zip",
4960
- "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/14d978f8e8555f2de719c00eb65376be7d2e9081",
4961
- "reference": "14d978f8e8555f2de719c00eb65376be7d2e9081",
4962
  "shasum": ""
4963
  },
4964
  "require": {
@@ -5022,20 +5035,20 @@
5022
  "type": "tidelift"
5023
  }
5024
  ],
5025
- "time": "2020-05-05T15:06:23+00:00"
5026
  },
5027
  {
5028
  "name": "symfony/filesystem",
5029
- "version": "v3.4.43",
5030
  "source": {
5031
  "type": "git",
5032
  "url": "https://github.com/symfony/filesystem.git",
5033
- "reference": "0f625d0cb1e59c8c4ba61abb170125175218ff10"
5034
  },
5035
  "dist": {
5036
  "type": "zip",
5037
- "url": "https://api.github.com/repos/symfony/filesystem/zipball/0f625d0cb1e59c8c4ba61abb170125175218ff10",
5038
- "reference": "0f625d0cb1e59c8c4ba61abb170125175218ff10",
5039
  "shasum": ""
5040
  },
5041
  "require": {
@@ -5086,11 +5099,11 @@
5086
  "type": "tidelift"
5087
  }
5088
  ],
5089
- "time": "2020-05-30T17:48:24+00:00"
5090
  },
5091
  {
5092
  "name": "symfony/finder",
5093
- "version": "v3.4.43",
5094
  "source": {
5095
  "type": "git",
5096
  "url": "https://github.com/symfony/finder.git",
@@ -5622,7 +5635,7 @@
5622
  },
5623
  {
5624
  "name": "symfony/process",
5625
- "version": "v3.4.43",
5626
  "source": {
5627
  "type": "git",
5628
  "url": "https://github.com/symfony/process.git",
@@ -5685,16 +5698,16 @@
5685
  },
5686
  {
5687
  "name": "symfony/yaml",
5688
- "version": "v3.4.43",
5689
  "source": {
5690
  "type": "git",
5691
  "url": "https://github.com/symfony/yaml.git",
5692
- "reference": "e7fa05917ae931332a42d65b577ece4d497aad81"
5693
  },
5694
  "dist": {
5695
  "type": "zip",
5696
- "url": "https://api.github.com/repos/symfony/yaml/zipball/e7fa05917ae931332a42d65b577ece4d497aad81",
5697
- "reference": "e7fa05917ae931332a42d65b577ece4d497aad81",
5698
  "shasum": ""
5699
  },
5700
  "require": {
@@ -5754,7 +5767,7 @@
5754
  "type": "tidelift"
5755
  }
5756
  ],
5757
- "time": "2020-07-23T09:37:51+00:00"
5758
  },
5759
  {
5760
  "name": "vlucas/phpdotenv",
@@ -7726,12 +7739,12 @@
7726
  "source": {
7727
  "type": "git",
7728
  "url": "https://github.com/wp-cli/wp-cli.git",
7729
- "reference": "49c3cba49ecd40cfac75f30d4e5be996c0b120be"
7730
  },
7731
  "dist": {
7732
  "type": "zip",
7733
- "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/49c3cba49ecd40cfac75f30d4e5be996c0b120be",
7734
- "reference": "49c3cba49ecd40cfac75f30d4e5be996c0b120be",
7735
  "shasum": ""
7736
  },
7737
  "require": {
@@ -7784,7 +7797,7 @@
7784
  "cli",
7785
  "wordpress"
7786
  ],
7787
- "time": "2020-07-05T21:55:14+00:00"
7788
  },
7789
  {
7790
  "name": "wp-cli/wp-cli-bundle",
@@ -8517,16 +8530,16 @@
8517
  },
8518
  {
8519
  "name": "wpdesk/wp-wpdesk-composer",
8520
- "version": "2.8.8",
8521
  "source": {
8522
  "type": "git",
8523
  "url": "https://gitlab.com/wpdesk/wp-wpdesk-composer.git",
8524
- "reference": "255042cc555328b37f6c6d983bb6e904a69317f5"
8525
  },
8526
  "dist": {
8527
  "type": "zip",
8528
- "url": "https://gitlab.com/api/v4/projects/wpdesk%2Fwp-wpdesk-composer/repository/archive.zip?sha=255042cc555328b37f6c6d983bb6e904a69317f5",
8529
- "reference": "255042cc555328b37f6c6d983bb6e904a69317f5",
8530
  "shasum": ""
8531
  },
8532
  "require": {
@@ -8556,7 +8569,7 @@
8556
  "email": "krzysiek@wpdesk.pl"
8557
  }
8558
  ],
8559
- "time": "2020-08-14T08:17:48+00:00"
8560
  },
8561
  {
8562
  "name": "wpdesk/wp-wpdesk-helper",
328
  },
329
  {
330
  "name": "codeception/codeception",
331
+ "version": "4.1.7",
332
  "source": {
333
  "type": "git",
334
  "url": "https://github.com/Codeception/Codeception.git",
335
+ "reference": "220ad18d3c192137d9dc2d0dd8d69a0d82083a26"
336
  },
337
  "dist": {
338
  "type": "zip",
339
+ "url": "https://api.github.com/repos/Codeception/Codeception/zipball/220ad18d3c192137d9dc2d0dd8d69a0d82083a26",
340
+ "reference": "220ad18d3c192137d9dc2d0dd8d69a0d82083a26",
341
  "shasum": ""
342
  },
343
  "require": {
415
  "type": "open_collective"
416
  }
417
  ],
418
+ "time": "2020-08-28T06:37:06+00:00"
419
  },
420
  {
421
  "name": "codeception/lib-asserts",
422
+ "version": "1.13.1",
423
  "source": {
424
  "type": "git",
425
  "url": "https://github.com/Codeception/lib-asserts.git",
426
+ "reference": "263ef0b7eff80643e82f4cf55351eca553a09a10"
427
  },
428
  "dist": {
429
  "type": "zip",
430
+ "url": "https://api.github.com/repos/Codeception/lib-asserts/zipball/263ef0b7eff80643e82f4cf55351eca553a09a10",
431
+ "reference": "263ef0b7eff80643e82f4cf55351eca553a09a10",
432
  "shasum": ""
433
  },
434
  "require": {
435
  "codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.0.3 | ^9.0",
436
+ "ext-dom": "*",
437
  "php": ">=5.6.0 <8.0"
438
  },
439
  "type": "library",
454
  },
455
  {
456
  "name": "Gintautas Miselis"
457
+ },
458
+ {
459
+ "name": "Gustavo Nieves",
460
+ "homepage": "https://medium.com/@ganieves"
461
  }
462
  ],
463
  "description": "Assertion methods used by Codeception core and Asserts module",
464
+ "homepage": "https://codeception.com/",
465
  "keywords": [
466
  "codeception"
467
  ],
468
+ "time": "2020-08-28T07:49:36+00:00"
469
  },
470
  {
471
  "name": "codeception/lib-innerbrowser",
525
  },
526
  {
527
  "name": "codeception/module-asserts",
528
+ "version": "1.3.0",
529
  "source": {
530
  "type": "git",
531
  "url": "https://github.com/Codeception/module-asserts.git",
532
+ "reference": "32e5be519faaeb60ed3692383dcd1b3390ec2667"
533
  },
534
  "dist": {
535
  "type": "zip",
536
+ "url": "https://api.github.com/repos/Codeception/module-asserts/zipball/32e5be519faaeb60ed3692383dcd1b3390ec2667",
537
+ "reference": "32e5be519faaeb60ed3692383dcd1b3390ec2667",
538
  "shasum": ""
539
  },
540
  "require": {
541
  "codeception/codeception": "*@dev",
542
+ "codeception/lib-asserts": "^1.13.1",
543
  "php": ">=5.6.0 <8.0"
544
  },
545
  "conflict": {
564
  },
565
  {
566
  "name": "Gintautas Miselis"
567
+ },
568
+ {
569
+ "name": "Gustavo Nieves",
570
+ "homepage": "https://medium.com/@ganieves"
571
  }
572
  ],
573
  "description": "Codeception module containing various assertions",
574
+ "homepage": "https://codeception.com/",
575
  "keywords": [
576
  "assertions",
577
  "asserts",
578
  "codeception"
579
  ],
580
+ "time": "2020-08-28T08:06:29+00:00"
581
  },
582
  {
583
  "name": "codeception/module-cli",
786
  },
787
  {
788
  "name": "codeception/module-rest",
789
+ "version": "1.2.2",
790
  "source": {
791
  "type": "git",
792
  "url": "https://github.com/Codeception/module-rest.git",
793
+ "reference": "114d640533a2a0a8369d77011fdb3fa36c2ca87f"
794
  },
795
  "dist": {
796
  "type": "zip",
797
+ "url": "https://api.github.com/repos/Codeception/module-rest/zipball/114d640533a2a0a8369d77011fdb3fa36c2ca87f",
798
+ "reference": "114d640533a2a0a8369d77011fdb3fa36c2ca87f",
799
  "shasum": ""
800
  },
801
  "require": {
833
  "codeception",
834
  "rest"
835
  ],
836
+ "time": "2020-08-28T06:55:41+00:00"
837
  },
838
  {
839
  "name": "codeception/module-webdriver",
840
+ "version": "1.1.1",
841
  "source": {
842
  "type": "git",
843
  "url": "https://github.com/Codeception/module-webdriver.git",
844
+ "reference": "237c6cb42d3e914f011d0419e966cbe0cb5d82c6"
845
  },
846
  "dist": {
847
  "type": "zip",
848
+ "url": "https://api.github.com/repos/Codeception/module-webdriver/zipball/237c6cb42d3e914f011d0419e966cbe0cb5d82c6",
849
+ "reference": "237c6cb42d3e914f011d0419e966cbe0cb5d82c6",
850
  "shasum": ""
851
  },
852
  "require": {
888
  "browser-testing",
889
  "codeception"
890
  ],
891
+ "time": "2020-08-06T07:39:31+00:00"
892
  },
893
  {
894
  "name": "codeception/phpunit-wrapper",
1001
  },
1002
  {
1003
  "name": "composer/ca-bundle",
1004
+ "version": "1.2.8",
1005
  "source": {
1006
  "type": "git",
1007
  "url": "https://github.com/composer/ca-bundle.git",
1008
+ "reference": "8a7ecad675253e4654ea05505233285377405215"
1009
  },
1010
  "dist": {
1011
  "type": "zip",
1012
+ "url": "https://api.github.com/repos/composer/ca-bundle/zipball/8a7ecad675253e4654ea05505233285377405215",
1013
+ "reference": "8a7ecad675253e4654ea05505233285377405215",
1014
  "shasum": ""
1015
  },
1016
  "require": {
1058
  "url": "https://packagist.com",
1059
  "type": "custom"
1060
  },
1061
+ {
1062
+ "url": "https://github.com/composer",
1063
+ "type": "github"
1064
+ },
1065
  {
1066
  "url": "https://tidelift.com/funding/github/packagist/composer/composer",
1067
  "type": "tidelift"
1068
  }
1069
  ],
1070
+ "time": "2020-08-23T12:54:47+00:00"
1071
  },
1072
  {
1073
  "name": "composer/composer",
2238
  },
2239
  {
2240
  "name": "lucatume/wp-browser",
2241
+ "version": "2.6.10",
2242
  "source": {
2243
  "type": "git",
2244
  "url": "https://github.com/lucatume/wp-browser.git",
2245
+ "reference": "2a838a67428904ab1bfa0a50515e185f7bc6b5fd"
2246
  },
2247
  "dist": {
2248
  "type": "zip",
2249
+ "url": "https://api.github.com/repos/lucatume/wp-browser/zipball/2a838a67428904ab1bfa0a50515e185f7bc6b5fd",
2250
+ "reference": "2a838a67428904ab1bfa0a50515e185f7bc6b5fd",
2251
  "shasum": ""
2252
  },
2253
  "require": {
2260
  "ext-pdo": "*",
2261
  "mikemclin/laravel-wp-password": "~2.0.0",
2262
  "php": ">=5.6.0",
2263
+ "symfony/filesystem": ">=3.0",
2264
  "symfony/process": ">=2.7 <5.0",
2265
  "vria/nodiacritic": "^0.1.2",
2266
  "wp-cli/wp-cli-bundle": ">=2.0 <3.0.0",
2317
  "codeception",
2318
  "wordpress"
2319
  ],
2320
+ "time": "2020-08-25T11:24:27+00:00"
2321
  },
2322
  {
2323
  "name": "matthiasmullie/minify",
4443
  },
4444
  {
4445
  "name": "seld/jsonlint",
4446
+ "version": "1.8.2",
4447
  "source": {
4448
  "type": "git",
4449
  "url": "https://github.com/Seldaek/jsonlint.git",
4450
+ "reference": "590cfec960b77fd55e39b7d9246659e95dd6d337"
4451
  },
4452
  "dist": {
4453
  "type": "zip",
4454
+ "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/590cfec960b77fd55e39b7d9246659e95dd6d337",
4455
+ "reference": "590cfec960b77fd55e39b7d9246659e95dd6d337",
4456
  "shasum": ""
4457
  },
4458
  "require": {
4498
  "type": "tidelift"
4499
  }
4500
  ],
4501
+ "time": "2020-08-25T06:56:57+00:00"
4502
  },
4503
  {
4504
  "name": "seld/phar-utils",
4597
  },
4598
  {
4599
  "name": "symfony/browser-kit",
4600
+ "version": "v3.4.44",
4601
  "source": {
4602
  "type": "git",
4603
  "url": "https://github.com/symfony/browser-kit.git",
4668
  },
4669
  {
4670
  "name": "symfony/console",
4671
+ "version": "v3.4.44",
4672
  "source": {
4673
  "type": "git",
4674
  "url": "https://github.com/symfony/console.git",
4675
+ "reference": "71da881ad579f0cd66aef8677e4cf6217d8ecd0c"
4676
  },
4677
  "dist": {
4678
  "type": "zip",
4679
+ "url": "https://api.github.com/repos/symfony/console/zipball/71da881ad579f0cd66aef8677e4cf6217d8ecd0c",
4680
+ "reference": "71da881ad579f0cd66aef8677e4cf6217d8ecd0c",
4681
  "shasum": ""
4682
  },
4683
  "require": {
4750
  "type": "tidelift"
4751
  }
4752
  ],
4753
+ "time": "2020-08-09T08:16:57+00:00"
4754
  },
4755
  {
4756
  "name": "symfony/css-selector",
4757
+ "version": "v3.4.44",
4758
  "source": {
4759
  "type": "git",
4760
  "url": "https://github.com/symfony/css-selector.git",
4821
  },
4822
  {
4823
  "name": "symfony/debug",
4824
+ "version": "v3.4.44",
4825
  "source": {
4826
  "type": "git",
4827
  "url": "https://github.com/symfony/debug.git",
4828
+ "reference": "0893a0b07c499a1530614d65869ea6a7b1b8a164"
4829
  },
4830
  "dist": {
4831
  "type": "zip",
4832
+ "url": "https://api.github.com/repos/symfony/debug/zipball/0893a0b07c499a1530614d65869ea6a7b1b8a164",
4833
+ "reference": "0893a0b07c499a1530614d65869ea6a7b1b8a164",
4834
  "shasum": ""
4835
  },
4836
  "require": {
4887
  "type": "tidelift"
4888
  }
4889
  ],
4890
+ "time": "2020-08-09T08:13:48+00:00"
4891
  },
4892
  {
4893
  "name": "symfony/dom-crawler",
4894
+ "version": "v3.4.44",
4895
  "source": {
4896
  "type": "git",
4897
  "url": "https://github.com/symfony/dom-crawler.git",
4898
+ "reference": "702ee651db23dc452bf1fd6dea6ca2f671ed2681"
4899
  },
4900
  "dist": {
4901
  "type": "zip",
4902
+ "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/702ee651db23dc452bf1fd6dea6ca2f671ed2681",
4903
+ "reference": "702ee651db23dc452bf1fd6dea6ca2f671ed2681",
4904
  "shasum": ""
4905
  },
4906
  "require": {
4958
  "type": "tidelift"
4959
  }
4960
  ],
4961
+ "time": "2020-08-09T09:13:53+00:00"
4962
  },
4963
  {
4964
  "name": "symfony/event-dispatcher",
4965
+ "version": "v3.4.44",
4966
  "source": {
4967
  "type": "git",
4968
  "url": "https://github.com/symfony/event-dispatcher.git",
4969
+ "reference": "a0f6858fbf7a524747e87a4c336cab7d0b67c802"
4970
  },
4971
  "dist": {
4972
  "type": "zip",
4973
+ "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a0f6858fbf7a524747e87a4c336cab7d0b67c802",
4974
+ "reference": "a0f6858fbf7a524747e87a4c336cab7d0b67c802",
4975
  "shasum": ""
4976
  },
4977
  "require": {
5035
  "type": "tidelift"
5036
  }
5037
  ],
5038
+ "time": "2020-08-12T14:55:37+00:00"
5039
  },
5040
  {
5041
  "name": "symfony/filesystem",
5042
+ "version": "v3.4.44",
5043
  "source": {
5044
  "type": "git",
5045
  "url": "https://github.com/symfony/filesystem.git",
5046
+ "reference": "8e6eff546d0fe879996fa701ee2f312767e95e50"
5047
  },
5048
  "dist": {
5049
  "type": "zip",
5050
+ "url": "https://api.github.com/repos/symfony/filesystem/zipball/8e6eff546d0fe879996fa701ee2f312767e95e50",
5051
+ "reference": "8e6eff546d0fe879996fa701ee2f312767e95e50",
5052
  "shasum": ""
5053
  },
5054
  "require": {
5099
  "type": "tidelift"
5100
  }
5101
  ],
5102
+ "time": "2020-08-21T12:53:49+00:00"
5103
  },
5104
  {
5105
  "name": "symfony/finder",
5106
+ "version": "v3.4.44",
5107
  "source": {
5108
  "type": "git",
5109
  "url": "https://github.com/symfony/finder.git",
5635
  },
5636
  {
5637
  "name": "symfony/process",
5638
+ "version": "v3.4.44",
5639
  "source": {
5640
  "type": "git",
5641
  "url": "https://github.com/symfony/process.git",
5698
  },
5699
  {
5700
  "name": "symfony/yaml",
5701
+ "version": "v3.4.44",
5702
  "source": {
5703
  "type": "git",
5704
  "url": "https://github.com/symfony/yaml.git",
5705
+ "reference": "4152e36b0f305c2a57aa0233dee56ec27bca4f06"
5706
  },
5707
  "dist": {
5708
  "type": "zip",
5709
+ "url": "https://api.github.com/repos/symfony/yaml/zipball/4152e36b0f305c2a57aa0233dee56ec27bca4f06",
5710
+ "reference": "4152e36b0f305c2a57aa0233dee56ec27bca4f06",
5711
  "shasum": ""
5712
  },
5713
  "require": {
5767
  "type": "tidelift"
5768
  }
5769
  ],
5770
+ "time": "2020-08-26T06:32:27+00:00"
5771
  },
5772
  {
5773
  "name": "vlucas/phpdotenv",
7739
  "source": {
7740
  "type": "git",
7741
  "url": "https://github.com/wp-cli/wp-cli.git",
7742
+ "reference": "339ee0f1cdfba96be69c79500cee2ac7abf10faa"
7743
  },
7744
  "dist": {
7745
  "type": "zip",
7746
+ "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/339ee0f1cdfba96be69c79500cee2ac7abf10faa",
7747
+ "reference": "339ee0f1cdfba96be69c79500cee2ac7abf10faa",
7748
  "shasum": ""
7749
  },
7750
  "require": {
7797
  "cli",
7798
  "wordpress"
7799
  ],
7800
+ "time": "2020-08-26T13:54:56+00:00"
7801
  },
7802
  {
7803
  "name": "wp-cli/wp-cli-bundle",
8530
  },
8531
  {
8532
  "name": "wpdesk/wp-wpdesk-composer",
8533
+ "version": "2.8.9",
8534
  "source": {
8535
  "type": "git",
8536
  "url": "https://gitlab.com/wpdesk/wp-wpdesk-composer.git",
8537
+ "reference": "82fd0dba9b4efb60fd6bfff40c778acf9251ebf3"
8538
  },
8539
  "dist": {
8540
  "type": "zip",
8541
+ "url": "https://gitlab.com/api/v4/projects/wpdesk%2Fwp-wpdesk-composer/repository/archive.zip?sha=82fd0dba9b4efb60fd6bfff40c778acf9251ebf3",
8542
+ "reference": "82fd0dba9b4efb60fd6bfff40c778acf9251ebf3",
8543
  "shasum": ""
8544
  },
8545
  "require": {
8569
  "email": "krzysiek@wpdesk.pl"
8570
  }
8571
  ],
8572
+ "time": "2020-08-27T21:02:51+00:00"
8573
  },
8574
  {
8575
  "name": "wpdesk/wp-wpdesk-helper",
flexible-shipping.php CHANGED
@@ -3,14 +3,14 @@
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.11.4
7
  * Author: WP Desk
8
  * Author URI: https://www.wpdesk.net/
9
  * Text Domain: flexible-shipping
10
  * Domain Path: /lang/
11
- * Requires at least: 4.5
12
- * Tested up to: 5.5
13
- * WC requires at least: 4.0
14
  * WC tested up to: 4.5
15
  * Requires PHP: 5.6
16
  *
@@ -38,7 +38,7 @@ if ( ! defined( 'ABSPATH' ) ) {
38
  } // Exit if accessed directly
39
 
40
  /* THIS VARIABLE CAN BE CHANGED AUTOMATICALLY */
41
- $plugin_version = '3.11.4';
42
 
43
  $plugin_name = 'Flexible Shipping';
44
  $product_id = '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.12.0
7
  * Author: WP Desk
8
  * Author URI: https://www.wpdesk.net/
9
  * Text Domain: flexible-shipping
10
  * Domain Path: /lang/
11
+ * Requires at least: 4.9
12
+ * Tested up to: 5.5.1
13
+ * WC requires at least: 4.2
14
  * WC tested up to: 4.5
15
  * Requires PHP: 5.6
16
  *
38
  } // Exit if accessed directly
39
 
40
  /* THIS VARIABLE CAN BE CHANGED AUTOMATICALLY */
41
+ $plugin_version = '3.12.0';
42
 
43
  $plugin_name = 'Flexible Shipping';
44
  $product_id = 'Flexible Shipping';
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: wpdesk,dyszczo,grola,piotrpo,marcinkolanko
3
  Donate link: https://flexibleshipping.com/table-rate/
4
  Tags: table rate, table rate shipping, conditional shipping, shipping method, 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, shipping, free shipping, advanced shipping
5
  Requires at least: 4.5
6
- Tested up to: 5.5
7
- Stable tag: 3.11.4
8
  Requires PHP: 5.6
9
  License: GPLv3 or later
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -163,6 +163,10 @@ If you are upgrading from the old Flexible Shipping version (1.3.2, woo-flexible
163
 
164
  == Changelog ==
165
 
 
 
 
 
166
  = 3.11.4 - 2020-08-26 =
167
  * Fixed 404 for bulk actions on some servers
168
 
3
  Donate link: https://flexibleshipping.com/table-rate/
4
  Tags: table rate, table rate shipping, conditional shipping, shipping method, 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, shipping, free shipping, advanced shipping
5
  Requires at least: 4.5
6
+ Tested up to: 5.5.1
7
+ Stable tag: 3.12.0
8
  Requires PHP: 5.6
9
  License: GPLv3 or later
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
163
 
164
  == Changelog ==
165
 
166
+ = 3.12.0 - 2020-09-03 =
167
+ * Added free shipping notice
168
+ * Removed Integrations settings when no integrations available
169
+
170
  = 3.11.4 - 2020-08-26 =
171
  * Fixed 404 for bulk actions on some servers
172
 
src/WPDesk/FS/TableRate/ContextualInfo/Creator.php ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Contextual info creator.
4
+ *
5
+ * @package Contextual Info
6
+ */
7
+
8
+ namespace WPDesk\FS\TableRate\ContextualInfo;
9
+
10
+ use FSVendor\WPDesk\PluginBuilder\Plugin\HookableCollection;
11
+
12
+ /**
13
+ * Can create contextual info.
14
+ */
15
+ class Creator implements HookableCollection {
16
+
17
+ use \FSVendor\WPDesk\PluginBuilder\Plugin\HookableParent;
18
+
19
+ const METHOD_TITLE_ELEMENT = 'woocommerce_flexible_shipping_method_title';
20
+ const METHOD_TITLE_AND_METHOD_DESCRIPTION_ELEMENTS = 'woocommerce_flexible_shipping_method_title,woocommerce_flexible_shipping_method_description';
21
+
22
+ /**
23
+ * @var string
24
+ */
25
+ private $base_location_country;
26
+
27
+ /**
28
+ * Flexible_Shipping_Contextual_Info_Creator constructor.
29
+ *
30
+ * @param string $base_location_country .
31
+ */
32
+ public function __construct( $base_location_country ) {
33
+ $this->base_location_country = $base_location_country;
34
+ }
35
+
36
+ /**
37
+ * Hooks.
38
+ */
39
+ public function hooks() {
40
+ $this->hooks_on_hookable_objects();
41
+ }
42
+
43
+ /**
44
+ * Create contextual info.
45
+ */
46
+ public function create_contextual_info() {
47
+ $other_phrases_not_in = array();
48
+
49
+ $phrases_in = $this->get_dhl_express_phrases();
50
+ $this->create_dhl_express_contextual_info( $phrases_in );
51
+ $other_phrases_not_in = $this->merge_phrases( $other_phrases_not_in, $phrases_in );
52
+
53
+ $phrases_in = array( 'fedex' );
54
+ $this->create_fedex_contextual_info( $phrases_in );
55
+ $other_phrases_not_in = $this->merge_phrases( $other_phrases_not_in, $phrases_in );
56
+
57
+ $phrases_in = array( 'ups' );
58
+ $this->create_ups_contextual_info( $phrases_in );
59
+ $other_phrases_not_in = $this->merge_phrases( $other_phrases_not_in, $phrases_in );
60
+
61
+ if ( $this->is_base_location_country_pl() ) {
62
+ $phrases_in = array( 'dpd' );
63
+ $this->create_dpd_contextual_info( $phrases_in );
64
+ $other_phrases_not_in = $this->merge_phrases( $other_phrases_not_in, $phrases_in );
65
+
66
+ $phrases_in = array( 'List', 'poczta polska', 'pocztex', 'polecony', 'poczt' );
67
+ $this->create_enadawca_contextual_info( $phrases_in );
68
+ $other_phrases_not_in = $this->merge_phrases( $other_phrases_not_in, $phrases_in );
69
+
70
+ $phrases_in = array( 'dhl', 'parcel' );
71
+ $this->create_dhl_contextual_info( $phrases_in );
72
+ $other_phrases_not_in = $this->merge_phrases( $other_phrases_not_in, $phrases_in );
73
+
74
+ $phrases_in = array( 'ruch', 'kiosk' );
75
+ $this->create_pwr_contextual_info( $phrases_in );
76
+ $other_phrases_not_in = $this->merge_phrases( $other_phrases_not_in, $phrases_in );
77
+
78
+ $phrases_in = array( 'paczkomat', 'paczka w weekend', 'inpost' );
79
+ $this->create_inpost_contextual_info( $phrases_in );
80
+ $other_phrases_not_in = $this->merge_phrases( $other_phrases_not_in, $phrases_in );
81
+ } else {
82
+ $phrases_in = array( 'air', 'dpd' );
83
+ $this->create_dpd_uk_contextual_info( $phrases_in );
84
+ $other_phrases_not_in = $this->merge_phrases( $other_phrases_not_in, $phrases_in );
85
+ }
86
+
87
+ $this->create_default_contextual_info( $other_phrases_not_in );
88
+ }
89
+
90
+ /**
91
+ * @return array
92
+ */
93
+ private function get_dhl_express_phrases() {
94
+ if ( $this->is_base_location_country_pl() ) {
95
+ return array( 'dhl express' );
96
+ } else {
97
+ return array( 'dhl', 'dhl express' );
98
+ }
99
+ }
100
+
101
+ /**
102
+ * @return bool
103
+ */
104
+ private function is_base_location_country_pl() {
105
+ return 'PL' === $this->base_location_country;
106
+ }
107
+
108
+ /**
109
+ * @param array $phrases1 .
110
+ * @param array $phrases2 .
111
+ *
112
+ * @return array
113
+ */
114
+ private function merge_phrases( array $phrases1, array $phrases2 ) {
115
+ return array_merge( $phrases1, $phrases2 );
116
+ }
117
+
118
+ /**
119
+ * @param array $phrases_in .
120
+ */
121
+ private function create_dhl_express_contextual_info( array $phrases_in ) {
122
+ if ( ! defined( 'FLEXIBLE_SHIPPING_DHL_EXPRESS_VERSION' ) && ! defined( 'FLEXIBLE_SHIPPING_DHL_EXPRESS_PRO_VERSION' ) ) {
123
+ $this->add_hookable(
124
+ new \Flexible_Shipping_Contextual_Info(
125
+ self::METHOD_TITLE_AND_METHOD_DESCRIPTION_ELEMENTS,
126
+ 'dhl_express',
127
+ $phrases_in,
128
+ sprintf(
129
+ // Translators: link.
130
+ __( 'Want to show your customers the DHL Express live rates? %1$sCheck our DHL Express plugin →%2$s', 'flexible-shipping' ),
131
+ '<a class="button button-primary" href="https://wpde.sk/fs-up-dhl-express" target="_blank">',
132
+ '</a>'
133
+ )
134
+ )
135
+ );
136
+ }
137
+ }
138
+
139
+ /**
140
+ * @param array $phrases_in .
141
+ */
142
+ private function create_fedex_contextual_info( array $phrases_in ) {
143
+ if ( ! defined( 'FLEXIBLE_SHIPPING_FEDEX_VERSION' ) && ! defined( 'FLEXIBLE_SHIPPING_FEDEX_PRO_VERSION' ) ) {
144
+ $target_url = $this->is_base_location_country_pl()
145
+ ? 'https://www.wpdesk.pl/sklep/fedex-woocommerce/?utm_source=flexible-shipping-method-fedex&utm_medium=button&utm_campaign=flexible-shipping-integrations'
146
+ : 'https://flexibleshipping.com/products/flexible-shipping-fedex-pro/?utm_source=flexible-shipping-method-fedex&utm_medium=button&utm_campaign=flexible-shipping-integrations';
147
+ $this->add_hookable(
148
+ new \Flexible_Shipping_Contextual_Info(
149
+ self::METHOD_TITLE_AND_METHOD_DESCRIPTION_ELEMENTS,
150
+ 'fedex',
151
+ $phrases_in,
152
+ sprintf(
153
+ // Translators: link.
154
+ __( 'Want to show your customers the FedEx live rates? %1$sCheck our FedEx plugin →%2$s', 'flexible-shipping' ),
155
+ '<a class="button button-primary" href="' . $target_url . '" target="_blank">',
156
+ '</a>'
157
+ )
158
+ )
159
+ );
160
+ }
161
+ }
162
+
163
+ /**
164
+ * @param array $phrases_in .
165
+ */
166
+ private function create_ups_contextual_info( array $phrases_in ) {
167
+ if ( ! defined( 'FLEXIBLE_SHIPPING_UPS_VERSION' ) && ! defined( 'FLEXIBLE_SHIPPING_UPS_PRO_VERSION' ) ) {
168
+ $target_url = $this->is_base_location_country_pl()
169
+ ? 'https://www.wpdesk.pl/sklep/ups-woocommerce/?utm_source=flexible-shipping-method-ups&utm_medium=button&utm_campaign=flexible-shipping-integrations'
170
+ : 'https://flexibleshipping.com/products/flexible-shipping-ups-pro/?utm_source=flexible-shipping-method-ups&utm_medium=button&utm_campaign=flexible-shipping-integrations';
171
+ $this->add_hookable(
172
+ new \Flexible_Shipping_Contextual_Info(
173
+ self::METHOD_TITLE_AND_METHOD_DESCRIPTION_ELEMENTS,
174
+ 'ups',
175
+ $phrases_in,
176
+ sprintf(
177
+ // Translators: link.
178
+ __( 'Want to show your customers the UPS live rates? %1$sCheck our UPS plugin →%2$s', 'flexible-shipping' ),
179
+ '<a class="button button-primary" href="' . $target_url . '" target="_blank">',
180
+ '</a>'
181
+ )
182
+ )
183
+ );
184
+ }
185
+ }
186
+
187
+ /**
188
+ * @param array $phrases_in .
189
+ */
190
+ private function create_dpd_contextual_info( array $phrases_in ) {
191
+ if ( ! defined( 'WOOCOMMERCE_DPD_VERSION' ) ) {
192
+ $this->add_hookable(
193
+ new \Flexible_Shipping_Contextual_Info(
194
+ self::METHOD_TITLE_AND_METHOD_DESCRIPTION_ELEMENTS,
195
+ 'dpd',
196
+ $phrases_in,
197
+ sprintf(
198
+ // Translators: link.
199
+ __( 'Sending your products via DPD? Create the shipments and generate shipping labels directly from your shop using our %1$sDPD integration →%2$s', 'flexible-shipping' ),
200
+ '<a class="button button-primary" href="https://www.wpdesk.pl/sklep/dpd-woocommerce/?utm_source=flexible-shipping-method-dpd&utm_medium=button&utm_campaign=flexible-shipping-integrations" target="_blank">',
201
+ '</a>'
202
+ )
203
+ )
204
+ );
205
+ }
206
+ }
207
+
208
+ /**
209
+ * @param array $phrases_in .
210
+ */
211
+ private function create_enadawca_contextual_info( array $phrases_in ) {
212
+ if ( ! defined( 'WOOCOMMERCE_ENADAWCA_VERSION' ) ) {
213
+ $this->add_hookable(
214
+ new \Flexible_Shipping_Contextual_Info(
215
+ self::METHOD_TITLE_AND_METHOD_DESCRIPTION_ELEMENTS,
216
+ 'enadawca',
217
+ $phrases_in,
218
+ sprintf(
219
+ // Translators: link.
220
+ __( 'Sending your products via Poczta Polska? Create the shipments and generate shipping labels directly from your shop using our %1$sPoczta Polska eNadawca integration →%2$s', 'flexible-shipping' ),
221
+ '<a class="button button-primary" href="https://www.wpdesk.pl/sklep/e-nadawca-poczta-polska-woocommerce/?utm_source=flexible-shipping-method-enadawca&utm_medium=button&utm_campaign=flexible-shipping-integrations" target="_blank">',
222
+ '</a>'
223
+ )
224
+ )
225
+ );
226
+ }
227
+ }
228
+
229
+ /**
230
+ * @param array $phrases_in .
231
+ */
232
+ private function create_dhl_contextual_info( array $phrases_in ) {
233
+ if ( ! defined( 'WOOCOMMERCE_DHL_VERSION' ) ) {
234
+ $this->add_hookable(
235
+ new \Flexible_Shipping_Contextual_Info(
236
+ self::METHOD_TITLE_AND_METHOD_DESCRIPTION_ELEMENTS,
237
+ 'dhl',
238
+ $phrases_in,
239
+ sprintf(
240
+ // Translators: link.
241
+ __( 'Sending your products via DHL? Create the shipments and generate shipping labels directly from your shop using our %1$sDHL integration →%2$s', 'flexible-shipping' ),
242
+ '<a class="button button-primary" href="https://www.wpdesk.pl/sklep/dhl-woocommerce/?utm_source=flexible-shipping-method-dhl&utm_medium=button&utm_campaign=flexible-shipping-integrations" target="_blank">',
243
+ '</a>'
244
+ )
245
+ )
246
+ );
247
+ }
248
+ }
249
+
250
+ /**
251
+ * @param array $phrases_in .
252
+ */
253
+ private function create_pwr_contextual_info( array $phrases_in ) {
254
+ if ( ! defined( 'WOOCOMMERCE_PACZKA_W_RUCHU_VERSION' ) ) {
255
+ $this->add_hookable(
256
+ new \Flexible_Shipping_Contextual_Info(
257
+ self::METHOD_TITLE_AND_METHOD_DESCRIPTION_ELEMENTS,
258
+ 'pwr',
259
+ $phrases_in,
260
+ sprintf(
261
+ // Translators: link.
262
+ __( 'Sending your products via Paczka w Ruchu? Create the shipments and generate shipping labels directly from your shop using our %1$sPaczka w Ruchu integration →%2$s', 'flexible-shipping' ),
263
+ '<a class="button button-primary" href="https://www.wpdesk.pl/sklep/paczka-w-ruchu-woocommerce/?utm_source=flexible-shipping-method-pwr&utm_medium=button&utm_campaign=flexible-shipping-integrations" target="_blank">',
264
+ '</a>'
265
+ )
266
+ )
267
+ );
268
+ }
269
+ }
270
+
271
+ /**
272
+ * @param array $phrases_in .
273
+ */
274
+ private function create_inpost_contextual_info( array $phrases_in ) {
275
+ if ( ! defined( 'WOOCOMMERCE_PACZKOMATY_INPOST_VERSION' ) ) {
276
+ $this->add_hookable(
277
+ new \Flexible_Shipping_Contextual_Info(
278
+ self::METHOD_TITLE_AND_METHOD_DESCRIPTION_ELEMENTS,
279
+ 'inpost',
280
+ $phrases_in,
281
+ sprintf(
282
+ // Translators: link.
283
+ __( 'Sending your products via InPost? Create the shipments and generate shipping labels directly from your shop using our %1$sInPost integration →%2$s', 'flexible-shipping' ),
284
+ '<a class="button button-primary" href="https://www.wpdesk.pl/sklep/paczkomaty-woocommerce/?utm_source=flexible-shipping-method-inpost&utm_medium=button&utm_campaign=flexible-shipping-integrations" target="_blank">',
285
+ '</a>'
286
+ )
287
+ )
288
+ );
289
+ }
290
+ }
291
+
292
+ /**
293
+ * @param array $phrases_in .
294
+ */
295
+ private function create_dpd_uk_contextual_info( array $phrases_in ) {
296
+ if ( ! defined( 'WOOCOMMERCE_DPD_UK_VERSION' ) ) {
297
+ $this->add_hookable(
298
+ new \Flexible_Shipping_Contextual_Info(
299
+ self::METHOD_TITLE_AND_METHOD_DESCRIPTION_ELEMENTS,
300
+ 'inpost',
301
+ $phrases_in,
302
+ sprintf(
303
+ // Translators: link.
304
+ __( 'Sending your products via DPD UK? Create the shipments and generate shipping labels directly from your shop using our %1$sDPD UK integration →%2$s', 'flexible-shipping' ),
305
+ '<a class="button button-primary" href="https://flexibleshipping.com/products/dpd-uk-dpd-local-woocommerce/?utm_source=flexible-shipping-method-dpd&utm_medium=button&utm_campaign=flexible-shipping-integrations" target="_blank">',
306
+ '</a>'
307
+ )
308
+ )
309
+ );
310
+ }
311
+ }
312
+
313
+ /**
314
+ * Crate default contextual info.
315
+ *
316
+ * @param array $phrases_not_in .
317
+ */
318
+ private function create_default_contextual_info( array $phrases_not_in ) {
319
+ $this->add_hookable(
320
+ new \Flexible_Shipping_Contextual_Info(
321
+ self::METHOD_TITLE_ELEMENT,
322
+ 'other',
323
+ array(),
324
+ $this->create_html_for_default_contextual_info(),
325
+ $phrases_not_in
326
+ )
327
+ );
328
+ }
329
+
330
+ /**
331
+ * @return string
332
+ */
333
+ private function create_html_for_default_contextual_info() {
334
+ if ( 'PL' === $this->base_location_country ) {
335
+ return __( 'Check our further shipping integrations with DPD, DHL, InPost, eNadawca and Paczka w Ruchu.', 'flexible-shipping' ) . '&nbsp;&nbsp;' .
336
+ sprintf(
337
+ // Translators: link.
338
+ __( '%1$sAdd integrations%2$s', 'flexible-shipping' ),
339
+ '<a class="button button-primary" href="https://www.wpdesk.pl/kategoria-produktu/integracje-wysylkowe/?utm_source=flexible-shipping-method&utm_medium=button&utm_campaign=flexible-shipping-integrations" target="_blank">',
340
+ ' &rarr;</a>'
341
+ );
342
+ } else {
343
+ return __( 'Check our further shipping integration with DPD UK and FedEx / UPS live rates plugins.', 'flexible-shipping' ) . '&nbsp;&nbsp;' .
344
+ sprintf(
345
+ // Translators: link.
346
+ __( '%1$sAdd integration%2$s', 'flexible-shipping' ),
347
+ '<a class="button button-primary" href="https://flexibleshipping.com/product-category/integrations/?utm_source=flexible-shipping-method&utm_medium=button&utm_campaign=flexible-shipping-integrations" target="_blank">',
348
+ ' &rarr;</a>'
349
+ );
350
+ }
351
+ }
352
+
353
+ }
src/WPDesk/FS/TableRate/FreeShipping/FreeShippingNotice.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Free Shipping Notice.
4
+ *
5
+ * @package WPDesk\FS\TableRate\FreeShipping
6
+ */
7
+
8
+ namespace WPDesk\FS\TableRate\FreeShipping;
9
+
10
+ use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable;
11
+
12
+ /**
13
+ * Can display free shipping notice.
14
+ */
15
+ class FreeShippingNotice implements Hookable {
16
+
17
+ const FLEXIBLE_SHIPPING_FREE_SHIPPING_NOTICE = 'flexible_shipping_free_shipping_notice';
18
+ const NOTICE_TYPE_SUCCESS = 'success';
19
+
20
+ /**
21
+ * @var \WC_Session
22
+ */
23
+ private $session;
24
+
25
+ /**
26
+ * FreeShippingNotice constructor.
27
+ *
28
+ * @param \WC_Session $session .
29
+ */
30
+ public function __construct( \WC_Session $session ) {
31
+ $this->session = $session;
32
+ }
33
+
34
+ /**
35
+ * Hooks.
36
+ */
37
+ public function hooks() {
38
+ add_action( 'wp_head', array( $this, 'add_notice_if_present' ) );
39
+ add_action( 'woocommerce_after_calculate_totals', array( $this, 'add_notice_if_present' ) );
40
+ }
41
+
42
+ /**
43
+ * Add notice if present.
44
+ */
45
+ public function add_notice_if_present() {
46
+ $this->remove_previous_notices_if_added();
47
+ if ( is_cart() || is_checkout() || wp_doing_ajax() ) {
48
+ $message_text = $this->session->get( FreeShippingNoticeGenerator::SESSION_VARIABLE, '' );
49
+ if ( ! empty( $message_text ) ) {
50
+ wc_add_notice( $message_text, self::NOTICE_TYPE_SUCCESS, array( self::FLEXIBLE_SHIPPING_FREE_SHIPPING_NOTICE => 'yes' ) );
51
+ }
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Remove previously added notices if present.
57
+ */
58
+ private function remove_previous_notices_if_added() {
59
+ $all_notices = wc_get_notices();
60
+ foreach ( $all_notices as $notice_type => $notices_for_type ) {
61
+ foreach ( $notices_for_type as $key => $notice ) {
62
+ if ( isset( $notice['data'] ) && isset( $notice['data'][ self::FLEXIBLE_SHIPPING_FREE_SHIPPING_NOTICE ] ) ) {
63
+ unset( $all_notices[ $notice_type ][ $key ] );
64
+ wc_set_notices( $all_notices );
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ }
src/WPDesk/FS/TableRate/FreeShipping/FreeShippingNoticeGenerator.php ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Free Shipping Notice Generator.
4
+ *
5
+ * @package WPDesk\FS\TableRate\FreeShipping
6
+ */
7
+
8
+ namespace WPDesk\FS\TableRate\FreeShipping;
9
+
10
+ use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable;
11
+
12
+ /**
13
+ * Can generate free shipping notice and save it on session.
14
+ */
15
+ class FreeShippingNoticeGenerator implements Hookable {
16
+
17
+ const SETTING_METHOD_FREE_SHIPPING = 'method_free_shipping';
18
+ const SESSION_VARIABLE = 'flexible_shipping_free_shipping_notice';
19
+ const META_DATA_FS_METHOD = '_fs_method';
20
+
21
+ /**
22
+ * @var \WC_Cart
23
+ */
24
+ private $cart;
25
+
26
+ /**
27
+ * @var \WC_Session
28
+ */
29
+ private $session;
30
+
31
+ /**
32
+ * FreeShippingNotice constructor.
33
+ *
34
+ * @param \WC_Cart $cart .
35
+ * @param \WC_Session $session .
36
+ */
37
+ public function __construct( $cart, $session ) {
38
+ $this->cart = $cart;
39
+ $this->session = $session;
40
+ }
41
+
42
+ /**
43
+ * Hooks.
44
+ */
45
+ public function hooks() {
46
+ add_filter( 'woocommerce_package_rates', array( $this, 'add_free_shipping_notice_if_should' ), 10, 2 );
47
+ }
48
+
49
+ /**
50
+ * @param array $package_rates .
51
+ * @param array $package .
52
+ *
53
+ * @internal Triggered by filter. Must return $package_rates.
54
+ */
55
+ public function add_free_shipping_notice_if_should( $package_rates, $package ) {
56
+ $this->session->set( self::SESSION_VARIABLE, '' );
57
+ if ( ! $this->has_free_shipping_rate( $package_rates ) && $this->has_shipping_rate_with_free_shipping( $package_rates ) ) {
58
+ $this->add_free_shipping_notice_to_session( $package_rates );
59
+ }
60
+
61
+ return $package_rates;
62
+ }
63
+
64
+ /**
65
+ * Add free shipping notice.
66
+ *
67
+ * @param array $package_rates .
68
+ */
69
+ private function add_free_shipping_notice_to_session( $package_rates ) {
70
+ $lowest_free_shipping_limit = $this->get_lowest_free_shipping_limit( $package_rates );
71
+ $amount = $lowest_free_shipping_limit - $this->get_cart_value();
72
+
73
+ $this->session->set( self::SESSION_VARIABLE, $this->prepare_notice_text( $amount ) );
74
+ }
75
+
76
+ /**
77
+ * @param float $amount .
78
+ *
79
+ * @return string
80
+ */
81
+ private function prepare_notice_text( $amount ) {
82
+ $notice_text = sprintf(
83
+ // Translators: cart value and shop link.
84
+ __( 'You only need %1$s more to get free shipping! %2$sContinue shopping%3$s', 'flexible-shipping' ),
85
+ wc_price( $amount ),
86
+ '<a class="button" href="' . esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ) . '">',
87
+ '</a>'
88
+ );
89
+
90
+ /**
91
+ * Notice text for Free Shipping.
92
+ *
93
+ * @param string $notice_text Notice text.
94
+ * @param float $amount Amount left to free shipping.
95
+ *
96
+ * @return string Message text.
97
+ */
98
+ return apply_filters( 'flexible_shipping_free_shipping_notice_text', $notice_text, $amount );
99
+ }
100
+
101
+ /**
102
+ * Has package free shipping rate?
103
+ *
104
+ * @param array $package_rates .
105
+ *
106
+ * @return bool
107
+ */
108
+ private function has_free_shipping_rate( $package_rates ) {
109
+ /** @var \WC_Shipping_Rate $package_rate */
110
+ foreach ( $package_rates as $package_rate ) {
111
+ if ( floatval( $package_rate->get_cost() ) === 0.0 && ! $this->is_excluded_shipping_method( $package_rate->get_method_id() ) ) {
112
+ return true;
113
+ }
114
+ }
115
+ return false;
116
+ }
117
+
118
+ /**
119
+ * Is shipping method excluded from free shipping?
120
+ *
121
+ * @param string $method_id .
122
+ *
123
+ * @return bool
124
+ */
125
+ private function is_excluded_shipping_method( $method_id ) {
126
+ /**
127
+ * Exclude methods from free shipping.
128
+ *
129
+ * @param array $excluded_methods
130
+ *
131
+ * @return array
132
+ */
133
+ $excluded_methods = apply_filters( 'flexible_shipping_free_shipping_notice_excluded_methods', array( 'local_pickup' ) );
134
+ return in_array(
135
+ $method_id,
136
+ $excluded_methods,
137
+ true
138
+ );
139
+ }
140
+
141
+ /**
142
+ * Has package rate with free shipping?
143
+ *
144
+ * @param array $package_rates .
145
+ *
146
+ * @return bool
147
+ */
148
+ private function has_shipping_rate_with_free_shipping( $package_rates ) {
149
+ /** @var \WC_Shipping_Rate $package_rate */
150
+ foreach ( $package_rates as $package_rate ) {
151
+ if ( $package_rate->get_method_id() === \WPDesk_Flexible_Shipping::METHOD_ID ) {
152
+ $meta_data = $package_rate->get_meta_data();
153
+ if ( isset( $meta_data[ self::META_DATA_FS_METHOD ] ) ) {
154
+ if ( $this->has_shipping_method_free_shipping_notice_enabled( $meta_data[ self::META_DATA_FS_METHOD ] ) ) {
155
+ return true;
156
+ }
157
+ }
158
+ }
159
+ }
160
+ return false;
161
+ }
162
+
163
+ /**
164
+ * @param array $fs_method .
165
+ *
166
+ * @return bool
167
+ */
168
+ private function has_shipping_method_free_shipping_notice_enabled( array $fs_method ) {
169
+ return isset( $fs_method[ self::SETTING_METHOD_FREE_SHIPPING ] )
170
+ && isset( $fs_method[ \WPDesk_Flexible_Shipping::SETTING_METHOD_FREE_SHIPPING_NOTICE ] )
171
+ && 'yes' === $fs_method[ \WPDesk_Flexible_Shipping::SETTING_METHOD_FREE_SHIPPING_NOTICE ];
172
+ }
173
+
174
+ /**
175
+ * Returns current cart value.
176
+ *
177
+ * @return float
178
+ */
179
+ private function get_cart_value() {
180
+ return $this->cart->display_prices_including_tax() ? $this->cart->get_cart_contents_total() + $this->cart->get_cart_contents_tax() : $this->cart->get_cart_contents_total();
181
+ }
182
+
183
+ /**
184
+ * Returns lowest free shipping limit from available rates.
185
+ *
186
+ * @param array $package_rates .
187
+ *
188
+ * @return float
189
+ */
190
+ private function get_lowest_free_shipping_limit( $package_rates ) {
191
+ $lowest_free_shipping_limit = null;
192
+ /** @var \WC_Shipping_Rate $package_rate */
193
+ foreach ( $package_rates as $package_rate ) {
194
+ if ( $this->is_package_rate_from_flexible_shipping( $package_rate ) ) {
195
+ $meta_data = $package_rate->get_meta_data();
196
+ $fs_method = isset( $meta_data[ self::META_DATA_FS_METHOD ] ) ? $meta_data[ self::META_DATA_FS_METHOD ] : array();
197
+ if ( $this->has_shipping_method_free_shipping_notice_enabled( $fs_method ) ) {
198
+ $method_free_shipping_limit = round( floatval( $fs_method[ self::SETTING_METHOD_FREE_SHIPPING ] ), wc_get_rounding_precision() );
199
+ $lowest_free_shipping_limit = min(
200
+ $method_free_shipping_limit,
201
+ null === $lowest_free_shipping_limit ? $method_free_shipping_limit : $lowest_free_shipping_limit
202
+ );
203
+ }
204
+ }
205
+ }
206
+
207
+ return $lowest_free_shipping_limit;
208
+ }
209
+
210
+ /**
211
+ * @param \WC_Shipping_Rate $package_rate .
212
+ *
213
+ * @return bool
214
+ */
215
+ private function is_package_rate_from_flexible_shipping( \WC_Shipping_Rate $package_rate ) {
216
+ return $package_rate->get_method_id() === \WPDesk_Flexible_Shipping::METHOD_ID;
217
+ }
218
+
219
+ }
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit32cc3786e09c42974bc2c50dd62d5b7a::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit5aa7666439b455856d9cb7e8d2521f92::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -310,6 +310,9 @@ return array(
310
  'WPDesk\\FS\\Rate\\SecondRateNotice' => $baseDir . '/classes/wp-wpdesk-fs-shipment/rate-notices/second-rate-notice.php',
311
  'WPDesk\\FS\\Rate\\ThirdRateNotice' => $baseDir . '/classes/wp-wpdesk-fs-shipment/rate-notices/third-rate-notice.php',
312
  'WPDesk\\FS\\Rate\\WPDesk_Flexible_Shipping_Rate_Notice' => $baseDir . '/classes/wp-wpdesk-fs-shipment/rate-notice.php',
 
 
 
313
  'WPDesk\\FS\\TableRate\\NewRulesTableBanner\\RulesBannerClickedOption' => $baseDir . '/src/WPDesk/FS/TableRate/NewRulesTableBanner/RulesBannerClickedOption.php',
314
  'WPDesk\\FS\\TableRate\\NewRulesTableBanner\\RulesBannerDontLikeOption' => $baseDir . '/src/WPDesk/FS/TableRate/NewRulesTableBanner/RulesBannerDontLikeOption.php',
315
  'WPDesk\\FS\\TableRate\\NewRulesTableBanner\\RulesBannerLikeOption' => $baseDir . '/src/WPDesk/FS/TableRate/NewRulesTableBanner/RulesBannerLikeOption.php',
310
  'WPDesk\\FS\\Rate\\SecondRateNotice' => $baseDir . '/classes/wp-wpdesk-fs-shipment/rate-notices/second-rate-notice.php',
311
  'WPDesk\\FS\\Rate\\ThirdRateNotice' => $baseDir . '/classes/wp-wpdesk-fs-shipment/rate-notices/third-rate-notice.php',
312
  'WPDesk\\FS\\Rate\\WPDesk_Flexible_Shipping_Rate_Notice' => $baseDir . '/classes/wp-wpdesk-fs-shipment/rate-notice.php',
313
+ 'WPDesk\\FS\\TableRate\\ContextualInfo\\Creator' => $baseDir . '/src/WPDesk/FS/TableRate/ContextualInfo/Creator.php',
314
+ 'WPDesk\\FS\\TableRate\\FreeShipping\\FreeShippingNotice' => $baseDir . '/src/WPDesk/FS/TableRate/FreeShipping/FreeShippingNotice.php',
315
+ 'WPDesk\\FS\\TableRate\\FreeShipping\\FreeShippingNoticeGenerator' => $baseDir . '/src/WPDesk/FS/TableRate/FreeShipping/FreeShippingNoticeGenerator.php',
316
  'WPDesk\\FS\\TableRate\\NewRulesTableBanner\\RulesBannerClickedOption' => $baseDir . '/src/WPDesk/FS/TableRate/NewRulesTableBanner/RulesBannerClickedOption.php',
317
  'WPDesk\\FS\\TableRate\\NewRulesTableBanner\\RulesBannerDontLikeOption' => $baseDir . '/src/WPDesk/FS/TableRate/NewRulesTableBanner/RulesBannerDontLikeOption.php',
318
  'WPDesk\\FS\\TableRate\\NewRulesTableBanner\\RulesBannerLikeOption' => $baseDir . '/src/WPDesk/FS/TableRate/NewRulesTableBanner/RulesBannerLikeOption.php',
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit32cc3786e09c42974bc2c50dd62d5b7a
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit32cc3786e09c42974bc2c50dd62d5b7a
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit32cc3786e09c42974bc2c50dd62d5b7a', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit32cc3786e09c42974bc2c50dd62d5b7a', '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\ComposerStaticInit32cc3786e09c42974bc2c50dd62d5b7a::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit5aa7666439b455856d9cb7e8d2521f92
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit5aa7666439b455856d9cb7e8d2521f92', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit5aa7666439b455856d9cb7e8d2521f92', '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\ComposerStaticInit5aa7666439b455856d9cb7e8d2521f92::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInit32cc3786e09c42974bc2c50dd62d5b7a
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'W' =>
@@ -342,6 +342,9 @@ class ComposerStaticInit32cc3786e09c42974bc2c50dd62d5b7a
342
  'WPDesk\\FS\\Rate\\SecondRateNotice' => __DIR__ . '/../..' . '/classes/wp-wpdesk-fs-shipment/rate-notices/second-rate-notice.php',
343
  'WPDesk\\FS\\Rate\\ThirdRateNotice' => __DIR__ . '/../..' . '/classes/wp-wpdesk-fs-shipment/rate-notices/third-rate-notice.php',
344
  'WPDesk\\FS\\Rate\\WPDesk_Flexible_Shipping_Rate_Notice' => __DIR__ . '/../..' . '/classes/wp-wpdesk-fs-shipment/rate-notice.php',
 
 
 
345
  'WPDesk\\FS\\TableRate\\NewRulesTableBanner\\RulesBannerClickedOption' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/NewRulesTableBanner/RulesBannerClickedOption.php',
346
  'WPDesk\\FS\\TableRate\\NewRulesTableBanner\\RulesBannerDontLikeOption' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/NewRulesTableBanner/RulesBannerDontLikeOption.php',
347
  'WPDesk\\FS\\TableRate\\NewRulesTableBanner\\RulesBannerLikeOption' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/NewRulesTableBanner/RulesBannerLikeOption.php',
@@ -450,10 +453,10 @@ class ComposerStaticInit32cc3786e09c42974bc2c50dd62d5b7a
450
  public static function getInitializer(ClassLoader $loader)
451
  {
452
  return \Closure::bind(function () use ($loader) {
453
- $loader->prefixLengthsPsr4 = ComposerStaticInit32cc3786e09c42974bc2c50dd62d5b7a::$prefixLengthsPsr4;
454
- $loader->prefixDirsPsr4 = ComposerStaticInit32cc3786e09c42974bc2c50dd62d5b7a::$prefixDirsPsr4;
455
- $loader->fallbackDirsPsr4 = ComposerStaticInit32cc3786e09c42974bc2c50dd62d5b7a::$fallbackDirsPsr4;
456
- $loader->classMap = ComposerStaticInit32cc3786e09c42974bc2c50dd62d5b7a::$classMap;
457
 
458
  }, null, ClassLoader::class);
459
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit5aa7666439b455856d9cb7e8d2521f92
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'W' =>
342
  'WPDesk\\FS\\Rate\\SecondRateNotice' => __DIR__ . '/../..' . '/classes/wp-wpdesk-fs-shipment/rate-notices/second-rate-notice.php',
343
  'WPDesk\\FS\\Rate\\ThirdRateNotice' => __DIR__ . '/../..' . '/classes/wp-wpdesk-fs-shipment/rate-notices/third-rate-notice.php',
344
  'WPDesk\\FS\\Rate\\WPDesk_Flexible_Shipping_Rate_Notice' => __DIR__ . '/../..' . '/classes/wp-wpdesk-fs-shipment/rate-notice.php',
345
+ 'WPDesk\\FS\\TableRate\\ContextualInfo\\Creator' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/ContextualInfo/Creator.php',
346
+ 'WPDesk\\FS\\TableRate\\FreeShipping\\FreeShippingNotice' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/FreeShipping/FreeShippingNotice.php',
347
+ 'WPDesk\\FS\\TableRate\\FreeShipping\\FreeShippingNoticeGenerator' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/FreeShipping/FreeShippingNoticeGenerator.php',
348
  'WPDesk\\FS\\TableRate\\NewRulesTableBanner\\RulesBannerClickedOption' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/NewRulesTableBanner/RulesBannerClickedOption.php',
349
  'WPDesk\\FS\\TableRate\\NewRulesTableBanner\\RulesBannerDontLikeOption' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/NewRulesTableBanner/RulesBannerDontLikeOption.php',
350
  'WPDesk\\FS\\TableRate\\NewRulesTableBanner\\RulesBannerLikeOption' => __DIR__ . '/../..' . '/src/WPDesk/FS/TableRate/NewRulesTableBanner/RulesBannerLikeOption.php',
453
  public static function getInitializer(ClassLoader $loader)
454
  {
455
  return \Closure::bind(function () use ($loader) {
456
+ $loader->prefixLengthsPsr4 = ComposerStaticInit5aa7666439b455856d9cb7e8d2521f92::$prefixLengthsPsr4;
457
+ $loader->prefixDirsPsr4 = ComposerStaticInit5aa7666439b455856d9cb7e8d2521f92::$prefixDirsPsr4;
458
+ $loader->fallbackDirsPsr4 = ComposerStaticInit5aa7666439b455856d9cb7e8d2521f92::$fallbackDirsPsr4;
459
+ $loader->classMap = ComposerStaticInit5aa7666439b455856d9cb7e8d2521f92::$classMap;
460
 
461
  }, null, ClassLoader::class);
462
  }