Flexible Shipping for WooCommerce - Version 3.13.0

Version Description

  • 2020-09-09 =
  • Removed tax calculation method notice
  • Removed redundant shipments data
  • Fixed negative rate costs
  • Added weight rounding on cart contents
Download this release

Release Info

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

Code changes from version 3.12.0 to 3.13.0

classes/table-rate/shipping-method.php CHANGED
@@ -319,7 +319,9 @@ class WPDesk_Flexible_Shipping extends WC_Shipping_Method {
319
  if ( isset( $_POST['woocommerce_' . $this->id . '_method_enabled'] ) && $_POST['woocommerce_' . $this->id . '_method_enabled'] == 1 )
320
  {$shipping_method['method_enabled'] = 'yes';}
321
  //
322
- $shipping_method['method_integration'] = sanitize_text_field( wp_unslash( $_POST['woocommerce_' . $this->id . '_method_integration'] ) );
 
 
323
  //
324
  $shipping_method = apply_filters( 'flexible_shipping_process_admin_options', $shipping_method );
325
  //
@@ -616,6 +618,8 @@ class WPDesk_Flexible_Shipping extends WC_Shipping_Method {
616
  continue;
617
  }
618
 
 
 
619
  foreach ( $shipping_method[ self::SETTING_METHOD_RULES ] as $rule_key => $method_rule ) {
620
  $rule_triggered = false;
621
 
@@ -657,7 +661,7 @@ class WPDesk_Flexible_Shipping extends WC_Shipping_Method {
657
  else {
658
  $max = floatval( $method_rule['max'] );
659
  }
660
- $contents_weight = floatval( $this->cart_weight() );
661
  if ( $contents_weight >= $min && $contents_weight <= $max ) {
662
  $rule_triggered = true;
663
  }
@@ -717,6 +721,38 @@ class WPDesk_Flexible_Shipping extends WC_Shipping_Method {
717
  }
718
  }
719
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
720
  /**
721
  * Calculate contents cost.
722
  *
@@ -807,14 +843,7 @@ class WPDesk_Flexible_Shipping extends WC_Shipping_Method {
807
  * @return float
808
  */
809
  public function cart_weight() {
810
- if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
811
- add_filter( 'woocommerce_product_weight', array( $this, 'woocommerce_product_weight' ) );
812
- }
813
- $cart_weight = WC()->cart->get_cart_contents_weight();
814
- if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
815
- remove_filter( 'woocommerce_product_weight', array( $this, 'woocommerce_product_weight' ) );
816
- }
817
- return round( $cart_weight, apply_filters( 'flexible_shipping_weight_rounding_precision', self::WEIGHT_ROUNDING_PRECISION ) );
818
  }
819
 
820
  function calculate_method_cost( $shipping_method, $rule_costs ) {
319
  if ( isset( $_POST['woocommerce_' . $this->id . '_method_enabled'] ) && $_POST['woocommerce_' . $this->id . '_method_enabled'] == 1 )
320
  {$shipping_method['method_enabled'] = 'yes';}
321
  //
322
+ if ( isset( $_POST['woocommerce_' . $this->id . '_method_integration'] ) ) {
323
+ $shipping_method['method_integration'] = sanitize_text_field( wp_unslash( $_POST[ 'woocommerce_' . $this->id . '_method_integration' ] ) );
324
+ }
325
  //
326
  $shipping_method = apply_filters( 'flexible_shipping_process_admin_options', $shipping_method );
327
  //
618
  continue;
619
  }
620
 
621
+ $weight_rounding_precision = $this->get_weight_rounding_precision( $shipping_method[ self::SETTING_METHOD_RULES ] );
622
+
623
  foreach ( $shipping_method[ self::SETTING_METHOD_RULES ] as $rule_key => $method_rule ) {
624
  $rule_triggered = false;
625
 
661
  else {
662
  $max = floatval( $method_rule['max'] );
663
  }
664
+ $contents_weight = round( $this->cart_weight(), $weight_rounding_precision );
665
  if ( $contents_weight >= $min && $contents_weight <= $max ) {
666
  $rule_triggered = true;
667
  }
721
  }
722
  }
723
 
724
+ /**
725
+ * Add a shipping rate.
726
+ *
727
+ * @param array $args .
728
+ */
729
+ public function add_rate( $args = array() ) {
730
+ parent::add_rate( $this->set_zero_cost_if_negative( $args ) );
731
+ }
732
+
733
+ /**
734
+ * @param array $args.
735
+ *
736
+ * @return array
737
+ */
738
+ private function set_zero_cost_if_negative( $args = array() ) {
739
+ if ( isset( $args['cost'] ) && 0.0 > (float) $args['cost'] ) {
740
+ $args['cost'] = 0.0;
741
+ }
742
+
743
+ return $args;
744
+ }
745
+
746
+ /**
747
+ * @param array $shipping_method_rules .
748
+ *
749
+ * @return int
750
+ */
751
+ private function get_weight_rounding_precision( array $shipping_method_rules ) {
752
+ $weight_rounding = new \FSVendor\WPDesk\FS\TableRate\Weight\Rounding( $shipping_method_rules );
753
+ return (int) apply_filters( 'flexible_shipping_weight_rounding_precision', $weight_rounding->get_rounding_from_rules() );
754
+ }
755
+
756
  /**
757
  * Calculate contents cost.
758
  *
843
  * @return float
844
  */
845
  public function cart_weight() {
846
+ return (float) WC()->cart->get_cart_contents_weight();
 
 
 
 
 
 
 
847
  }
848
 
849
  function calculate_method_cost( $shipping_method, $rule_costs ) {
classes/wp-wpdesk-fs-shipment/admin-notices.php CHANGED
@@ -1,237 +1,133 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- exit;
5
- } // Exit if accessed directly
6
-
7
- if ( ! class_exists( 'WPDesk_Flexible_Shipping_Admin_Notices' ) ) {
8
-
9
- class WPDesk_Flexible_Shipping_Admin_Notices {
10
-
11
- /**
12
- *
13
- */
14
- const SETTINGS_CHECKED_OPTION_NAME = 'flexible_shipping_smsc';
15
-
16
- /**
17
- *
18
- */
19
- const SETTINGS_CHECKED_OPTION_NAME_DISMISS = 'flexible_shipping_smsc_dismiss';
20
-
21
- /**
22
- *
23
- */
24
- const SETTINGS_CHECKED_OPTION_VALUE_SHOW_MESSAGE = '1';
25
-
26
- /**
27
- *
28
- */
29
- const SETTINGS_CHECKED_OPTION_VALUE_DO_NOT_SHOW_MESSAGE = '2';
30
-
31
- /**
32
- *
33
- */
34
- const BASED_ON_VALUE = 'value';
35
-
36
- /**
37
- * @var Flexible_Shipping_Plugin
38
- */
39
- private $plugin;
40
-
41
- /**
42
- * WPDesk_Flexible_Shipping_Export constructor.
43
- *
44
- * @param Flexible_Shipping_Plugin $plugin
45
- */
46
- public function __construct( Flexible_Shipping_Plugin $plugin ) {
47
- $this->plugin = $plugin;
48
- $this->hooks();
49
- }
50
-
51
- /**
52
- *
53
- */
54
- private function hooks() {
55
- //add_action( 'admin_notices', array( $this, 'admin_notices_plugin_versions' ) );
56
- add_action( 'admin_notices', array( $this, 'admin_notices_plugin_activepayments' ) );
57
- add_action( 'admin_notices', array( $this, 'admin_notices_plugin_enadawca' ) );
58
- add_action( 'admin_notices', array( $this, 'admin_notices_plugin_pwr' ) );
59
- add_action( 'admin_notices', array( $this, 'admin_notices_plugin_woo_fs' ) );
60
-
61
- add_action( 'admin_notices', array( $this, 'admin_notices_taxes' ) );
62
-
63
- add_action( 'wp_ajax_flexible_shipping_taxes_notice', array( $this, 'wp_ajax_flexible_shipping_taxes_notice' ) );
64
- }
65
-
66
- /**
67
- *
68
- */
69
- public function wp_ajax_flexible_shipping_taxes_notice() {
70
- update_option( self::SETTINGS_CHECKED_OPTION_NAME_DISMISS, 1 );
71
- }
72
 
73
 
74
- /**
75
- * @param WC_Shipping_Method $shipping_method
76
- *
77
- * @return bool
78
- */
79
- private function has_value_based_rule( $shipping_method ) {
80
- $methods = get_option( 'flexible_shipping_methods_' . $shipping_method->instance_id, array() );
81
- if ( is_array( $methods ) ) {
82
- foreach ( $methods as $method_settings ) {
83
- if ( isset( $method_settings['method_rules'] ) && is_array( $method_settings['method_rules'] ) ) {
84
- foreach ( $method_settings['method_rules'] as $rule ) {
85
- if ( isset( $rule['based_on'] ) && $rule['based_on'] == self::BASED_ON_VALUE ) {
86
- return true;
87
- }
88
  }
89
  }
90
  }
91
  }
92
- return false;
93
- }
94
-
95
- /**
96
- *
97
- */
98
- private function update_show_admin_notice_taxes_option() {
99
- $has_value_based_rule = false;
100
- $shipping_zones = WC_Shipping_Zones::get_zones();
101
- $shipping_zones[0] = WC_Shipping_Zones::get_zone_by( 'zone_id', 0 );
102
- foreach ( $shipping_zones as $zone_id => $shipping_zone_array ) {
103
- $shipping_zone = WC_Shipping_Zones::get_zone( $zone_id );
104
- /** @var WC_Shipping_Zone $shipping_zone */
105
- $shipping_methods = $shipping_zone->get_shipping_methods();
106
- foreach ( $shipping_methods as $shipping_method ) {
107
- /** @var WC_Shipping_Method $shipping_method */
108
- if ( $shipping_method->id == 'flexible_shipping' ) {
109
- $has_value_based_rule = $has_value_based_rule || $this->has_value_based_rule( $shipping_method );
110
- }
111
- }
112
- }
113
- if ( $has_value_based_rule ) {
114
- $shipping_methods_settings_checked = self::SETTINGS_CHECKED_OPTION_VALUE_SHOW_MESSAGE;
115
- }
116
- else {
117
- $shipping_methods_settings_checked = self::SETTINGS_CHECKED_OPTION_VALUE_DO_NOT_SHOW_MESSAGE;
118
- }
119
- update_option( self::SETTINGS_CHECKED_OPTION_NAME, $shipping_methods_settings_checked );
120
  }
121
 
122
- /**
123
- * @return bool
124
- */
125
- public function is_show_admin_notice_taxes() {
126
- $shipping_methods_settings_checked = get_option( self::SETTINGS_CHECKED_OPTION_NAME, '0' );
127
- if ( $shipping_methods_settings_checked == '0' ) {
128
- $this->update_show_admin_notice_taxes_option();
129
- $shipping_methods_settings_checked = get_option( self::SETTINGS_CHECKED_OPTION_NAME, '0' );
130
- }
131
- return $shipping_methods_settings_checked == self::SETTINGS_CHECKED_OPTION_VALUE_SHOW_MESSAGE;
132
- }
133
 
134
- /**
135
- * @return bool
136
- */
137
- public function is_in_zones() {
138
- if ( isset( $_GET['page'] ) && sanitize_key( $_GET['page'] ) == 'wc-settings'
139
- && isset( $_GET['tab'] ) && sanitize_key( $_GET['tab'] ) == 'shipping'
140
- && ( !isset( $_GET['section'] ) || $_GET['section'] == '' )
141
- ) {
142
- return true;
143
- }
144
- return false;
145
  }
146
 
147
- /**
148
- * @return bool
149
- */
150
- public function is_admin_notice_taxes_dismissed() {
151
- if ( get_option( self::SETTINGS_CHECKED_OPTION_NAME_DISMISS, '0' ) == '1' ) {
152
- return true;
153
- }
154
- return false;
155
- }
156
 
157
- /**
158
- *
159
- */
160
- public function admin_notices_taxes() {
161
- if ( wc_tax_enabled() && !$this->is_admin_notice_taxes_dismissed() && $this->is_show_admin_notice_taxes() ) {
162
- $class = 'notice notice-error is-dismissible flexible-shipping-taxes-notice';
163
- $message = sprintf(
164
- __( 'Flexible Shipping has changed the calculation method for shipping rules. Currently, the cart value for rules based on price is determined by WooCommerce tax option "Display prices during cart and checkout". You should check the %ssettings%s.', 'flexible-shipping' ),
165
- '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=tax' ) . '">',
166
- '</a>'
167
- );
168
  $this->print_notice( $class, $message );
169
  }
170
  }
 
171
 
172
- /*
173
- *
174
- */
175
- public function admin_notices_plugin_activepayments() {
176
- if ( is_plugin_active( 'woocommerce-active-payments/activepayments.php' ) ) {
177
- $plugin_activepayments = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-active-payments/activepayments.php' );
178
- $version_compare = version_compare( $plugin_activepayments['Version'], '2.7' );
179
- if ( $version_compare < 0 ) {
180
- $class = 'notice notice-error';
181
- $message = __( 'Flexible Shipping requires at least version 2.7 of Active Payments plugin.', 'flexible-shipping' );
182
- $this->print_notice( $class, $message );
183
- }
184
- }
185
- }
186
-
187
- /**
188
- *
189
- */
190
- public function admin_notices_plugin_enadawca() {
191
- if ( is_plugin_active( 'woocommerce-enadawca/woocommerce-enadawca.php' ) ) {
192
- $plugin_enadawca = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-enadawca/woocommerce-enadawca.php' );
193
- $version_compare = version_compare( $plugin_enadawca['Version'], '1.2' );
194
- if ( $version_compare < 0 ) {
195
- $class = 'notice notice-error';
196
- $message = __( 'Flexible Shipping requires at least version 1.2 of eNadawca plugin.', 'flexible-shipping' );
197
- $this->print_notice( $class, $message );
198
- }
199
- }
200
- }
201
-
202
- /**
203
- *
204
- */
205
- public function admin_notices_plugin_pwr() {
206
- if ( is_plugin_active( 'woocommerce-paczka-w-ruchu/woocommerce-paczka-w-ruchu.php' ) ) {
207
- $plugin_pwr = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-paczka-w-ruchu/woocommerce-paczka-w-ruchu.php' );
208
- $version_compare = version_compare( $plugin_pwr['Version'], '1.1' );
209
- if ( $version_compare < 0 ) {
210
- $class = 'notice notice-error';
211
- $message = __( 'Flexible Shipping requires at least version 1.1 of Paczka w Ruchu plugin.', 'flexible-shipping' );
212
- $this->print_notice( $class, $message );
213
- }
214
  }
215
  }
 
216
 
217
- /*
218
- *
219
- */
220
- public function admin_notices_plugin_woo_fs() {
221
- if ( is_plugin_active( 'woo-flexible-shipping/flexible-shipping.php' ) ) {
222
- $class = 'notice notice-error';
223
- $message = sprintf( __( 'You are using WooCommerce Flexible Shipping below 1.4. Please deactivate it on %splugins page%s. Read about big changes in Flexible Shipping on %sour blog →%s', 'flexible-shipping' ), '<a href="' . admin_url('plugins.php') . '">', '</a>', '<a href="https://www.wpdesk.pl/blog/nowy-flexible-shipping/">', '</a>' );
 
 
 
224
  $this->print_notice( $class, $message );
225
  }
226
  }
 
227
 
228
- /**
229
- * @param string $class
230
- * @param string $message
231
- */
232
- private function print_notice( $class, $message ) {
233
- printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
234
- }
235
-
236
  }
 
237
  }
1
  <?php
2
+ /**
3
+ * Admin notices.
4
+ *
5
+ * @package Flexible Shipping
6
+ */
7
+
8
+ /**
9
+ * Can display notices in admin.
10
+ */
11
+ class WPDesk_Flexible_Shipping_Admin_Notices {
12
+
13
+ const SETTINGS_CHECKED_OPTION_VALUE_SHOW_MESSAGE = '1';
14
+
15
+ const SETTINGS_CHECKED_OPTION_VALUE_DO_NOT_SHOW_MESSAGE = '2';
16
+
17
+ const BASED_ON_VALUE = 'value';
18
+
19
+ /**
20
+ * @var Flexible_Shipping_Plugin
21
+ */
22
+ private $plugin;
23
+
24
+ /**
25
+ * WPDesk_Flexible_Shipping_Export constructor.
26
+ *
27
+ * @param Flexible_Shipping_Plugin $plugin .
28
+ */
29
+ public function __construct( Flexible_Shipping_Plugin $plugin ) {
30
+ $this->plugin = $plugin;
31
+ $this->hooks();
32
+ }
33
 
34
+ /**
35
+ * Hooks.
36
+ */
37
+ private function hooks() {
38
+ add_action( 'admin_notices', array( $this, 'admin_notices_plugin_activepayments' ) );
39
+ add_action( 'admin_notices', array( $this, 'admin_notices_plugin_enadawca' ) );
40
+ add_action( 'admin_notices', array( $this, 'admin_notices_plugin_pwr' ) );
41
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
 
44
+ /**
45
+ * @param WC_Shipping_Method $shipping_method .
46
+ *
47
+ * @return bool
48
+ */
49
+ private function has_value_based_rule( $shipping_method ) {
50
+ $methods = get_option( 'flexible_shipping_methods_' . $shipping_method->instance_id, array() );
51
+ if ( is_array( $methods ) ) {
52
+ foreach ( $methods as $method_settings ) {
53
+ if ( isset( $method_settings['method_rules'] ) && is_array( $method_settings['method_rules'] ) ) {
54
+ foreach ( $method_settings['method_rules'] as $rule ) {
55
+ if ( isset( $rule['based_on'] ) && self::BASED_ON_VALUE === $rule['based_on'] ) {
56
+ return true;
 
57
  }
58
  }
59
  }
60
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
 
63
+ return false;
64
+ }
 
 
 
 
 
 
 
 
 
65
 
66
+ /**
67
+ * @return bool
68
+ */
69
+ public function is_in_zones() {
70
+ if ( isset( $_GET['page'] ) && 'wc-settings' === sanitize_key( $_GET['page'] )
71
+ && isset( $_GET['tab'] ) && 'shipping' === sanitize_key( $_GET['tab'] )
72
+ && ( ! isset( $_GET['section'] ) || '' === $_GET['section'] )
73
+ ) {
74
+ return true;
 
 
75
  }
76
 
77
+ return false;
78
+ }
 
 
 
 
 
 
 
79
 
80
+ /**
81
+ * Active payments notice.
82
+ */
83
+ public function admin_notices_plugin_activepayments() {
84
+ if ( is_plugin_active( 'woocommerce-active-payments/activepayments.php' ) ) {
85
+ $plugin_activepayments = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-active-payments/activepayments.php' );
86
+ $version_compare = version_compare( $plugin_activepayments['Version'], '2.7' );
87
+ if ( $version_compare < 0 ) {
88
+ $class = 'notice notice-error';
89
+ $message = __( 'Flexible Shipping requires at least version 2.7 of Active Payments plugin.', 'flexible-shipping' );
 
90
  $this->print_notice( $class, $message );
91
  }
92
  }
93
+ }
94
 
95
+ /**
96
+ * Enadawca notice.
97
+ */
98
+ public function admin_notices_plugin_enadawca() {
99
+ if ( is_plugin_active( 'woocommerce-enadawca/woocommerce-enadawca.php' ) ) {
100
+ $plugin_enadawca = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-enadawca/woocommerce-enadawca.php' );
101
+ $version_compare = version_compare( $plugin_enadawca['Version'], '1.2' );
102
+ if ( $version_compare < 0 ) {
103
+ $class = 'notice notice-error';
104
+ $message = __( 'Flexible Shipping requires at least version 1.2 of eNadawca plugin.', 'flexible-shipping' );
105
+ $this->print_notice( $class, $message );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
107
  }
108
+ }
109
 
110
+ /**
111
+ * Paczka w Ruchu notice.
112
+ */
113
+ public function admin_notices_plugin_pwr() {
114
+ if ( is_plugin_active( 'woocommerce-paczka-w-ruchu/woocommerce-paczka-w-ruchu.php' ) ) {
115
+ $plugin_pwr = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-paczka-w-ruchu/woocommerce-paczka-w-ruchu.php' );
116
+ $version_compare = version_compare( $plugin_pwr['Version'], '1.1' );
117
+ if ( $version_compare < 0 ) {
118
+ $class = 'notice notice-error';
119
+ $message = __( 'Flexible Shipping requires at least version 1.1 of Paczka w Ruchu plugin.', 'flexible-shipping' );
120
  $this->print_notice( $class, $message );
121
  }
122
  }
123
+ }
124
 
125
+ /**
126
+ * @param string $class .
127
+ * @param string $message .
128
+ */
129
+ private function print_notice( $class, $message ) {
130
+ printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message ); // phpcs:ignore
 
 
131
  }
132
+
133
  }
classes/wp-wpdesk-fs-shipment/shipment/cpt-shipment.php CHANGED
@@ -243,8 +243,6 @@ class WPDesk_Flexible_Shipping_Shipment_CPT {
243
  $shipment->set_meta( '_fs_method', $fs_method );
244
  $shipment->set_meta( '_shipping_id', $shipping_id );
245
  $shipment->set_meta( '_shipping_method', $shipping_method );
246
- $shipment->set_meta( '_package', $packages[ $package_id ] );
247
- $shipment->set_meta( '_packages', $packages );
248
  $shipment->set_created_via_checkout();
249
  $shipment->checkout( $fs_method, $packages[ $package_id ] );
250
  $shipment->save();
243
  $shipment->set_meta( '_fs_method', $fs_method );
244
  $shipment->set_meta( '_shipping_id', $shipping_id );
245
  $shipment->set_meta( '_shipping_method', $shipping_method );
 
 
246
  $shipment->set_created_via_checkout();
247
  $shipment->checkout( $fs_method, $packages[ $package_id ] );
248
  $shipment->save();
composer.lock CHANGED
@@ -4,7 +4,7 @@
4
  "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5
  "This file is @generated automatically"
6
  ],
7
- "content-hash": "8f1c9a632624cbeff66cb8f8286f355d",
8
  "packages": [
9
  {
10
  "name": "psr/log",
@@ -8571,6 +8571,49 @@
8571
  ],
8572
  "time": "2020-08-27T21:02:51+00:00"
8573
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8574
  {
8575
  "name": "wpdesk/wp-wpdesk-helper",
8576
  "version": "2.4.0",
4
  "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5
  "This file is @generated automatically"
6
  ],
7
+ "content-hash": "b41e83cea4d88121da8eddee3f2f4031",
8
  "packages": [
9
  {
10
  "name": "psr/log",
8571
  ],
8572
  "time": "2020-08-27T21:02:51+00:00"
8573
  },
8574
+ {
8575
+ "name": "wpdesk/wp-wpdesk-fs-table-rate",
8576
+ "version": "2.0.0",
8577
+ "source": {
8578
+ "type": "git",
8579
+ "url": "https://gitlab.com/wpdesk/wp-wpdesk-fs-table-rate.git",
8580
+ "reference": "3d9e06f19b81490f84c9ddc83ca0ee6c28cc86ff"
8581
+ },
8582
+ "dist": {
8583
+ "type": "zip",
8584
+ "url": "https://gitlab.com/api/v4/projects/wpdesk%2Fwp-wpdesk-fs-table-rate/repository/archive.zip?sha=3d9e06f19b81490f84c9ddc83ca0ee6c28cc86ff",
8585
+ "reference": "3d9e06f19b81490f84c9ddc83ca0ee6c28cc86ff",
8586
+ "shasum": ""
8587
+ },
8588
+ "require": {
8589
+ "php": ">=5.6"
8590
+ },
8591
+ "require-dev": {
8592
+ "10up/wp_mock": "^0.3",
8593
+ "mockery/mockery": "^1.2",
8594
+ "phpunit/phpunit": "<7",
8595
+ "squizlabs/php_codesniffer": "^3.4.2",
8596
+ "wp-coding-standards/wpcs": "^0.14.1"
8597
+ },
8598
+ "type": "library",
8599
+ "autoload": {
8600
+ "psr-4": {
8601
+ "WPDesk\\FS\\TableRate\\": "src/"
8602
+ }
8603
+ },
8604
+ "notification-url": "https://packagist.org/downloads/",
8605
+ "authors": [
8606
+ {
8607
+ "name": "Krzysiek",
8608
+ "email": "krzysiek@wpdesk.pl"
8609
+ },
8610
+ {
8611
+ "name": "Grzegorz",
8612
+ "email": "grzegorz@wpdesk.net"
8613
+ }
8614
+ ],
8615
+ "time": "2020-09-08T10:01:05+00:00"
8616
+ },
8617
  {
8618
  "name": "wpdesk/wp-wpdesk-helper",
8619
  "version": "2.4.0",
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.12.0
7
  * Author: WP Desk
8
  * Author URI: https://www.wpdesk.net/
9
  * Text Domain: flexible-shipping
@@ -38,7 +38,7 @@ if ( ! defined( 'ABSPATH' ) ) {
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';
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.13.0
7
  * Author: WP Desk
8
  * Author URI: https://www.wpdesk.net/
9
  * Text Domain: flexible-shipping
38
  } // Exit if accessed directly
39
 
40
  /* THIS VARIABLE CAN BE CHANGED AUTOMATICALLY */
41
+ $plugin_version = '3.13.0';
42
 
43
  $plugin_name = 'Flexible Shipping';
44
  $product_id = 'Flexible Shipping';
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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,6 +163,12 @@ If you are upgrading from the old Flexible Shipping version (1.3.2, woo-flexible
163
 
164
  == Changelog ==
165
 
 
 
 
 
 
 
166
  = 3.12.0 - 2020-09-03 =
167
  * Added free shipping notice
168
  * Removed Integrations settings when no integrations available
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.13.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.13.0 - 2020-09-09 =
167
+ * Removed tax calculation method notice
168
+ * Removed redundant shipments data
169
+ * Fixed negative rate costs
170
+ * Added weight rounding on cart contents
171
+
172
  = 3.12.0 - 2020-09-03 =
173
  * Added free shipping notice
174
  * Removed Integrations settings when no integrations available
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit5aa7666439b455856d9cb7e8d2521f92::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit0064257423e0b8f8962fac51c2e3ce79::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -122,6 +122,7 @@ return array(
122
  'FSVendor\\WPDesk\\Composer\\Codeception\\Commands\\RunCodeceptionTests' => $baseDir . '/vendor_prefixed/wpdesk/wp-codeception/src/WPDesk/Composer/Commands/RunCodeceptionTests.php',
123
  'FSVendor\\WPDesk\\Composer\\Codeception\\Commands\\SedTrait' => $baseDir . '/vendor_prefixed/wpdesk/wp-codeception/src/WPDesk/Composer/Commands/SedTrait.php',
124
  'FSVendor\\WPDesk\\Composer\\Codeception\\Plugin' => $baseDir . '/vendor_prefixed/wpdesk/wp-codeception/src/WPDesk/Composer/Plugin.php',
 
125
  'FSVendor\\WPDesk\\Helper\\Debug\\LibraryDebug' => $baseDir . '/vendor_prefixed/wpdesk/wp-wpdesk-helper/src/Debug/LibraryDebug.php',
126
  'FSVendor\\WPDesk\\Helper\\HelperRemoveInfo' => $baseDir . '/vendor_prefixed/wpdesk/wp-wpdesk-helper/src/HelperRemoveNotice.php',
127
  'FSVendor\\WPDesk\\Helper\\HelperRemover' => $baseDir . '/vendor_prefixed/wpdesk/wp-wpdesk-helper/src/HelperRemover.php',
122
  'FSVendor\\WPDesk\\Composer\\Codeception\\Commands\\RunCodeceptionTests' => $baseDir . '/vendor_prefixed/wpdesk/wp-codeception/src/WPDesk/Composer/Commands/RunCodeceptionTests.php',
123
  'FSVendor\\WPDesk\\Composer\\Codeception\\Commands\\SedTrait' => $baseDir . '/vendor_prefixed/wpdesk/wp-codeception/src/WPDesk/Composer/Commands/SedTrait.php',
124
  'FSVendor\\WPDesk\\Composer\\Codeception\\Plugin' => $baseDir . '/vendor_prefixed/wpdesk/wp-codeception/src/WPDesk/Composer/Plugin.php',
125
+ 'FSVendor\\WPDesk\\FS\\TableRate\\Weight\\Rounding' => $baseDir . '/vendor_prefixed/wpdesk/wp-wpdesk-fs-table-rate/src/Weight/Rounding.php',
126
  'FSVendor\\WPDesk\\Helper\\Debug\\LibraryDebug' => $baseDir . '/vendor_prefixed/wpdesk/wp-wpdesk-helper/src/Debug/LibraryDebug.php',
127
  'FSVendor\\WPDesk\\Helper\\HelperRemoveInfo' => $baseDir . '/vendor_prefixed/wpdesk/wp-wpdesk-helper/src/HelperRemoveNotice.php',
128
  'FSVendor\\WPDesk\\Helper\\HelperRemover' => $baseDir . '/vendor_prefixed/wpdesk/wp-wpdesk-helper/src/HelperRemover.php',
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit5aa7666439b455856d9cb7e8d2521f92
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit5aa7666439b455856d9cb7e8d2521f92
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) {
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit0064257423e0b8f8962fac51c2e3ce79
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit0064257423e0b8f8962fac51c2e3ce79', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit0064257423e0b8f8962fac51c2e3ce79', '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\ComposerStaticInit0064257423e0b8f8962fac51c2e3ce79::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 ComposerStaticInit5aa7666439b455856d9cb7e8d2521f92
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'W' =>
@@ -154,6 +154,7 @@ class ComposerStaticInit5aa7666439b455856d9cb7e8d2521f92
154
  'FSVendor\\WPDesk\\Composer\\Codeception\\Commands\\RunCodeceptionTests' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-codeception/src/WPDesk/Composer/Commands/RunCodeceptionTests.php',
155
  'FSVendor\\WPDesk\\Composer\\Codeception\\Commands\\SedTrait' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-codeception/src/WPDesk/Composer/Commands/SedTrait.php',
156
  'FSVendor\\WPDesk\\Composer\\Codeception\\Plugin' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-codeception/src/WPDesk/Composer/Plugin.php',
 
157
  'FSVendor\\WPDesk\\Helper\\Debug\\LibraryDebug' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-wpdesk-helper/src/Debug/LibraryDebug.php',
158
  'FSVendor\\WPDesk\\Helper\\HelperRemoveInfo' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-wpdesk-helper/src/HelperRemoveNotice.php',
159
  'FSVendor\\WPDesk\\Helper\\HelperRemover' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-wpdesk-helper/src/HelperRemover.php',
@@ -453,10 +454,10 @@ class ComposerStaticInit5aa7666439b455856d9cb7e8d2521f92
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
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit0064257423e0b8f8962fac51c2e3ce79
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'W' =>
154
  'FSVendor\\WPDesk\\Composer\\Codeception\\Commands\\RunCodeceptionTests' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-codeception/src/WPDesk/Composer/Commands/RunCodeceptionTests.php',
155
  'FSVendor\\WPDesk\\Composer\\Codeception\\Commands\\SedTrait' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-codeception/src/WPDesk/Composer/Commands/SedTrait.php',
156
  'FSVendor\\WPDesk\\Composer\\Codeception\\Plugin' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-codeception/src/WPDesk/Composer/Plugin.php',
157
+ 'FSVendor\\WPDesk\\FS\\TableRate\\Weight\\Rounding' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-wpdesk-fs-table-rate/src/Weight/Rounding.php',
158
  'FSVendor\\WPDesk\\Helper\\Debug\\LibraryDebug' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-wpdesk-helper/src/Debug/LibraryDebug.php',
159
  'FSVendor\\WPDesk\\Helper\\HelperRemoveInfo' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-wpdesk-helper/src/HelperRemoveNotice.php',
160
  'FSVendor\\WPDesk\\Helper\\HelperRemover' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-wpdesk-helper/src/HelperRemover.php',
454
  public static function getInitializer(ClassLoader $loader)
455
  {
456
  return \Closure::bind(function () use ($loader) {
457
+ $loader->prefixLengthsPsr4 = ComposerStaticInit0064257423e0b8f8962fac51c2e3ce79::$prefixLengthsPsr4;
458
+ $loader->prefixDirsPsr4 = ComposerStaticInit0064257423e0b8f8962fac51c2e3ce79::$prefixDirsPsr4;
459
+ $loader->fallbackDirsPsr4 = ComposerStaticInit0064257423e0b8f8962fac51c2e3ce79::$fallbackDirsPsr4;
460
+ $loader->classMap = ComposerStaticInit0064257423e0b8f8962fac51c2e3ce79::$classMap;
461
 
462
  }, null, ClassLoader::class);
463
  }
vendor_prefixed/wpdesk/wp-wpdesk-fs-table-rate/composer.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "wpdesk\/wp-wpdesk-fs-table-rate",
3
+ "authors": [
4
+ {
5
+ "name": "Krzysiek",
6
+ "email": "krzysiek@wpdesk.pl"
7
+ },
8
+ {
9
+ "name": "Grzegorz",
10
+ "email": "grzegorz@wpdesk.net"
11
+ }
12
+ ],
13
+ "require": {
14
+ "php": ">=5.6"
15
+ },
16
+ "require-dev": {
17
+ "phpunit\/phpunit": "<7",
18
+ "wp-coding-standards\/wpcs": "^0.14.1",
19
+ "squizlabs\/php_codesniffer": "^3.4.2",
20
+ "mockery\/mockery": "^1.2",
21
+ "10up\/wp_mock": "^0.3"
22
+ },
23
+ "autoload": {
24
+ "psr-4": {
25
+ "FSVendor\\WPDesk\\FS\\TableRate\\": "src\/"
26
+ }
27
+ },
28
+ "autoload-dev": {},
29
+ "scripts": {
30
+ "phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never",
31
+ "phpunit-unit-fast": "phpunit --configuration phpunit-unit.xml --no-coverage",
32
+ "phpunit-integration": "phpunit --configuration phpunit-integration.xml --coverage-text --colors=never",
33
+ "phpunit-integration-fast": "phpunit --configuration phpunit-integration.xml --no-coverage"
34
+ }
35
+ }
vendor_prefixed/wpdesk/wp-wpdesk-fs-table-rate/src/Weight/Rounding.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Rounding.
5
+ *
6
+ * @package WPDesk\FS\TableRate
7
+ */
8
+ namespace FSVendor\WPDesk\FS\TableRate\Weight;
9
+
10
+ /**
11
+ * Can compute rounding precision from Flexible Shipping rules.
12
+ */
13
+ class Rounding
14
+ {
15
+ /**
16
+ * @var array
17
+ */
18
+ private $shipping_method_rules;
19
+ /**
20
+ * WeightRounding constructor.
21
+ *
22
+ * @param array $shipping_method_rules .
23
+ */
24
+ public function __construct(array $shipping_method_rules)
25
+ {
26
+ $this->shipping_method_rules = $shipping_method_rules;
27
+ }
28
+ /**
29
+ * @return int
30
+ */
31
+ public function get_rounding_from_rules()
32
+ {
33
+ $rounding = 0;
34
+ foreach ($this->shipping_method_rules as $rule) {
35
+ $rounding = \max($rounding, $this->get_rounding_from_rule($rule));
36
+ }
37
+ return $rounding;
38
+ }
39
+ /**
40
+ * @param array $rule .
41
+ *
42
+ * @return int
43
+ */
44
+ private function get_rounding_from_rule(array $rule)
45
+ {
46
+ if ('weight' === $rule['based_on']) {
47
+ return \max($this->get_rounding_from_value(isset($rule['min']) ? $rule['min'] : ''), $this->get_rounding_from_value(isset($rule['max']) ? $rule['max'] : ''));
48
+ }
49
+ return 0;
50
+ }
51
+ /**
52
+ * @param string $value String representation for float.
53
+ *
54
+ * @return int
55
+ */
56
+ private function get_rounding_from_value($value)
57
+ {
58
+ $parts = \explode('.', $value);
59
+ if (isset($parts[1])) {
60
+ return \strlen($parts[1]);
61
+ }
62
+ return 0;
63
+ }
64
+ }