Flexible Shipping for WooCommerce - Version 1.4

Version Description

  • 2016-06-14 =
  • Converted to English
  • Added Polish (pl_PL) translation
  • Added FREE and PRO versions
Download this release

Release Info

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

Version 1.4

assets/css/admin.css ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @CHARSET "UTF-8";
2
+
3
+ table.flexible_shipping_method_rules td p,
4
+ table.flexible_shipping_method_rules td p input,
5
+ table.flexible_shipping_method_rules td p select {
6
+ margin: 0;
7
+ width: 100%;
8
+ }
9
+
10
+ table.flexible_shipping_method_rules td p input[type=checkbox] {
11
+ margin: 0;
12
+ width: auto;
13
+ }
14
+
15
+ table.flexible_shipping_method_rules th,
16
+ table.flexible_shipping_method_rules td {
17
+ text-align: center;
18
+ }
19
+
20
+ table.flexible_shipping_method_rules th span.woocommerce-help-tip {
21
+ float: none !important;
22
+ }
assets/images/icon-pp.jpg ADDED
Binary file
classes/inspire/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ ?>
classes/inspire/plugin4.php ADDED
@@ -0,0 +1,422 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+
4
+ //set_site_transient('update_plugins', null);
5
+
6
+ if (!class_exists('inspire_Plugin4'))
7
+ {
8
+
9
+ /**
10
+ * Base plugin class for Inspire Labs plugins
11
+ *
12
+ * @author Krzysiek
13
+ *
14
+ */
15
+ abstract class inspire_Plugin4
16
+ {
17
+ const VERSION = '4.0';
18
+ const DEFAULT_TOKEN = '350299001f1cbf2c8f3af7ca3296f0a3';
19
+
20
+ protected $_pluginNamespace = "";
21
+ protected $__wpdeskUpdateUrl = 'http://wpdesk.pl/wp-content/';
22
+
23
+ protected $_pluginPath;
24
+ protected $_templatePath;
25
+ protected $_pluginFilePath;
26
+ protected $_pluginUrl;
27
+
28
+ protected $_defaultViewArgs; // default args given to template
29
+
30
+ public function __construct()
31
+ {
32
+ $this->initBaseVariables();
33
+ }
34
+
35
+ /**
36
+ *
37
+ * @return inspire_Plugin4
38
+ */
39
+ public function getPlugin()
40
+ {
41
+ return $this;
42
+ }
43
+
44
+ public function loadPluginTextDomain()
45
+ {
46
+ load_plugin_textdomain( 'inspire-plugin', FALSE, basename( dirname( __FILE__ ) ) . '/lang/' );
47
+ }
48
+
49
+ /**
50
+ *
51
+ */
52
+ public function initBaseVariables()
53
+ {
54
+ $reflection = new ReflectionClass($this);
55
+
56
+ // Set Plugin Path
57
+ $this->_pluginPath = dirname($reflection->getFileName());
58
+
59
+ // Set Plugin URL
60
+ $this->_pluginUrl = plugin_dir_url($reflection->getFileName());
61
+
62
+ $this->_pluginFilePath = $reflection->getFileName();
63
+
64
+ $this->_templatePath = '/' . $this->_pluginNamespace . '_templates';
65
+
66
+ $this->_defaultViewArgs = array(
67
+ 'pluginUrl' => $this->getPluginUrl()
68
+ );
69
+
70
+ register_activation_hook( $this->_pluginFilePath, array( $this, 'activation' ) );
71
+ register_deactivation_hook( $this->_pluginFilePath, array( $this, 'deactivation' ) );
72
+ register_uninstall_hook( $this->_pluginFilePath, 'inspire_Plugin4::uninstall' );
73
+
74
+ add_action( 'plugins_loaded', array($this, 'loadPluginTextDomain') );
75
+ add_filter( 'plugin_action_links_' . plugin_basename( $this->getPluginFilePath() ), array( $this, 'linksFilter' ) );
76
+
77
+ /*$this->_initPluginUpdates();
78
+ echo '<pre style="margin-left: 170px;">';
79
+ var_dump($this->_pluginPath);
80
+ var_dump($this->_pluginUrl);
81
+ var_dump($this->_pluginFilePath);
82
+ var_dump($this->getTemplatePath());
83
+ var_dump($this->getPluginAssetsUrl());
84
+
85
+ echo '</pre>';*/
86
+
87
+ }
88
+
89
+ /**
90
+ * Plugin activation hook
91
+ */
92
+ public function activation()
93
+ {
94
+
95
+ }
96
+
97
+ /**
98
+ * Plugin deactivation hook
99
+ */
100
+ public function deactivation()
101
+ {
102
+
103
+ }
104
+
105
+ /**
106
+ * Plugin uninstall hook
107
+ */
108
+ public static function uninstall()
109
+ {
110
+
111
+ }
112
+
113
+ /**
114
+ *
115
+ * @return string
116
+ */
117
+ public function getPluginUrl()
118
+ {
119
+ return esc_url(trailingslashit($this->_pluginUrl));
120
+ }
121
+
122
+ public function getPluginAssetsUrl()
123
+ {
124
+ return esc_url(trailingslashit($this->getPluginUrl() . 'assets'));
125
+ }
126
+
127
+ /**
128
+ * @return string
129
+ */
130
+ public function getTemplatePath()
131
+ {
132
+ return trailingslashit($this->_templatePath);
133
+ }
134
+
135
+ public function getPluginFilePath()
136
+ {
137
+ return $this->_pluginFilePath;
138
+ }
139
+
140
+ public function getNamespace()
141
+ {
142
+ return $this->_pluginNamespace;
143
+ }
144
+
145
+ protected function _initPluginUpdates()
146
+ {
147
+ add_filter('pre_set_site_transient_update_plugins', array($this, 'checkForPluginUpdate'));
148
+ //add_filter('plugins_api', array($this, 'pluginApiCall'), 10, 3);
149
+ }
150
+
151
+ protected function getPluginUpdateName()
152
+ {
153
+ return $this->getNamespace() . '/' . str_replace('woocommerce-', '', $this->getNamespace()) .'.php';
154
+ }
155
+
156
+ public function checkForPluginUpdate($checked_data)
157
+ {
158
+ global $wp_version;
159
+
160
+ var_dump('y');
161
+
162
+ if (empty($checked_data->checked))
163
+ return $checked_data;
164
+
165
+ var_dump($checked_data);
166
+
167
+ $args = array(
168
+ 'slug' => $this->getNamespace(),
169
+ 'version' => $checked_data->checked[$this->getPluginUpdateName()],
170
+ );
171
+ $request_string = array(
172
+ 'body' => array(
173
+ 'action' => 'basic_check',
174
+ 'request' => serialize($args),
175
+ 'site' => get_bloginfo('url'),
176
+ 'token' => self::DEFAULT_TOKEN
177
+ ),
178
+ 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')
179
+ );
180
+
181
+ var_dump($request_string); die();
182
+
183
+ // Start checking for an update
184
+ $raw_response = wp_remote_post($this->_wpdeskUpdateUrl, $request_string);
185
+
186
+ if (!is_wp_error($raw_response) && ($raw_response['response']['code'] == 200))
187
+ $response = unserialize($raw_response['body']);
188
+
189
+ if (is_object($response) && !empty($response)) // Feed the update data into WP updater
190
+ $checked_data->response[$this->getNamespace() .'/'. $this->getNamespace() .'.php'] = $response;
191
+
192
+ return $checked_data;
193
+ }
194
+
195
+ function pluginApiCall($def, $action, $args) {
196
+ global $wp_version;
197
+
198
+ if (!isset($args->slug) || ($args->slug != $plugin_slug))
199
+ return false;
200
+
201
+ // Get the current version
202
+ $plugin_info = get_site_transient('update_plugins');
203
+ $current_version = $plugin_info->checked[$this->getPluginUpdateName()];
204
+ $args->version = $current_version;
205
+
206
+ $request_string = array(
207
+ 'body' => array(
208
+ 'action' => $action,
209
+ 'request' => serialize($args),
210
+ 'api-key' => md5(get_bloginfo('url'))
211
+ ),
212
+ 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')
213
+ );
214
+
215
+ $request = wp_remote_post($this->wpdeskServer, $request_string);
216
+
217
+ if (is_wp_error($request)) {
218
+ $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request. <a href="?" onclick="document.location.reload(); return false;">Try again</a>', 'inspire-plugin'), $request->get_error_message());
219
+ } else {
220
+ $res = unserialize($request['body']);
221
+
222
+ if ($res === false)
223
+ $res = new WP_Error('plugins_api_failed', __('An unknown error occurred', 'inspire-plugin'), $request['body']);
224
+ }
225
+
226
+ return $res;
227
+ }
228
+
229
+ /**
230
+ *
231
+ * @param string $message
232
+ * @param string $class
233
+ */
234
+ public function addAdminMessage($message, $class = 'updated')
235
+ {
236
+ $messages = $this->_getAdminMessages();
237
+ if (!is_array($messages))
238
+ {
239
+ $messages = array();
240
+ }
241
+ $messages[$class][] = $message;
242
+ $this->_setAdminMessages($messages);
243
+ }
244
+
245
+ protected function _getAdminMessages()
246
+ {
247
+ return get_option($this->getNamespace() . '_messages');
248
+ }
249
+
250
+ protected function _setAdminMessages($messages)
251
+ {
252
+ update_option($this->getNamespace() . '_messages', $messages);
253
+ }
254
+
255
+ /**
256
+ *
257
+ * @param boolean $clean
258
+ */
259
+ public function getAdminMessagesHtml($clean = true)
260
+ {
261
+ $messages = $this->_getAdminMessages();
262
+ $str = '';
263
+
264
+ if (is_array($messages) && !empty($messages))
265
+ {
266
+ foreach ($messages as $class => $messagesArray)
267
+ {
268
+ $str .= '<div class="' . $class . '" id="message">';
269
+
270
+ foreach ($messagesArray as $message)
271
+ {
272
+ $str .= '<p>' . $message . '</p>';
273
+ }
274
+ $str .= '</div>';
275
+ }
276
+ }
277
+
278
+ if ($clean)
279
+ {
280
+ $this->_setAdminMessages('');
281
+ }
282
+ return $str;
283
+ }
284
+
285
+ public function addFrontMessage($message, $class = 'message')
286
+ {
287
+ $messages = $this->_getFrontMessages();
288
+ if (!is_array($messages))
289
+ {
290
+ $messages = array();
291
+ }
292
+ $messages[$class][] = $message;
293
+ $this->_setFrontMessages($messages);
294
+ }
295
+
296
+ protected function _getFrontMessages()
297
+ {
298
+ return $_SESSION['i-messages'];
299
+ }
300
+
301
+ protected function _setFrontMessages($messages)
302
+ {
303
+ $_SESSION['i-messages'] = $messages;
304
+ }
305
+
306
+ public function getFrontMessagesHtml($clean = true)
307
+ {
308
+ $messages = $this->_getFrontMessages();
309
+ $str = '';
310
+
311
+ if (is_array($messages) && !empty($messages))
312
+ {
313
+ foreach ($messages as $class => $messagesArray)
314
+ {
315
+ foreach ($messagesArray as $message)
316
+ {
317
+ $str .= '<p class="woocommerce-' . $class . '"><strong>' . $message . '</strong></p>';
318
+ }
319
+ }
320
+ }
321
+
322
+ if ($clean)
323
+ {
324
+ $this->_setFrontMessages('');
325
+ }
326
+ return $str;
327
+ }
328
+
329
+ /**
330
+ * Renders end returns selected template
331
+ *
332
+ * @param string $name name of the template
333
+ * @param string $path additional inner path to the template
334
+ * @param array $args args accesible from template
335
+ * @return string
336
+ */
337
+ public function loadTemplate($name, $path = '', $args = array())
338
+ {
339
+ //$args = array_merge($this->_defaultViewArgs, array('textDomain', $this->_textDomain), $args);
340
+ $path = trim($path, '/');
341
+
342
+ if (file_exists($templateName = implode('/', array(get_template_directory(), $this->getTemplatePath(), $path, $name . '.php'))))
343
+ {
344
+ } else {
345
+ $templateName = implode('/', array($this->_pluginPath, $this->getTemplatePath(), $path, $name . '.php'));
346
+ }
347
+
348
+ ob_start();
349
+ include($templateName);
350
+ return ob_get_clean();
351
+ }
352
+
353
+ /**
354
+ * Gets setting value
355
+ *
356
+ * @param string $name
357
+ * @param string $default
358
+ * @return Ambigous <mixed, boolean>
359
+ */
360
+ public function getSettingValue($name, $default = null)
361
+ {
362
+ return get_option($this->getNamespace() . '_' . $name, $default);
363
+ }
364
+
365
+ public function setSettingValue($name, $value)
366
+ {
367
+ return update_option($this->getNamespace() . '_' . $name, $value);
368
+ }
369
+
370
+ public function isSettingValue($name)
371
+ {
372
+ $option = get_option($this->getNamespace() . '_' . $name);
373
+ return !empty($option);
374
+ }
375
+
376
+ /**
377
+ * action_links function.
378
+ *
379
+ * @access public
380
+ * @param mixed $links
381
+ * @return void
382
+ */
383
+ public function linksFilter( $links )
384
+ {
385
+
386
+ $plugin_links = array(
387
+ '<a href="' . admin_url( 'admin.php?page=' . $this->getNamespace() ) . '">' . __( 'Settings', 'inspire-plugin' ) . '</a>',
388
+ '<a href="http://www.wpdesk.pl/docs/' . str_replace('_', '-', $this->getNamespace()) . '_docs/">' . __( 'Docs', 'inspire-plugin' ) . '</a>',
389
+ '<a href="http://www.wpdesk.pl/support/">' . __( 'Support', $this->getTextDomain() ) . '</a>',
390
+ );
391
+
392
+ return array_merge( $plugin_links, $links );
393
+ }
394
+
395
+ /**
396
+ *
397
+ * @param string $name
398
+ */
399
+ protected function _convertCamelCaseToPath($name)
400
+ {
401
+ return strtolower(preg_replace('/([a-z0-9])([A-Z])/', '$1_$2', $name));
402
+ }
403
+
404
+ public function createHelperClass($name)
405
+ {
406
+ require_once('pluginHelper4.php');
407
+ $file = $this->_convertCamelCaseToPath($name); ;
408
+ require_once( plugin_dir_path($this->getPluginFilePath()) . '/classes/' . $file . '.php' );
409
+
410
+ return new $name($this);
411
+ }
412
+
413
+ public function createDependant($name)
414
+ {
415
+ require_once('pluginDependant4.php');
416
+ $file = $this->_convertCamelCaseToPath($name); ;
417
+ require_once( plugin_dir_path($this->getPluginFilePath()) . '/classes/' . $file . '.php' );
418
+
419
+ return new $name($this);
420
+ }
421
+ }
422
+ }
classes/settings-flexible-shipping.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ $docs_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/' : 'https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/';
8
+
9
+ /**
10
+ * Settings for flexible shipping
11
+ */
12
+ $settings = array(
13
+ array(
14
+ 'title' => __( 'Flexible Shipping', 'flexible-shipping' ),
15
+ 'type' => 'title',
16
+ 'description' => sprintf( __( 'See how to %sconfigure Flexible Shipping%s.', 'flexible-shipping' ), '<a href="' . $docs_link . '" target="_blank">', '</a>' ),
17
+ ),
18
+ 'enabled' => array(
19
+ 'title' => __( 'Enable/Disable', 'flexible-shipping' ),
20
+ 'type' => 'checkbox',
21
+ 'label' => __( 'Enable Flexible Shipping', 'flexible-shipping' ),
22
+ 'default' => 'no',
23
+ ),
24
+ 'title' => array(
25
+ 'title' => __( 'Shipping title', 'flexible-shipping' ),
26
+ 'type' => 'text',
27
+ 'description' => __( 'Visible only to admin in WooCommerce settings.', 'flexible-shipping' ),
28
+ 'default' => __( 'Flexible Shipping', 'flexible-shipping' ),
29
+ 'desc_tip' => true
30
+ ),
31
+ 'tax_status' => array(
32
+ 'title' => __( 'Tax Status', 'flexible-shipping' ),
33
+ 'type' => 'select',
34
+ 'class' => 'wc-enhanced-select',
35
+ 'default' => 'taxable',
36
+ 'options' => array(
37
+ 'taxable' => __( 'Taxable', 'flexible-shipping' ),
38
+ 'none' => _x( 'None', 'Tax status', 'woocommerce' )
39
+ )
40
+ ),
41
+ 'title_shipping_methods' => array(
42
+ 'title' => __( 'Shipping Methods', 'flexible-shipping' ),
43
+ 'type' => 'title_shipping_methods',
44
+ 'description' => '',
45
+ ),
46
+ 'shipping_methods' => array(
47
+ 'title' => __( 'Shipping Methods', 'flexible-shipping' ),
48
+ 'type' => 'shipping_methods',
49
+ 'desc_tip' => true
50
+ ),
51
+ );
52
+
53
+ return $settings;
classes/settings-shipping-method-form.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ /**
6
+ * Settings for flexible shipping, shipping method
7
+ */
8
+
9
+ $shipping_classes = array();
10
+ $shipping_classes['0'] = __( 'Select shipping class', 'flexible-shipping' );
11
+ foreach ( WC()->shipping->get_shipping_classes() as $shipping_class ) {
12
+ $shipping_classes[$shipping_class->term_id] = $shipping_class->name;
13
+ }
14
+
15
+ $integrations = get_locale() === 'pl_PL' ? sprintf( __( 'You can add integrations with Paczkomaty InPost, eNadawca Poczta Polska, Paczka w Ruchu. %sView details%s', 'flexible-shipping' ), '<a href="https://www.wpdesk.pl/kategoria-produktu/wysylka/?utm_source=flexible-shipping-method&utm_medium=text-link&utm_campaign=flexible-shipping-integrations" target="_blank">', ' &rarr;</a>' ) : '';
16
+ $integrations_tip = get_locale() === 'pl_PL' ? false : true;
17
+
18
+ $settings = array(
19
+ 'method_enabled' => array(
20
+ 'title' => __( 'Enable/Disable', 'flexible-shipping' ),
21
+ 'type' => 'checkbox',
22
+ 'default' => $shipping_method['method_enabled'],
23
+ 'label' => __( 'Enable this shipping method', 'flexible-shipping' )
24
+ ),
25
+ 'method_title' => array(
26
+ 'title' => __( 'Method Title', 'flexible-shipping' ),
27
+ 'type' => 'text',
28
+ 'description' => __( 'This controls the title which the user sees during checkout.', 'flexible-shipping' ),
29
+ 'default' => __( 'Flexible Shipping', 'flexible-shipping' ),
30
+ 'desc_tip' => true,
31
+ 'default' => $shipping_method['method_title'],
32
+ 'custom_attributes' => array('required' => true)
33
+ ),
34
+ 'method_free_shipping' => array(
35
+ 'title' => __( 'Free shipping', 'flexible-shipping' ),
36
+ 'type' => 'price',
37
+ 'default' => $shipping_method['method_free_shipping'],
38
+ 'description' => __( 'Enter a minimum order amount for free shipping. This will override the costs configured below.', 'flexible-shipping' ),
39
+ 'desc_tip' => true
40
+ ),
41
+ 'method_calculation_method' => array(
42
+ 'title' => __( 'Calculation method', 'flexible-shipping' ),
43
+ 'type' => 'select',
44
+ 'description' => __( 'Select how rules will be calculated. If you choose "sum" the rules order is important.', 'flexible-shipping' ),
45
+ 'default' => $shipping_method['method_calculation_method'],
46
+ 'desc_tip' => true,
47
+ 'options' => array( 'sum' => __( 'Sum', 'flexible-shipping' ) )
48
+ ),
49
+ 'method_visibility' => array(
50
+ 'title' => __( 'Visibility', 'flexible-shipping' ),
51
+ 'type' => 'checkbox',
52
+ 'default' => $shipping_method['method_visibility'],
53
+ 'label' => __( 'Show only for logged in users', 'flexible-shipping' )
54
+ ),
55
+ 'method_default' => array(
56
+ 'title' => __( 'Default', 'flexible-shipping' ),
57
+ 'type' => 'checkbox',
58
+ 'default' => $shipping_method['method_default'],
59
+ 'label' => __( 'Check the box to set this option as the default selected choice on the cart page.', 'flexible-shipping' )
60
+ ),
61
+ 'method_integration' => array(
62
+ 'title' => __( 'Integration', 'flexible-shipping' ),
63
+ 'type' => 'select',
64
+ 'description' => __( 'Select integration. ' , 'flexible-shipping' ) . $integrations ,
65
+ 'desc_tip' => $integrations_tip,
66
+ 'default' => $shipping_method['method_integration'],
67
+ 'options' => apply_filters( 'flexible_shipping_integration_options' , array( '' => __( 'None', 'flexible-shipping' ) ) )
68
+ ),
69
+ );
70
+
71
+ $settings = apply_filters( 'flexible_shipping_method_settings', $settings, $shipping_method );
72
+
73
+ $settings['method_rules'] = array(
74
+ 'title' => __( 'Rules', 'flexible-shipping' ),
75
+ 'type' => 'shipping_rules',
76
+ 'default' => isset( $shipping_method['method_rules'] ) ? $shipping_method['method_rules'] : array(),
77
+ 'method_title' => $shipping_method['method_title'],
78
+ );
79
+
80
+ if ( class_exists('WC_Shipping_Zones1') ) {
81
+ $shipping_zones = WC_Shipping_Zones::get_zones();
82
+ $shipping_zones_options = array();
83
+ foreach ( $shipping_zones as $shipping_zone ) {
84
+ $shipping_zones_options[$shipping_zone['zone_id']] = $shipping_zone['zone_name'];
85
+ }
86
+ error_log(print_r($shipping_zones,true));
87
+ $settings_with_zones = array();
88
+ foreach ( $settings as $key => $setting ) {
89
+ $settings_with_zones[$key] = $setting;
90
+ if ( $key == 'method_title' ) {
91
+ $settings_with_zones['method_shipping_zone'] = array(
92
+ 'title' => __( 'Shipping Zone', 'flexible-shipping' ),
93
+ 'type' => 'select',
94
+ 'default' => $shipping_method['method_shipping_zone'],
95
+ 'options' => $shipping_zones_options,
96
+ );
97
+ }
98
+ }
99
+ return $settings_with_zones;
100
+ }
101
+
102
+ $docs_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/' : 'https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/';
103
+
104
+ echo '<p>' . sprintf( __( 'See how to %sconfigure shipping methods%s.', 'flexible-shipping' ), '<a href="' . $docs_link . '" target="_blank">', '</a>' ) . '</p>';
105
+
106
+ return $settings;
classes/shipping_method.php ADDED
@@ -0,0 +1,592 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
+ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
6
+ class WPDesk_Flexible_Shipping extends WC_Shipping_Method {
7
+
8
+ private $default_method = false;
9
+
10
+ private $message_added = false;
11
+
12
+ /**
13
+ * Constructor for your shipping class
14
+ *
15
+ * @access public
16
+ * @return void
17
+ */
18
+ public function __construct( $instance_id = 0 ) {
19
+ $this->instance_id = absint( $instance_id );
20
+ $this->id = 'flexible_shipping';
21
+ $this->shipping_methods_option = 'flexible_shipping_methods_' . $this->instance_id;
22
+ $this->shipping_method_order_option = 'flexible_shipping_method_order_' . $this->instance_id;
23
+ $this->section_name = 'flexible_shipping';
24
+ $this->method_title = __( 'Flexible Shipping', 'flexible-shipping' );
25
+ $this->method_description = __( 'Flexible Shipping', 'flexible-shipping' );
26
+
27
+ $this->supports = array(
28
+ 'shipping-zones',
29
+ 'instance-settings',
30
+ );
31
+
32
+ $this->instance_form_fields = array(
33
+ 'enabled' => array(
34
+ 'title' => __( 'Enable/Disable', 'flexible-shipping' ),
35
+ 'type' => 'checkbox',
36
+ 'label' => __( 'Enable this shipping method', 'flexible-shipping' ),
37
+ 'default' => 'yes',
38
+ ),
39
+ 'title' => array(
40
+ 'title' => __( 'Shipping Title', 'flexible-shipping' ),
41
+ 'type' => 'text',
42
+ 'description' => __( 'This controls the title which the user sees during checkout.', 'flexible-shipping' ),
43
+ 'default' => __( 'Flexible Shipping', 'flexible-shipping' ),
44
+ 'desc_tip' => true
45
+ )
46
+ );
47
+
48
+ $this->enabled = $this->get_option( 'enabled' );
49
+ $this->title = $this->get_option( 'title' );
50
+
51
+ $this->init();
52
+
53
+ //$this->method_title = $this->get_option( 'title' );
54
+
55
+ add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) );
56
+
57
+ }
58
+
59
+ /**
60
+ * Init your settings
61
+ *
62
+ * @access public
63
+ * @return void
64
+ */
65
+ function init() {
66
+ $this->instance_form_fields = include( 'settings-flexible-shipping.php' );
67
+ // Load the settings API
68
+ $this->init_form_fields(); // This is part of the settings API. Override the method to add your own settings
69
+ $this->init_settings(); // This is part of the settings API. Loads settings you previously init.
70
+
71
+ // Define user set variables
72
+ $this->title = $this->get_option( 'title' );
73
+ $this->tax_status = $this->get_option( 'tax_status' );
74
+
75
+ $this->availability = $this->get_option( 'availability' );
76
+
77
+ $this->type = $this->get_option( 'type', 'class' );
78
+ }
79
+
80
+
81
+ /**
82
+ * @param unknown $key
83
+ * @return string
84
+ *
85
+ * Dodane w WooCommerce 2.4
86
+ * Dodane w celu zachowania kompatybilności z WooCommerce 2.3
87
+ * Przetestowane na WooCommerce 2.3.9
88
+ */
89
+ public function get_field_key( $key ) {
90
+ return $this->plugin_id . $this->id . '_' . $key;
91
+ }
92
+
93
+ public function generate_title_shipping_methods_html( $key, $data ) {
94
+ $field = $this->get_field_key( $key );
95
+ $defaults = array(
96
+ 'title' => '',
97
+ 'class' => ''
98
+ );
99
+
100
+ $data = wp_parse_args( $data, $defaults );
101
+
102
+ ob_start();
103
+
104
+ ?>
105
+ </table>
106
+ <h3 class="wc-settings-sub-title <?php echo esc_attr( $data['class'] ); ?>" id="<?php echo esc_attr( $field ); ?>"><?php echo wp_kses_post( $data['title'] ); ?>
107
+ <a href="<?php echo remove_query_arg( 'added', add_query_arg( 'action', 'new' ) ); ?>" class="add-new-h2"><?php echo __('Add New', 'flexible-shipping' ); ?></a></h3>
108
+
109
+ <?php if ( ! empty( $data['description'] ) ) : ?>
110
+ <p><?php echo wp_kses_post( $data['description'] ); ?></p>
111
+ <?php endif; ?>
112
+ <table class="form-table">
113
+ <?php
114
+
115
+ return ob_get_clean();
116
+ }
117
+
118
+ public function generate_shipping_methods_html( $key, $data ) {
119
+ $shipping_methods = $this->get_shipping_methods();
120
+ $shipping_method_order = $this->get_shipping_method_order();
121
+ ob_start();
122
+ include ( 'views/html-shipping-method-settings.php' );
123
+ return ob_get_clean();
124
+ }
125
+
126
+ public function get_shipping_methods( $enabled = false ) {
127
+ $shipping_methods = get_option( $this->shipping_methods_option, array() );
128
+ $shipping_method_order = get_option( $this->shipping_method_order_option, array() );
129
+ $ret = array();
130
+ if ( is_array( $shipping_method_order ) ) {
131
+ foreach ( $shipping_method_order as $method_id ) {
132
+ if ( isset( $shipping_methods[$method_id] ) ) $ret[$method_id] = $shipping_methods[$method_id];
133
+ }
134
+ }
135
+ foreach ( $shipping_methods as $shipping_method ) {
136
+ if ( !isset( $ret[$shipping_method['id']] ) ) $ret[$shipping_method['id']] = $shipping_method;
137
+ }
138
+ if ( $enabled ) {
139
+ foreach ( $ret as $key => $shipping_method ) {
140
+ if ( isset( $shipping_method['method_enabled'] ) && 'yes' != $shipping_method['method_enabled'] ) unset($ret[$key]);
141
+ }
142
+ }
143
+ return $ret;
144
+ }
145
+
146
+ public function get_shipping_method_order() {
147
+ $shipping_methods = get_option( $this->shipping_methods_option, array() );
148
+ $shipping_method_order = get_option( $this->shipping_method_order_option, array() );
149
+ $ret = array();
150
+ if ( is_array( $shipping_method_order ) ) {
151
+ foreach ( $shipping_method_order as $method_id ) {
152
+ if ( isset( $shipping_methods[$method_id] ) ) $ret[$method_id] = $method_id;
153
+ }
154
+ }
155
+ foreach ( $shipping_methods as $shipping_method ) {
156
+ if ( !isset( $ret[$shipping_method['id']] ) ) $ret[$shipping_method['id']] = $shipping_method['id'];
157
+ }
158
+ return $ret;
159
+ }
160
+
161
+ public function generate_shipping_rules_html( $key, $data ) {
162
+ ob_start();
163
+ include ( 'views/html-shipping-method-rules.php' );
164
+ return ob_get_clean();
165
+ }
166
+
167
+
168
+ /**
169
+ * Initialise Settings Form Fields
170
+ */
171
+ public function init_form_fields() {
172
+ $this->form_fields = include( 'settings-flexible-shipping.php' );
173
+ }
174
+
175
+ public function update_rates($shipping_methods) {
176
+ $retes = array();
177
+ foreach ( $shipping_methods as $shipping_method ) {
178
+ $id = $this->id . '_' . $this->instance_id . '_' . sanitize_title($shipping_method['method_title'] );
179
+ $id = apply_filters( 'flexible_shipping_method_rate_id', $id, $shipping_method );
180
+ if ( ! isset( $rates[$id] ) && $shipping_method['method_enabled'] == 'yes' )
181
+ $rates[$id] = array(
182
+ 'identifier' => $id,
183
+ 'title' => $shipping_method['method_title']
184
+ );
185
+ }
186
+ update_option( 'flexible_shipping_rates', $rates );
187
+ }
188
+
189
+ public function process_admin_options() {
190
+ $action = false;
191
+ if ( isset( $_POST['method_action'] ) ) {
192
+ $action = $_POST['method_action'];
193
+ }
194
+ if ( $action == 'new' || $action == 'edit' ) {
195
+ $shipping_methods = get_option( $this->shipping_methods_option, array() );
196
+ $shipping_method = array();
197
+ if ( $action == 'new' ) {
198
+ $shipping_methods = get_option( $this->shipping_methods_option, array() );
199
+ $shipping_method_order = get_option( $this->shipping_method_order_option, array() );
200
+ //
201
+ $method_id = 0;
202
+ foreach ( $shipping_methods as $shipping_method ) {
203
+ if ( $shipping_method['id'] > $method_id ) $method_id = $shipping_method['id'];
204
+ }
205
+ $method_id++;
206
+ //
207
+ }
208
+ else {
209
+ $method_id = $_POST['method_id'];
210
+ }
211
+ $shipping_method['id'] = $method_id;
212
+ $shipping_method['method_title'] = $_POST['woocommerce_' . $this->id . '_method_title'];
213
+ $shipping_method['method_free_shipping'] = $_POST['woocommerce_' . $this->id . '_method_free_shipping'];
214
+ $shipping_method['method_calculation_method'] = $_POST['woocommerce_' . $this->id . '_method_calculation_method'];
215
+ $shipping_method['method_visibility'] = 'no';
216
+ if ( isset( $_POST['woocommerce_' . $this->id . '_method_visibility'] ) && $_POST['woocommerce_' . $this->id . '_method_visibility'] == 1 )
217
+ $shipping_method['method_visibility'] = 'yes';
218
+ //
219
+ $shipping_method['method_default'] = 'no';
220
+ if ( isset( $_POST['woocommerce_' . $this->id . '_method_default'] ) && $_POST['woocommerce_' . $this->id . '_method_default'] == 1 )
221
+ $shipping_method['method_default'] = 'yes';
222
+ //
223
+ $shipping_method['method_enabled'] = 'no';
224
+ if ( isset( $_POST['woocommerce_' . $this->id . '_method_enabled'] ) && $_POST['woocommerce_' . $this->id . '_method_enabled'] == 1 )
225
+ $shipping_method['method_enabled'] = 'yes';
226
+ //
227
+ $shipping_method['method_integration'] = $_POST['woocommerce_' . $this->id . '_method_integration'];
228
+ //
229
+ $shipping_method = apply_filters( 'flexible_shipping_process_admin_options', $shipping_method );
230
+ //
231
+ $count = 0;
232
+ $shipping_method['method_rules'] = array();
233
+ foreach ( $_POST['method_rules'] as $rule ) {
234
+ $count++;
235
+ $method_rule = array();
236
+ $method_rule['based_on'] = $rule['based_on'];
237
+ $method_rule['min'] = wc_format_decimal( $rule['min'] );
238
+ $method_rule['max'] = wc_format_decimal( $rule['max'] );
239
+ $method_rule['cost_per_order'] = wc_format_decimal( $rule['cost_per_order'] );
240
+ $method_rule = apply_filters( 'flexible_shipping_method_rule_save', $method_rule, $rule );
241
+ $shipping_method['method_rules'][$count] = $method_rule;
242
+ }
243
+ //
244
+ $shipping_methods[$method_id] = $shipping_method;
245
+ //
246
+ update_option( $this->shipping_methods_option, $shipping_methods );
247
+ //
248
+ $this->update_rates($shipping_methods);
249
+ //
250
+ if ( $action == 'new' ) {
251
+ $shipping_method_order[$method_id] = $method_id;
252
+ update_option( $this->shipping_method_order_option, $shipping_method_order );
253
+ }
254
+ if ( $action == 'new' ) {
255
+ $redirect = add_query_arg( array('added' => $method_id, 'action' => false, 'method_id' => false ));
256
+ $redirect .= '#method_' . $method_id;
257
+ $redirect = add_query_arg( array('added' => $method_id, 'action' => 'edit', 'method_id' => $method_id ));
258
+ wpdesk_redirect( $redirect );
259
+ exit;
260
+ }
261
+ if ( $action == 'edit' ) {
262
+ $redirect = add_query_arg( array('updated' => $method_id, 'action' => false, 'method_id' => false ));
263
+ $redirect .= '#method_' . $method_id;
264
+ }
265
+ }
266
+ else {
267
+ parent::process_admin_options();
268
+ update_option($this->shipping_method_order_option,$_POST['method_order']);
269
+ }
270
+ }
271
+
272
+ public function get_shipping_method_form( $shipping_method ) {
273
+ $this->form_fields = include( 'settings-shipping-method-form.php' );
274
+ }
275
+
276
+
277
+ public function admin_options() {
278
+ ?>
279
+ <table class="form-table">
280
+ <?php
281
+ $action = false;
282
+ if ( isset( $_GET['action'] ) )
283
+ {
284
+ $action = $_GET['action'];
285
+ }
286
+ if ( $action == 'new' || $action == 'edit' ) {
287
+ $shipping_methods = get_option( $this->shipping_methods_option, array() );
288
+ $shipping_method = array(
289
+ 'method_title' => '',
290
+ 'method_enabled' => 'no',
291
+ 'method_shipping_zone' => '',
292
+ 'method_calculation_method' => 'sum',
293
+ 'method_free_shipping' => '',
294
+ 'method_visibility' => 'no',
295
+ 'method_default' => 'no',
296
+ 'method_integration' => '',
297
+ );
298
+ if ( $action == 'edit' ) {
299
+ $method_id = $_GET['method_id'];
300
+ $shipping_method = $shipping_methods[$method_id];
301
+ }
302
+ ?>
303
+ <input type="hidden" name="method_action" value="<?php echo $action; ?>" />
304
+ <input type="hidden" name="method_id" value="<?php echo $method_id; ?>" />
305
+ <?php if ( $action == 'new' ) : ?>
306
+ <h2><?php _e('New Shipping Method', 'flexible-shipping' ); ?></h2>
307
+ <?php endif; ?>
308
+ <?php if ( $action == 'edit' ) : ?>
309
+ <h2><?php _e('Edit Shipping Method', 'flexible-shipping' ); ?></h2>
310
+ <?php endif; ?>
311
+ <?php
312
+ if ( isset( $_GET['added'] ) ) {
313
+ $method_id = $_GET['added'];
314
+ $shipping_methods = get_option( $this->shipping_methods_option, array() );
315
+ if ( isset( $shipping_methods[$method_id] ) )
316
+ {
317
+ if ( ! $this->message_added ) {
318
+ $shipping_method = $shipping_methods[$method_id];
319
+ WC_Admin_Settings::add_message( sprintf(__( 'Shipping method %s added.', 'flexible-shipping' ), $shipping_method['method_title'] ) );
320
+ $this->message_added = true;
321
+ }
322
+ }
323
+ WC_Admin_Settings::show_messages();
324
+ }
325
+ $this->generate_settings_html( $this->get_shipping_method_form($shipping_method) );
326
+ }
327
+ else if ( $action == 'delete' ) {
328
+ $method_id = $_GET['method_id'];
329
+ $shipping_methods = get_option( $this->shipping_methods_option, array() );
330
+ $shipping_method_order = get_option( $this->shipping_method_order_option, array() );
331
+ if ( isset( $shipping_methods[$method_id] ) )
332
+ {
333
+ $shipping_method = $shipping_methods[$method_id];
334
+ unset( $shipping_methods[$method_id] );
335
+ if ( isset( $shipping_method_order[$method_id] ) ) {
336
+ unset( $shipping_method_order[$method_id] );
337
+ }
338
+ update_option( $this->shipping_methods_option, $shipping_methods );
339
+ update_option( $this->shipping_method_order_option, $shipping_method_order );
340
+ WC_Admin_Settings::add_message( sprintf(__('Shipping method %s deleted.', 'flexible-shipping' ), $shipping_method['method_title'] ) );
341
+ }
342
+ else {
343
+ WC_Admin_Settings::add_error( __( 'Shipping method not found.', 'flexible-shipping' ) );
344
+ }
345
+ WC_Admin_Settings::show_messages();
346
+ $this->generate_settings_html();
347
+ }
348
+ else {
349
+ if ( isset( $_GET['added'] ) ) {
350
+ $method_id = $_GET['added'];
351
+ $shipping_methods = get_option( $this->shipping_methods_option, array() );
352
+ if ( isset( $shipping_methods[$method_id] ) )
353
+ {
354
+ if ( ! $this->message_added ) {
355
+ $shipping_method = $shipping_methods[$method_id];
356
+ WC_Admin_Settings::add_message( sprintf(__( 'Shipping method %s added.', 'flexible-shipping' ), $shipping_method['method_title'] ) );
357
+ $this->message_added = true;
358
+ }
359
+ }
360
+ WC_Admin_Settings::show_messages();
361
+ }
362
+ if ( isset( $_GET['updated'] ) ) {
363
+ $method_id = $_GET['updated'];
364
+ $shipping_methods = get_option( $this->shipping_methods_option, array() );
365
+ if ( isset( $shipping_methods[$method_id] ) )
366
+ {
367
+ $shipping_method = $shipping_methods[$method_id];
368
+ WC_Admin_Settings::add_message( sprintf(__( 'Shipping method %s updated.', 'flexible-shipping' ), $shipping_method['method_title'] ) );
369
+ }
370
+ WC_Admin_Settings::show_messages();
371
+ }
372
+
373
+ // General Settings
374
+ $this->generate_settings_html();
375
+ }
376
+ ?>
377
+ </table>
378
+ <?php do_action( 'flexible_shipping_method_script' ); ?>
379
+ <?php
380
+ }
381
+
382
+ private function package_subtotal( $items ) {
383
+ $subtotal = 0;
384
+ foreach( $items as $item )
385
+ $subtotal += $item['line_subtotal'];
386
+ return $subtotal;
387
+ }
388
+
389
+ public function package_weight( $items ) {
390
+ $weight = 0;
391
+ foreach( $items as $item ) {
392
+ $weight += $item['data']->weight * $item['quantity'];
393
+ }
394
+ return $weight;
395
+ }
396
+
397
+ public function cart_weight() {
398
+ $weight = 0;
399
+ $cart = WC()->cart;
400
+ foreach( $cart->cart_contents as $item ) {
401
+ $weight += $item['data']->weight * $item['quantity'];
402
+ }
403
+ return $weight;
404
+ }
405
+
406
+ public function package_item_count( $items ) {
407
+ $item_count = 0;
408
+
409
+ foreach( $items as $item ) {
410
+ $item_count += $item['quantity'];
411
+ }
412
+ return $item_count;
413
+ }
414
+
415
+ public function cart_item_count() {
416
+ $item_count = 0;
417
+
418
+ $cart = WC()->cart;
419
+ foreach( $cart->cart_contents as $item ) {
420
+ $item_count += $item['quantity'];
421
+ }
422
+
423
+ return $item_count;
424
+ }
425
+
426
+ function calculate_method_cost( $shipping_method, $rule_costs ) {
427
+ $cost = 0;
428
+ if ( $shipping_method['method_calculation_method'] == 'sum' ) {
429
+ $cost = 0;
430
+ foreach ( $rule_costs as $rule_cost ) {
431
+ $cost += $rule_cost['cost'];
432
+ }
433
+ }
434
+ return $cost;
435
+ }
436
+
437
+ public function calculate_shipping( $package = array() ) {
438
+
439
+ $processed = apply_filters( 'flexible_shipping_calculate_shipping', false, $this, $package, 0 );
440
+
441
+ $default_method_is_set = false;
442
+
443
+ if ( $processed === false ) {
444
+
445
+ $shipping_methods = $this->get_shipping_methods( true );
446
+
447
+ foreach ( $shipping_methods as $shipping_method ) {
448
+
449
+ $rule_costs = array();
450
+
451
+ $add_method = false;
452
+
453
+ if ( isset( $shipping_method['method_visibility'] ) && $shipping_method['method_visibility'] == 'yes' && !is_user_logged_in() ) {
454
+ /* only for logged in */
455
+ continue;
456
+ }
457
+
458
+ foreach ( $shipping_method['method_rules'] as $rule_key => $method_rule ) {
459
+
460
+ $rule_triggered = false;
461
+
462
+ if ( $method_rule['based_on'] == 'none' ) {
463
+ $rule_triggered = true;
464
+ }
465
+
466
+ $contents_cost = 0;
467
+ if ( WC()->cart->prices_include_tax ) {
468
+ $contents_cost = WC()->cart->cart_contents_total + array_sum( WC()->cart->taxes );
469
+ }
470
+ else {
471
+ $contents_cost = WC()->cart->cart_contents_total;
472
+ }
473
+
474
+ $cart_contents_cost = $contents_cost;
475
+
476
+ if ( $method_rule['based_on'] == 'value' ) {
477
+ if ( trim( $method_rule['min'] ) == '' ) {
478
+ $min = 0;
479
+ }
480
+ else {
481
+ $min = floatval( $method_rule['min'] );
482
+ }
483
+ if ( trim( $method_rule['max'] ) == '' ) {
484
+ $max = INF;
485
+ }
486
+ else {
487
+ $max = floatval( $method_rule['max'] );
488
+ }
489
+
490
+ if ( $contents_cost >= $min && $contents_cost <= $max ) {
491
+ $rule_triggered = true;
492
+ }
493
+ }
494
+
495
+ if ( $method_rule['based_on'] == 'weight' ) {
496
+ if ( trim( $method_rule['min'] ) == '' ) {
497
+ $min = 0;
498
+ }
499
+ else {
500
+ $min = floatval( $method_rule['min'] );
501
+ }
502
+ if ( trim( $method_rule['max'] ) == '' ) {
503
+ $max = INF;
504
+ }
505
+ else {
506
+ $max = floatval( $method_rule['max'] );
507
+ }
508
+ $contents_weight = floatval( $this->cart_weight() );
509
+ if ( $contents_weight >= $min && $contents_weight <= $max ) {
510
+ $rule_triggered = true;
511
+ }
512
+ }
513
+
514
+ if ( $rule_triggered ) {
515
+ $rule_cost = array( 'cost' => floatval( $method_rule['cost_per_order'] ) );
516
+ $rule_costs[$rule_key] = $rule_cost;
517
+ $add_method = true;
518
+ }
519
+ }
520
+
521
+ $cost = $this->calculate_method_cost( $shipping_method, $rule_costs );
522
+
523
+ $add_method = apply_filters( 'flexible_shipping_add_method' , $add_method, $shipping_method, $package );
524
+
525
+ if ( $add_method === true ) {
526
+ if ( isset( $shipping_method['method_free_shipping'] ) && $shipping_method['method_free_shipping'] != '' ) {
527
+ if ( floatval( $shipping_method['method_free_shipping'] ) <= floatval( $cart_contents_cost ) ) {
528
+ $cost = 0;
529
+ }
530
+ }
531
+
532
+ $id = $this->id . '_' . $this->instance_id . '_' . sanitize_title( $shipping_method['method_title'] );
533
+ $id = apply_filters( 'flexible_shipping_method_rate_id', $id, $shipping_method );
534
+ $this->add_rate( array(
535
+ 'id' => $id,
536
+ 'label' => $shipping_method['method_title'],
537
+ 'cost' => $cost,
538
+ 'method' => $shipping_method,
539
+ 'rule_costs' => $rule_costs,
540
+ ) );
541
+ if ( !$default_method_is_set && isset( $shipping_method['method_default'] ) && $shipping_method['method_default'] == 'yes' ) {
542
+ WC()->session->set('chosen_shipping_methods', array( '0' => $id ) );
543
+ $default_method_is_set = true;
544
+ }
545
+ }
546
+ }
547
+ }
548
+ }
549
+
550
+ public function get_all_rates() {
551
+ if ( class_exists( 'WC_Shipping_Zones' ) ) {
552
+ $zones = WC_Shipping_Zones::get_zones();
553
+ $rates = array();
554
+ foreach ( $zones as $zone ) {
555
+ foreach ( $zone['shipping_methods'] as $instance_id => $woo_shipping_method ) {
556
+ if ( $woo_shipping_method->id == $this->id ) {
557
+ $shipping_methods = $woo_shipping_method->get_shipping_methods();
558
+ foreach ( $shipping_methods as $shipping_method ) {
559
+ $id = $this->id . '_' . $woo_shipping_method->instance_id . '_' . sanitize_title($shipping_method['method_title'] );
560
+ $id = apply_filters( 'flexible_shipping_method_rate_id', $id, $shipping_method );
561
+ $rates[$id] = $shipping_method;
562
+ }
563
+ }
564
+ }
565
+ }
566
+ }
567
+ else {
568
+ $shipping_methods = $this->get_shipping_methods();
569
+ $rates = array();
570
+ foreach ( $shipping_methods as $shipping_method ) {
571
+ $id = $this->id . '_' . $this->instance_id . '_' . sanitize_title($shipping_method['method_title'] );
572
+ $id = apply_filters( 'flexible_shipping_method_rate_id', $id, $shipping_method );
573
+ $rates[$id] = $shipping_method;
574
+ }
575
+ }
576
+ return $rates;
577
+ }
578
+
579
+ public function get_method_from_rate( $rate_id ) {
580
+ $rates = $this->get_all_rates();
581
+ return $rates[$rate_id];
582
+ }
583
+
584
+ }
585
+
586
+ function wpdesk_add_flexible_shipping( $methods ) {
587
+ $methods['flexible_shipping'] = 'WPDesk_Flexible_Shipping';
588
+ return $methods;
589
+ }
590
+ add_filter( 'woocommerce_shipping_methods', 'wpdesk_add_flexible_shipping', 10, 1 );
591
+
592
+ }
classes/views/html-shipping-method-rules.php ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit;
3
+
4
+ $field = $this->get_field_key( $key );
5
+
6
+ $options_based_on = apply_filters( 'flexible_shipping_method_rule_options_based_on', array(
7
+ 'none' => __( 'None', 'flexible-shipping' ),
8
+ 'value' => __( 'Price', 'flexible-shipping' ),
9
+ 'weight' => __( 'Weight', 'flexible-shipping' ),
10
+ ));
11
+
12
+
13
+ $key = 'method_rules[xxx][based_on]';
14
+ $args = array(
15
+ 'type' => 'select',
16
+ 'options' => $options_based_on,
17
+ 'return' => true,
18
+ );
19
+ $value = 'none';
20
+ $field_based_on = woocommerce_form_field( $key, $args, $value );
21
+
22
+ $key = 'method_rules[xxx][min]';
23
+ $args = array(
24
+ 'type' => 'text',
25
+ 'return' => true,
26
+ 'input_class' => array( 'wc_input_price' ),
27
+ );
28
+ $value = '';
29
+ $field_min = woocommerce_form_field( $key, $args, wc_format_localized_price( $value ) );
30
+
31
+ $key = 'method_rules[xxx][max]';
32
+ $args = array(
33
+ 'type' => 'text',
34
+ 'return' => true,
35
+ 'input_class' => array( 'wc_input_price' ),
36
+ );
37
+ $value = '';
38
+ $field_max = woocommerce_form_field( $key, $args, wc_format_localized_price( $value ) );
39
+
40
+ $key = 'method_rules[xxx][cost_per_order]';
41
+ $args = array(
42
+ 'type' => 'text',
43
+ 'return' => true,
44
+ 'input_class' => array( 'wc_input_price' ),
45
+ );
46
+ $value = '';
47
+ $field_cost_per_order = woocommerce_form_field( $key, $args, wc_format_localized_price( $value ) );
48
+
49
+ $count_rules = 0;
50
+ ?>
51
+
52
+ <tr valign="top">
53
+ <th class="forminp" colspan="2">
54
+ <label for="<?php echo esc_attr( $field ); ?>"><?php echo $data['title']; ?></label>
55
+
56
+ <?php
57
+ $fs_pro_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/sklep/flexible-shipping-pro-woocommerce/' : 'https://www.wpdesk.net/products/flexible-shipping-pro-woocommerce/';
58
+
59
+ if ( ! in_array( 'flexible-shipping-pro/flexible-shipping-pro.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ):
60
+ ?>
61
+ <p><?php printf( __( 'If you need more advanced rules based on shipping classes, product/item count or adding additional handling/insurance fees make sure to check %sFlexible Shipping PRO &rarr;%s', 'flexible-shipping' ), '<a href="' . $fs_pro_link . '?utm_source=flexible-shipping-method&utm_medium=text-link&utm_campaign=flexible-shipping-pro" target="_blank">', '</a>' ); ?></p>
62
+ <?php endif; ?>
63
+ </th>
64
+ </tr>
65
+
66
+ <tr valign="top">
67
+ <td colspan="2" style="padding:0;">
68
+ <table id="<?php echo esc_attr( $field ); ?>" class="flexible_shipping_method_rules wc_input_table sortable widefat">
69
+ <thead>
70
+ <tr>
71
+ <th class="sort">&nbsp;</th>
72
+ <th class="based_on">
73
+ <?php _e( 'Based on', 'flexible-shipping' ); ?>
74
+ <span class="woocommerce-help-tip" data-tip="<?php _e( 'Shipping cost will be calculated based on the selected parameter.', 'flexible-shipping' ); ?>"></span>
75
+ </th>
76
+ <th class="min">
77
+ <?php _e( 'Min', 'flexible-shipping' ); ?>
78
+ <span class="woocommerce-help-tip" data-tip="<?php _e( 'Enter minimum value for the "Based on" parameter.', 'flexible-shipping' ); ?>"></span>
79
+ </th>
80
+ <th class="max">
81
+ <?php _e( 'Max', 'flexible-shipping' ); ?>
82
+ <span class="woocommerce-help-tip" data-tip="<?php _e( 'Enter maximum value for the "Based on" parameter.', 'flexible-shipping' ); ?>"></span>
83
+ </th>
84
+ <th class="cost_per_order">
85
+ <?php _e( 'Cost per order', 'flexible-shipping' ); ?>
86
+ <span class="woocommerce-help-tip" data-tip="<?php _e( 'Enter shipping cost for this rule.', 'flexible-shipping' ); ?>"></span>
87
+ </th>
88
+ <?php do_action( 'flexible_shipping_method_rule_thead', '' ); ?>
89
+ </tr>
90
+ </thead>
91
+
92
+ <tbody>
93
+ <?php if ( isset( $data['default'] ) ) : ?>
94
+ <?php foreach ( $data['default'] as $key => $rule ) : $count_rules++; ?>
95
+ <tr>
96
+ <td class="sort"></td>
97
+ <td class="based_on">
98
+ <?php
99
+ $key = 'method_rules[' . $count_rules . '][based_on]';
100
+ $args = array(
101
+ 'type' => 'select',
102
+ 'options' => $options_based_on,
103
+ );
104
+ $value = '';
105
+ if ( isset( $rule['based_on'] ) ) {
106
+ $value = $rule['based_on'];
107
+ }
108
+ woocommerce_form_field( $key, $args, $value );
109
+ ?>
110
+ </td>
111
+ <td class="min">
112
+ <?php
113
+ $key = 'method_rules[' . $count_rules . '][min]';
114
+ $args = array(
115
+ 'type' => 'text',
116
+ 'input_class' => array( 'wc_input_price' ),
117
+ );
118
+ $value = '';
119
+ if ( isset( $rule['min'] ) ) {
120
+ $value = $rule['min'];
121
+ }
122
+ woocommerce_form_field( $key, $args, wc_format_localized_price( $value ) );
123
+ ?>
124
+ </td>
125
+ <td class="max">
126
+ <?php
127
+ $key = 'method_rules[' . $count_rules . '][max]';
128
+ $args = array(
129
+ 'type' => 'text',
130
+ 'input_class' => array( 'wc_input_price' ),
131
+ );
132
+ $value = '';
133
+ if ( isset( $rule['max'] ) ) {
134
+ $value = $rule['max'];
135
+ }
136
+ woocommerce_form_field( $key, $args, wc_format_localized_price( $value ) );
137
+ ?>
138
+ </td>
139
+ <td class="cost_per_order">
140
+ <?php
141
+ $key = 'method_rules[' . $count_rules . '][cost_per_order]';
142
+ $args = array(
143
+ 'type' => 'text',
144
+ 'input_class' => array( 'wc_input_price' ),
145
+ );
146
+ $value = '';
147
+ if ( isset( $rule['cost_per_order'] ) ) {
148
+ $value = $rule['cost_per_order'];
149
+ }
150
+ woocommerce_form_field( $key, $args, wc_format_localized_price( $value ) );
151
+ ?>
152
+ </td>
153
+ <?php do_action( 'flexible_shipping_method_rule_row', $rule, $count_rules ); ?>
154
+ </tr>
155
+ <?php endforeach; ?>
156
+ <?php endif; ?>
157
+ </tbody>
158
+
159
+ <tfoot>
160
+ <tr>
161
+ <th colspan="99">
162
+ <a id="insert_rule" href="#" class="button plus insert"><?php _e( 'Insert rule', 'flexible-shipping' ); ?></a>
163
+ <a id="remove_rules" href="#" class="button minus"><?php _e( 'Delete selected rules', 'flexible-shipping' ); ?></a>
164
+ </th>
165
+ </tr>
166
+ </tfoot>
167
+ </table>
168
+
169
+ <script type="text/javascript">
170
+ function append_row( id ) {
171
+ var code = '<tr class="new">\
172
+ <td class="sort"></td>\
173
+ <td class="based_on">\
174
+ <?php echo str_replace( "'", '"', str_replace( "\n", "\\\n", $field_based_on ) ); ?> \
175
+ </td>\
176
+ <td class="min">\
177
+ <?php echo str_replace( "'", '"', str_replace( "\n", "\\\n", $field_min ) ); ?> \
178
+ </td>\
179
+ <td class="max">\
180
+ <?php echo str_replace( "'", '"', str_replace( "\n", "\\\n", $field_max ) ); ?> \
181
+ </td>\
182
+ <td class="cost_per_order">\
183
+ <?php echo str_replace( "'", '"', str_replace( "\n", "\\\n", $field_cost_per_order ) ); ?> \
184
+ </td>\
185
+ <?php do_action( 'flexible_shipping_method_rule_js', '' ); ?>
186
+ </tr>';
187
+ var code2 = code.replace(/xxx/g, id );
188
+ var $tbody = jQuery('#<?php echo esc_attr( $field ); ?>').find('tbody');
189
+ $tbody.append( code2 );
190
+ }
191
+ jQuery(document).ready(function() {
192
+ var tbody = jQuery('#<?php echo esc_attr( $field ); ?>').find('tbody');
193
+ var append_id = <?php echo $count_rules ?>;
194
+ var size = tbody.find('tr').size();
195
+ if ( size == 0 ) {
196
+ append_id = append_id+1;
197
+ append_row(append_id);
198
+ }
199
+ jQuery('#insert_rule').click(function() {
200
+ append_id = append_id+1;
201
+ append_row(append_id);
202
+ jQuery('#rules_'+append_id+'_min').focus();
203
+ return false;
204
+ });
205
+ jQuery('#remove_rules').click(function() {
206
+ if ( current = tbody.children( '.current' ) ) {
207
+ current.each(function() {
208
+ jQuery(this).remove();
209
+ });
210
+ } else {
211
+ alert( '<?php _e( 'No rows selected.' , 'flexible-shipping' ); ?>' );
212
+ }
213
+ return false;
214
+ });
215
+ jQuery(document).on('click', '.delete_rule', function() {
216
+ if (confirm('<?php _e( 'Are you sure?' , 'flexible-shipping' ); ?>')) {
217
+ jQuery(this).closest('tr').remove();
218
+ }
219
+ return false;
220
+ });
221
+ jQuery('#mainform').attr('action', '<?php echo remove_query_arg( 'added', add_query_arg( 'added', '1' ) ); ?>' );
222
+ });
223
+ </script>
224
+ <?php
225
+ if( version_compare( WC()->version, '2.6.0', ">=" ) ) {
226
+ ?>
227
+ <script type="text/javascript">
228
+ <?php
229
+ $zone = WC_Shipping_Zones::get_zone_by( 'instance_id', $_GET['instance_id'] );
230
+ $shipping_method_woo = WC_Shipping_Zones::get_shipping_method( $_GET['instance_id'] );
231
+ $content = '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=shipping' ) . '">' . __( 'Shipping Zones', 'woocommerce' ) . '</a> &gt ';
232
+ $content .= '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=shipping&zone_id=' . absint( $zone->get_zone_id() ) ) . '">' . esc_html( $zone->get_zone_name() ) . '</a> &gt ';
233
+ $content .= '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=shipping&instance_id=' . $_GET['instance_id'] ) . '">' . esc_html( $shipping_method_woo->get_title() ) . '</a>';
234
+ if ( isset( $data['method_title'] ) && $data['method_title'] != '' ) {
235
+ $content .= ' &gt ';
236
+ $content .= esc_html( $data['method_title'] );
237
+ }
238
+ else {
239
+ $content .= ' &gt ';
240
+ $content .= __( 'Add New', 'flexible-shipping' );
241
+ }
242
+ ?>
243
+ jQuery('#mainform h2').first().replaceWith( '<h2>' + '<?php echo $content; ?>' + '</h2>' );
244
+ </script>
245
+ <?php
246
+ }
247
+ ?>
248
+ </td>
249
+ </tr>
classes/views/html-shipping-method-settings.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
+ <tr valign="top">
3
+ <td class="forminp" style="padding-left:0;padding-right:0;">
4
+ <fieldset>
5
+ <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
6
+ <style>
7
+ tr.highlight td {
8
+ background-color: #e4f2fd !important;
9
+ }
10
+
11
+ .form-table .wc_shipping th {
12
+ width: auto;
13
+ }
14
+ </style>
15
+ <table class="wc_shipping widefat wp-list-table" cellspacing="0">
16
+ <thead>
17
+ <tr>
18
+ <th class="sort">&nbsp;</th>
19
+ <th class="title"><?php _e( 'Title', 'flexible-shipping' ); ?></th>
20
+ <th class="status"><?php _e( 'Enabled', 'flexible-shipping' ); ?></th>
21
+ <th class="visibility"><?php _e( 'Visibility', 'flexible-shipping' ); ?></th>
22
+ <th class="default"><?php _e( 'Default', 'flexible-shipping' ); ?></th>
23
+ <th class="integration"><?php _e( 'Integration', 'flexible-shipping' ); ?></th>
24
+ <th class="action"><?php _e( 'Action', 'flexible-shipping' ); ?></th>
25
+ </tr>
26
+ </thead>
27
+ <tbody>
28
+ <?php if ( isset( $shipping_method_order ) && is_array( $shipping_method_order ) ) : ?>
29
+ <?php foreach ( $shipping_method_order as $shipping_method_id ) : $shipping_method = $shipping_methods[$shipping_method_id]; ?>
30
+ <?php $tr_class = ''; ?>
31
+ <?php if ( isset( $_GET['added'] ) && $_GET['added'] == $shipping_method_id ) $tr_class = 'highlight'; ?>
32
+ <?php if ( isset( $_GET['updated'] ) && $_GET['updated'] == $shipping_method_id ) $tr_class = 'highlight'; ?>
33
+ <tr id="method_<?php echo $shipping_method_id; ?>" class="<?php echo $tr_class; ?>">
34
+ <td width="1%" class="sort">
35
+ <input type="hidden" name="method_order[<?php echo esc_attr( $shipping_method['id'] ); ?>]" value="<?php echo esc_attr( $shipping_method['id'] ); ?>" />
36
+ </td>
37
+ <td class="title">
38
+ <a href="<?php echo add_query_arg( 'method_id' , $shipping_method_id, add_query_arg( 'action', 'edit' ) ); ?>">
39
+ <strong><?php echo esc_html( $shipping_method['method_title'] ); ?></strong>
40
+ </a>
41
+ </td>
42
+ <td width="1%" class="status">
43
+ <?php if ( isset($shipping_method['method_enabled']) && 'yes' === $shipping_method['method_enabled'] ) : ?>
44
+ <span class="status-enabled tips" data-tip="<?php _e( 'yes', 'flexible-shipping' ); ?>"><?php _e( 'yes', 'flexible-shipping' ); ?></span>
45
+ <?php else : ?>
46
+ <span class="na">-</span>
47
+ <?php endif; ?>
48
+ </td>
49
+ <td width="1%" class="default visibility">
50
+ <?php if ( isset( $shipping_method['method_visibility'] ) && 'yes' === $shipping_method['method_visibility'] ) : ?>
51
+ <span class="status-enabled tips" data-tip="<?php _e( 'Show only for logged in users', 'flexible-shipping' ); ?>"><?php _e( 'yes', 'flexible-shipping' ); ?></span>
52
+ <?php else : ?>
53
+ <span class="na tips" data-tip="<?php _e( 'Show for all users', 'flexible-shipping' ); ?>">-</span>
54
+ <?php endif; ?>
55
+ </td>
56
+ <td width="1%" class="default">
57
+ <?php if ( 'yes' === $shipping_method['method_default'] ) : ?>
58
+ <span class="status-enabled tips" data-tip="<?php _e( 'yes', 'flexible-shipping' ); ?>"><?php _e( 'yes', 'flexible-shipping' ); ?></span>
59
+ <?php else : ?>
60
+ <span class="na">-</span>
61
+ <?php endif; ?>
62
+ </td>
63
+ <?php echo apply_filters( 'flexible_shipping_method_integration_col', '<td width="1%" class="integration default">-</td>', $shipping_method );?>
64
+ <td width="1%" class="action" nowrap>
65
+ <?php /* ?>
66
+ <a class="button" href="?page=wc-settings&amp;tab=shipping&amp;section=<?php echo $this->section_name; ?>&amp;action=delete&method_id=<?php echo $shipping_method_id; ?>"><?php _e( 'Delete', 'flexible-shipping' ); ?></a>
67
+ <?php */ ?>
68
+ <a class="button" href="<?php echo add_query_arg( 'method_id' , $shipping_method_id, add_query_arg( 'action', 'delete' ) ); ?>"><?php _e( 'Delete', 'flexible-shipping' ); ?></a>
69
+ </td>
70
+ </tr>
71
+ <?php endforeach; ?>
72
+ <?php endif; ?>
73
+ </tbody>
74
+ <tfoot>
75
+ <tr>
76
+ <th>&nbsp;</th>
77
+ <th colspan="8"><span class="description"><?php _e( 'Drag and drop the above shipping methods to control their display order. Confirm by clicking Save changes button below.', 'flexible-shipping' ); ?></span></th>
78
+ </tr>
79
+ </tfoot>
80
+ </table>
81
+
82
+ <?php echo $this->get_description_html( $data ); ?>
83
+ </fieldset>
84
+ </td>
85
+ </tr>
86
+ <?php
87
+ if( version_compare( WC()->version, '2.6.0', ">=" ) ) {
88
+ ?>
89
+ <script type="text/javascript">
90
+ <?php
91
+ $zone = WC_Shipping_Zones::get_zone_by( 'instance_id', $_GET['instance_id'] );
92
+ $shipping_method_woo = WC_Shipping_Zones::get_shipping_method( $_GET['instance_id'] );
93
+ $content = '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=shipping' ) . '">' . __( 'Shipping Zones', 'woocommerce' ) . '</a> &gt ';
94
+ $content .= '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=shipping&zone_id=' . absint( $zone->get_zone_id() ) ) . '">' . esc_html( $zone->get_zone_name() ) . '</a> &gt';
95
+ $content .= esc_html( $shipping_method_woo->get_title() );
96
+ ?>
97
+ jQuery('#mainform h2').first().replaceWith( '<h2>' + '<?php echo $content; ?>' + '</h2>' );
98
+ </script>
99
+ <?php
100
+ }
101
+ ?>
102
+ <?php
flexible-shipping.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Flexible Shipping
4
+ Plugin URI: https://wordpress.org/plugins/flexible-shipping/
5
+ Description: Create additional shipping methods in WooCommerce and enable pricing based on cart weight or total.
6
+ Version: 1.4
7
+ Author: WP Desk
8
+ Author URI: https://www.wpdesk.net/
9
+ Text Domain: flexible-shipping
10
+ Domain Path: /languages/
11
+ Tested up to: 4.5.2
12
+
13
+ Copyright 2016 WP Desk Ltd.
14
+
15
+ This program is free software; you can redistribute it and/or modify
16
+ it under the terms of the GNU General Public License as published by
17
+ the Free Software Foundation; either version 3 of the License, or
18
+ (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program; if not, write to the Free Software
27
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
+
29
+ */
30
+
31
+
32
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
33
+
34
+ if (!class_exists('inspire_Plugin4')) {
35
+ require_once('classes/inspire/plugin4.php');
36
+ }
37
+
38
+ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
39
+
40
+ class WPDesk_Flexible_Shipping_Free_Plugin extends inspire_Plugin4 {
41
+
42
+ protected $_pluginNamespace = "flexible-shipping";
43
+
44
+ public function __construct() {
45
+ parent::__construct();
46
+ add_action('plugins_loaded', array($this, 'init_flexible_shipping'), 1000 );
47
+ }
48
+
49
+ public function init_flexible_shipping() {
50
+ require_once('classes/shipping_method.php');
51
+ add_action( 'admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 75 );
52
+
53
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
54
+
55
+ }
56
+
57
+ public function admin_notices() {
58
+ if ( is_plugin_active( 'woocommerce-active-payments/activepayments.php' ) ) {
59
+ $plugin_activepayments = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-active-payments/activepayments.php' );
60
+
61
+ $version_compare = version_compare( $plugin_activepayments['Version'], '2.7' );
62
+ if ( $version_compare < 0 ) {
63
+ $class = 'notice notice-error';
64
+ $message = __( 'Flexible Shipping requires at least version 2.7 of Active Payments plugin.', 'flexible-shipping' );
65
+
66
+ printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
67
+ }
68
+ }
69
+ if ( is_plugin_active( 'woocommerce-enadawca/woocommerce-enadawca.php' ) ) {
70
+ $plugin_enadawca = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-enadawca/woocommerce-enadawca.php' );
71
+
72
+ $version_compare = version_compare( $plugin_enadawca['Version'], '1.2' );
73
+ if ( $version_compare < 0 ) {
74
+ $class = 'notice notice-error';
75
+ $message = __( 'Flexible Shipping requires at least version 1.2 of eNadawca plugin.', 'flexible-shipping' );
76
+
77
+ printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
78
+ }
79
+ }
80
+ if ( is_plugin_active( 'woocommerce-paczka-w-ruchu/woocommerce-paczka-w-ruchu.php' ) ) {
81
+ $plugin_pwr = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-paczka-w-ruchu/woocommerce-paczka-w-ruchu.php' );
82
+
83
+ $version_compare = version_compare( $plugin_pwr['Version'], '1.1' );
84
+ if ( $version_compare < 0 ) {
85
+ $class = 'notice notice-error';
86
+ $message = __( 'Flexible Shipping requires at least version 1.1 of Paczka w Ruchu plugin.', 'flexible-shipping' );
87
+
88
+ printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
89
+ }
90
+ }
91
+ if ( is_plugin_active( 'woo-flexible-shipping/flexible-shipping.php' ) ) {
92
+
93
+ $class = 'notice notice-error';
94
+ $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>' );
95
+
96
+ printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
97
+ }
98
+ }
99
+
100
+ public function loadPluginTextDomain() {
101
+ parent::loadPluginTextDomain();
102
+ $ret = load_plugin_textdomain( 'flexible-shipping', FALSE, basename( dirname( __FILE__ ) ) . '/languages' );
103
+ }
104
+
105
+ public static function getTextDomain() {
106
+ return 'flexible-shipping';
107
+ }
108
+
109
+ function enqueue_admin_scripts() {
110
+ wp_enqueue_style( 'flexible-shipping-admin', $this->getPluginUrl() . 'assets/css/admin.css' );
111
+ }
112
+
113
+ function enqueue_scripts() {
114
+ }
115
+
116
+ function admin_footer() {
117
+ }
118
+
119
+ /**
120
+ * action_links function.
121
+ *
122
+ * @access public
123
+ * @param mixed $links
124
+ * @return void
125
+ */
126
+ public function linksFilter( $links ) {
127
+ $docs_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/' : 'https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/';
128
+ $support_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/support/' : 'https://www.wpdesk.net/support';
129
+
130
+ $plugin_links = array(
131
+ '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=shipping&section=wpdesk_flexible_shipping') . '">' . __( 'Settings', 'flexible-shipping-pro' ) . '</a>',
132
+ '<a href="' . $docs_link . '">' . __( 'Docs', 'flexible-shipping-pro' ) . '</a>',
133
+ '<a href="' . $support_link . '">' . __( 'Support', 'flexible-shipping-pro' ) . '</a>',
134
+ );
135
+
136
+ return array_merge( $plugin_links, $links );
137
+ }
138
+ }
139
+
140
+ if ( !function_exists('wpdesk_redirect') ) {
141
+ function wpdesk_redirect( $redirect ) {
142
+ if ( 1==1 && headers_sent() ) {
143
+ ?>
144
+ <span><?php printf( __( 'Redirecting. If page not redirects click %s here %s.', 'flexible-shipping'), '<a href="' . $redirect . '" >', '</a>' ); ?></span>
145
+
146
+ <script>
147
+ parent.location.replace('<?php echo $redirect; ?>');
148
+ </script>
149
+ <?php
150
+ }
151
+ else {
152
+ wp_safe_redirect($redirect);
153
+ }
154
+ exit;
155
+ }
156
+ }
157
+
158
+ $_GLOBALS['woocommerce_flexible_shipping'] = new WPDesk_Flexible_Shipping_Free_Plugin();
159
+ }
languages/flexible-shipping-pl_PL.mo ADDED
Binary file
languages/flexible-shipping-pl_PL.po ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Flexible Shipping\n"
4
+ "POT-Creation-Date: 2016-06-14 12:12+0200\n"
5
+ "PO-Revision-Date: 2016-06-14 12:12+0200\n"
6
+ "Last-Translator: Maciej Swoboda <maciej.swoboda@gmail.com>\n"
7
+ "Language-Team: Maciej Swoboda <maciej.swoboda@gmail.com>\n"
8
+ "Language: pl_PL\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.7\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "X-Poedit-WPHeader: flexible-shipping.php\n"
15
+ "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
16
+ "|| n%100>=20) ? 1 : 2);\n"
17
+ "X-Poedit-SourceCharset: UTF-8\n"
18
+ "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
19
+ "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
20
+ "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
21
+ "X-Poedit-SearchPath-0: .\n"
22
+ "X-Poedit-SearchPathExcluded-0: *.js\n"
23
+
24
+ #: classes/inspire/plugin4.php:218
25
+ msgid ""
26
+ "An Unexpected HTTP Error occurred during the API request. <a href=\"?\" "
27
+ "onclick=\"document.location.reload(); return false;\">Try again</a>"
28
+ msgstr ""
29
+ "Wystąpił nieoczekiwany błąd HTTP podczas zapytania API.</p> <p><a href=„?” "
30
+ "onclick=„document.location.reload(); return false;”>Spróbuj ponownie</a>"
31
+
32
+ #: classes/inspire/plugin4.php:223
33
+ msgid "An unknown error occurred"
34
+ msgstr "Wystąpił nieznany błąd"
35
+
36
+ #: classes/inspire/plugin4.php:387 flexible-shipping.php:131
37
+ msgid "Settings"
38
+ msgstr "Ustawienia"
39
+
40
+ #: classes/inspire/plugin4.php:388 flexible-shipping.php:132
41
+ msgid "Docs"
42
+ msgstr "Docs"
43
+
44
+ #: classes/inspire/plugin4.php:389 flexible-shipping.php:133
45
+ msgid "Support"
46
+ msgstr "Wsparcie"
47
+
48
+ #. Plugin Name of the plugin/theme
49
+ #: classes/settings-flexible-shipping.php:14
50
+ #: classes/settings-flexible-shipping.php:28
51
+ #: classes/settings-shipping-method-form.php:29 classes/shipping_method.php:24
52
+ #: classes/shipping_method.php:25 classes/shipping_method.php:43
53
+ msgid "Flexible Shipping"
54
+ msgstr "Flexible Shipping"
55
+
56
+ #: classes/settings-flexible-shipping.php:16
57
+ #, php-format
58
+ msgid "See how to %sconfigure Flexible Shipping%s."
59
+ msgstr "Zobacz jak %sskonfigurować Flexible Shipping%s."
60
+
61
+ #: classes/settings-flexible-shipping.php:19
62
+ #: classes/settings-shipping-method-form.php:20 classes/shipping_method.php:34
63
+ msgid "Enable/Disable"
64
+ msgstr "Włącz/Wyłącz"
65
+
66
+ #: classes/settings-flexible-shipping.php:21
67
+ msgid "Enable Flexible Shipping"
68
+ msgstr "Włącz Flexible Shipping"
69
+
70
+ #: classes/settings-flexible-shipping.php:25
71
+ msgid "Shipping title"
72
+ msgstr "Tytuł"
73
+
74
+ #: classes/settings-flexible-shipping.php:27
75
+ msgid "Visible only to admin in WooCommerce settings."
76
+ msgstr "Widoczny tylko dla admina w ustawieniach WooCommerce."
77
+
78
+ #: classes/settings-flexible-shipping.php:32
79
+ msgid "Tax Status"
80
+ msgstr "Status podatku"
81
+
82
+ #: classes/settings-flexible-shipping.php:37
83
+ msgid "Taxable"
84
+ msgstr "Opodatkowany"
85
+
86
+ #: classes/settings-flexible-shipping.php:38
87
+ msgctxt "Tax status"
88
+ msgid "None"
89
+ msgstr "Brak"
90
+
91
+ #: classes/settings-flexible-shipping.php:42
92
+ #: classes/settings-flexible-shipping.php:47
93
+ msgid "Shipping Methods"
94
+ msgstr "Metody wysyłki"
95
+
96
+ #: classes/settings-shipping-method-form.php:10
97
+ msgid "Select shipping class"
98
+ msgstr "Wybierz klasę wysyłkową"
99
+
100
+ #: classes/settings-shipping-method-form.php:15
101
+ #, php-format
102
+ msgid ""
103
+ "You can add integrations with Paczkomaty InPost, eNadawca Poczta Polska, "
104
+ "Paczka w Ruchu. %sView details%s"
105
+ msgstr ""
106
+ "Możesz dodać integracje z Paczkomaty InPost, eNadawca Poczta Polska, Paczka "
107
+ "w Ruchu. %sSprawdź szczegóły%s"
108
+
109
+ #: classes/settings-shipping-method-form.php:23 classes/shipping_method.php:36
110
+ msgid "Enable this shipping method"
111
+ msgstr "Włącz tę metodę wysyłki"
112
+
113
+ #: classes/settings-shipping-method-form.php:26
114
+ msgid "Method Title"
115
+ msgstr "Tytuł metody"
116
+
117
+ #: classes/settings-shipping-method-form.php:28 classes/shipping_method.php:42
118
+ msgid "This controls the title which the user sees during checkout."
119
+ msgstr "Tytuł, który widzi użytkownik podczas składania zamówienia."
120
+
121
+ #: classes/settings-shipping-method-form.php:35
122
+ msgid "Free shipping"
123
+ msgstr "Darmowa wysyłka"
124
+
125
+ #: classes/settings-shipping-method-form.php:38
126
+ msgid ""
127
+ "Enter a minimum order amount for free shipping. This will override the costs "
128
+ "configured below."
129
+ msgstr ""
130
+ "Wpisz minimalną kwotę zamówienia dla bezpłatnej wysyłki. Spowoduje to "
131
+ "zastąpienie reguł skonfigurowanych poniżej."
132
+
133
+ #: classes/settings-shipping-method-form.php:42
134
+ msgid "Calculation method"
135
+ msgstr "Metoda obliczania"
136
+
137
+ #: classes/settings-shipping-method-form.php:44
138
+ msgid ""
139
+ "Select how rules will be calculated. If you choose \"sum\" the rules order "
140
+ "is important."
141
+ msgstr ""
142
+ "Wybierz jak będą obliczane reguły. Dla sumy, kolejność reguł ma znaczenie."
143
+
144
+ #: classes/settings-shipping-method-form.php:47
145
+ msgid "Sum"
146
+ msgstr "Suma"
147
+
148
+ #: classes/settings-shipping-method-form.php:50
149
+ #: classes/views/html-shipping-method-settings.php:21
150
+ msgid "Visibility"
151
+ msgstr "Wyświetlanie"
152
+
153
+ #: classes/settings-shipping-method-form.php:53
154
+ #: classes/views/html-shipping-method-settings.php:51
155
+ msgid "Show only for logged in users"
156
+ msgstr "Pokaż tylko dla zalogowanych użytkowników"
157
+
158
+ #: classes/settings-shipping-method-form.php:56
159
+ #: classes/views/html-shipping-method-settings.php:22
160
+ msgid "Default"
161
+ msgstr "Domyślnie"
162
+
163
+ #: classes/settings-shipping-method-form.php:59
164
+ msgid ""
165
+ "Check the box to set this option as the default selected choice on the cart "
166
+ "page."
167
+ msgstr ""
168
+ "Zaznacz, aby ustawić tę metodę wysyłki jako domyślną przy składaniu "
169
+ "zamówienia."
170
+
171
+ #: classes/settings-shipping-method-form.php:62
172
+ #: classes/views/html-shipping-method-settings.php:23
173
+ msgid "Integration"
174
+ msgstr "Integracja"
175
+
176
+ #: classes/settings-shipping-method-form.php:64
177
+ msgid "Select integration. "
178
+ msgstr "Wybierz integrację."
179
+
180
+ #: classes/settings-shipping-method-form.php:67
181
+ #: classes/views/html-shipping-method-rules.php:7
182
+ msgid "None"
183
+ msgstr "Brak"
184
+
185
+ #: classes/settings-shipping-method-form.php:74
186
+ msgid "Rules"
187
+ msgstr "Reguły"
188
+
189
+ #: classes/settings-shipping-method-form.php:92
190
+ msgid "Shipping Zone"
191
+ msgstr "Strefa wysyłki"
192
+
193
+ #: classes/settings-shipping-method-form.php:104
194
+ #, php-format
195
+ msgid "See how to %sconfigure shipping methods%s."
196
+ msgstr "Zobacz jak %sskonfigurować metody wysyłki %s."
197
+
198
+ #: classes/shipping_method.php:40
199
+ msgid "Shipping Title"
200
+ msgstr "Tytuł"
201
+
202
+ #: classes/shipping_method.php:107
203
+ #: classes/views/html-shipping-method-rules.php:240
204
+ msgid "Add New"
205
+ msgstr "Dodaj nową"
206
+
207
+ #: classes/shipping_method.php:306
208
+ msgid "New Shipping Method"
209
+ msgstr "Nowa metoda wysyłki"
210
+
211
+ #: classes/shipping_method.php:309
212
+ msgid "Edit Shipping Method"
213
+ msgstr "Edytuj metodę wysyłki"
214
+
215
+ #: classes/shipping_method.php:319 classes/shipping_method.php:356
216
+ #, php-format
217
+ msgid "Shipping method %s added."
218
+ msgstr "Metoda wysyłki dodana: %s."
219
+
220
+ #: classes/shipping_method.php:340
221
+ #, php-format
222
+ msgid "Shipping method %s deleted."
223
+ msgstr "Metoda wysyłki usunięta: %s."
224
+
225
+ #: classes/shipping_method.php:343
226
+ msgid "Shipping method not found."
227
+ msgstr "Metoda wysyłki nie znaleziona."
228
+
229
+ #: classes/shipping_method.php:368
230
+ #, php-format
231
+ msgid "Shipping method %s updated."
232
+ msgstr "Metoda wysyłki zaktualizowana: %s."
233
+
234
+ #: classes/views/html-shipping-method-rules.php:8
235
+ msgid "Price"
236
+ msgstr "Cena"
237
+
238
+ #: classes/views/html-shipping-method-rules.php:9
239
+ msgid "Weight"
240
+ msgstr "Waga"
241
+
242
+ #: classes/views/html-shipping-method-rules.php:61
243
+ #, php-format
244
+ msgid ""
245
+ "If you need more advanced rules based on shipping classes, product/item "
246
+ "count or adding additional handling/insurance fees make sure to check "
247
+ "%sFlexible Shipping PRO &rarr;%s"
248
+ msgstr ""
249
+ "Jeśli potrzebujesz bardziej zaawansowanych reguł opartych o klasy wysyłkowe, "
250
+ "liczbę produktów/pozycji lub dodatkowe koszty obsługi/ubezpieczenia, "
251
+ "koniecznie sprawdź %sFlexible Shipping PRO &rarr;%s"
252
+
253
+ #: classes/views/html-shipping-method-rules.php:73
254
+ msgid "Based on"
255
+ msgstr "Oparte na"
256
+
257
+ #: classes/views/html-shipping-method-rules.php:74
258
+ msgid "Shipping cost will be calculated based on the selected parameter."
259
+ msgstr "Koszty wysyłki będą obliczane w oparciu o wybrany parametr."
260
+
261
+ #: classes/views/html-shipping-method-rules.php:77
262
+ msgid "Min"
263
+ msgstr "Min"
264
+
265
+ #: classes/views/html-shipping-method-rules.php:78
266
+ msgid "Enter minimum value for the \"Based on\" parameter."
267
+ msgstr "Wpisz minimalną wartość dla parametru \"Oparte na\"."
268
+
269
+ #: classes/views/html-shipping-method-rules.php:81
270
+ msgid "Max"
271
+ msgstr "Max"
272
+
273
+ #: classes/views/html-shipping-method-rules.php:82
274
+ msgid "Enter maximum value for the \"Based on\" parameter."
275
+ msgstr "Wpisz maksymalną wartość dla parametru \"Oparte na\"."
276
+
277
+ #: classes/views/html-shipping-method-rules.php:85
278
+ msgid "Cost per order"
279
+ msgstr "Koszt na zamówienie"
280
+
281
+ #: classes/views/html-shipping-method-rules.php:86
282
+ msgid "Enter shipping cost for this rule."
283
+ msgstr "Wpisz koszt wysyłki dla tej reguły."
284
+
285
+ #: classes/views/html-shipping-method-rules.php:162
286
+ msgid "Insert rule"
287
+ msgstr "Dodaj regułę"
288
+
289
+ #: classes/views/html-shipping-method-rules.php:163
290
+ msgid "Delete selected rules"
291
+ msgstr "Usuń wybrane reguły"
292
+
293
+ #: classes/views/html-shipping-method-rules.php:211
294
+ msgid "No rows selected."
295
+ msgstr "Nie wybrano wierszy."
296
+
297
+ #: classes/views/html-shipping-method-rules.php:216
298
+ msgid "Are you sure?"
299
+ msgstr "Na pewno?"
300
+
301
+ #: classes/views/html-shipping-method-rules.php:231
302
+ #: classes/views/html-shipping-method-settings.php:93
303
+ msgid "Shipping Zones"
304
+ msgstr "Strefy wysyłki"
305
+
306
+ #: classes/views/html-shipping-method-settings.php:19
307
+ msgid "Title"
308
+ msgstr "Tytuł"
309
+
310
+ #: classes/views/html-shipping-method-settings.php:20
311
+ msgid "Enabled"
312
+ msgstr "Włączona"
313
+
314
+ #: classes/views/html-shipping-method-settings.php:24
315
+ msgid "Action"
316
+ msgstr "Akcje"
317
+
318
+ #: classes/views/html-shipping-method-settings.php:44
319
+ #: classes/views/html-shipping-method-settings.php:51
320
+ #: classes/views/html-shipping-method-settings.php:58
321
+ msgid "yes"
322
+ msgstr "tak"
323
+
324
+ #: classes/views/html-shipping-method-settings.php:53
325
+ msgid "Show for all users"
326
+ msgstr "Pokaż dla wszystkich użytkowników"
327
+
328
+ #: classes/views/html-shipping-method-settings.php:68
329
+ msgid "Delete"
330
+ msgstr "Usuń"
331
+
332
+ #: classes/views/html-shipping-method-settings.php:77
333
+ msgid ""
334
+ "Drag and drop the above shipping methods to control their display order. "
335
+ "Confirm by clicking Save changes button below."
336
+ msgstr ""
337
+ "Przeciągnij i upuść metody wysyłki aby ustawić ich kolejność wyświetlania. "
338
+ "Potwierdź przez kliknięcie przycisku Zapisz zmiany poniżej."
339
+
340
+ #: flexible-shipping.php:64
341
+ msgid ""
342
+ "Flexible Shipping requires at least version 2.7 of Active Payments plugin."
343
+ msgstr ""
344
+ "Flexible Shipping wymaga wtyczki Aktywne płatności w wersji co najmniej 2.7."
345
+
346
+ #: flexible-shipping.php:75
347
+ msgid "Flexible Shipping requires at least version 1.2 of eNadawca plugin."
348
+ msgstr "Flexible Shipping wymaga wtyczki eNadawca w wersji co najmniej 1.2."
349
+
350
+ #: flexible-shipping.php:86
351
+ msgid ""
352
+ "Flexible Shipping requires at least version 1.1 of Paczka w Ruchu plugin."
353
+ msgstr ""
354
+ "Flexible Shipping wymaga wtyczki Paczka w Ruchu w wersji co najmniej 1.1."
355
+
356
+ #: flexible-shipping.php:94
357
+ #, php-format
358
+ msgid ""
359
+ "You are using WooCommerce Flexible Shipping below 1.4. Please deactivate it "
360
+ "on %splugins page%s. Read about big changes in Flexible Shipping on %sour "
361
+ "blog →%s"
362
+ msgstr ""
363
+ " Masz włączony WooCommerce Flexible Shipping w wersji starszej niż 1.4. "
364
+ "Wyłącz go na %sstronie wtyczek%s. Przeczytaj o dużej zmianie we Flexible "
365
+ "Shipping na %snaszym blogu →%s"
366
+
367
+ #: flexible-shipping.php:144
368
+ #, php-format
369
+ msgid "Redirecting. If page not redirects click %s here %s."
370
+ msgstr ""
371
+ "Przekierowywanie. Jeśli strona nie przekierowuje cię automatycznie, kliknij "
372
+ "%s tu %s."
373
+
374
+ #. Plugin URI of the plugin/theme
375
+ msgid "https://wordpress.org/plugins/flexible-shipping/"
376
+ msgstr "https://pl.wordpress.org/plugins/flexible-shipping/"
377
+
378
+ #. Description of the plugin/theme
379
+ msgid ""
380
+ "Create additional shipping methods in WooCommerce and enable pricing based "
381
+ "on cart weight or total."
382
+ msgstr ""
383
+ "Stwórz dodatkowe metody wysyłki w WooCommerce i włącz obliczanie kosztów w "
384
+ "oparciu o wagę lub wartość zamówienia."
385
+
386
+ #. Author of the plugin/theme
387
+ msgid "WP Desk"
388
+ msgstr "WP Desk"
389
+
390
+ #. Author URI of the plugin/theme
391
+ msgid "https://www.wpdesk.net/"
392
+ msgstr "https://www.wpdesk.pl/"
393
+
394
+ #~ msgid "Insert row"
395
+ #~ msgstr "Dodaj wiersz"
396
+
397
+ #~ msgid "Delete selected rows"
398
+ #~ msgstr "Usuń zaznaczone wiersze"
399
+
400
+ #~ msgid "Cart total"
401
+ #~ msgstr "Suma koszyka"
402
+
403
+ #~ msgid "Value"
404
+ #~ msgstr "Wartość"
405
+
406
+ #~ msgid ""
407
+ #~ "Enter minimum order amount for free shipping. This will override all "
408
+ #~ "rules configured below."
409
+ #~ msgstr "Wprowadź minimalną kwotę do bezpłatnej wysyłki. "
readme.txt ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Flexible Shipping for WooCommerce ===
2
+ Contributors: wpdesk, swoboda
3
+ Donate link: https://www.wpdesk.net/
4
+ Tags: table rate, table rate shipping, woocommerce shipping, flexible shipping, woocommerce table rate shipping, cart total
5
+ Requires at least: 4.0
6
+ Tested up to: 4.5.2
7
+ Stable tag: 1.4
8
+ License: GPLv3 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
+
11
+ The most flexible Table Rate Shipping WooCommerce plugin. Create virtually any shipping scenario you need based on totals, weight, quantity and more.
12
+
13
+ == Description ==
14
+
15
+ = Table Rate Shipping Killer =
16
+
17
+ Flexible Shipping is the most advanced shipping plugin for WooCommerce stores allowing you to calculate shipping costs based on weight and/or cart total. Combine it with the PRO version and it will become the only WooCommerce Shipping plugin you'll ever need.
18
+
19
+ > **Upgrade to Flexible Shipping PRO**<br />
20
+ > Get priority e-mail support and access all PRO features, upgrade to [Flexible Shipping PRO now &rarr;](https://www.wpdesk.net/products/flexible-shipping-pro-woocommerce/)
21
+
22
+ = Possible Shipping Scenarios =
23
+
24
+ * Shipping costs based on cart weight
25
+ * Shipping costs based on cart total
26
+ * Adding handling or insurance costs above a certain value
27
+ * Creating COD (cash on delivery) shipping method with additional costs
28
+ * Different shipping costs for different shipping classes (PRO)
29
+ * Disable shipping method if a rule is matched in the cart (PRO)
30
+ * Add a cost for order and per every product (PRO)
31
+
32
+ These are just a few examples. The possibilities are probably endless ;) We described some of the in our [DIY section](https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/).
33
+
34
+ = Features =
35
+
36
+ * Unlimited shipping methods and cost rules
37
+ * Shipping cost based on cart total and/or weight
38
+ * Minimum and maximum values for cart total and/or weight
39
+ * Summing cost rules if they are matched - option to add costs based on cart total and weight at the same time
40
+ * Free shipping override
41
+ * Show selected shipping methods only for logged in users
42
+ * Integrations (see below for details)
43
+ * Compatible with WooCommerce 2.6 Shipping Zones (see below for details)
44
+
45
+ = PRO Features =
46
+
47
+ * All free features
48
+ * Support for shipping classes
49
+ * Shipping costs based on product item count and/or cart line item count
50
+ * Additional costs for price, weight, item, cart line item
51
+ * Stopping a rule (if the rule is matched the following rules are not calculated)
52
+ * Cancelling a rule (if the rule is matched it is removed from available shipping methods at the checkout)
53
+ * Additional calculation methods (sum, lowest cost, highest cost)
54
+ * Maximum shipping cost per shipping method
55
+
56
+ [Upgrade to PRO Now &rarr;](https://www.wpdesk.net/products/flexible-shipping-pro-woocommerce/)
57
+
58
+ = WooCommerce Compatibility =
59
+
60
+ **WooCommerce 2.6 ready!** Flexible Shipping is compatible with WooCommerce Shipping Zones introduced in version 2.6. Read more about [WooCommerce Shipping Zones](https://www.wpdesk.net/blog/woocommerce-shipping-zones-explained/).
61
+
62
+ Flexible Shipping also plays well with older versions of WooCommerce. We tested the plugin with WooCommerce 2.3.x and up.
63
+
64
+ = Docs =
65
+
66
+ [View Flexible Shipping Docs](https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/)
67
+
68
+ = Support Policy =
69
+
70
+ We provide a limited support for the free version in the [plugin Support Forum](https://wordpress.org/support/plugin/flexible-shipping/). Please upgrade to PRO version to get priority e-mail support as well as all pro features. [Upgrade Now &rarr;](https://www.wpdesk.net/products/flexible-shipping-pro-woocommerce/)
71
+
72
+ = Integrations =
73
+
74
+ There are several integrations that we provide for Flexible Shipping in Poland:
75
+
76
+ * Paczkomaty InPost - WooCommerce
77
+ * eNadawca Poczta Polska - WooCommerce
78
+ * Paczka w Ruchu - WooCommerce
79
+
80
+ [View the Polish integrations &rarr;](https://www.wpdesk.pl/kategoria-produktu/wysylka/)
81
+
82
+ > **Get more WooCommerce plugins from WP Desk**<br />
83
+ > We provide premium plugins for customizing checkout, shipping, invoicing and more. Check out our [premium WooCommerce plugins here →](https://www.wpdesk.net/products/)
84
+
85
+ == Installation ==
86
+
87
+ You can install this plugin like any other WordPress plugin.
88
+
89
+ 1. Download and unzip the latest release zip file.
90
+ 2. Upload the entire plugin directory to your /wp-content/plugins/ directory.
91
+ 3. Activate the plugin through the Plugins menu in WordPress Administration.
92
+
93
+ You can also use WordPress uploader to upload plugin zip file in menu Plugins -> Add New -> Upload Plugin. Then go directly to point 3.
94
+
95
+ == Frequently Asked Questions ==
96
+
97
+ = How to configure the plugin? =
98
+
99
+ Just check out our [Flexible Shipping Docs here](https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/).
100
+
101
+ = Do you offer support? =
102
+
103
+ We provide a limited support for the free version in the [plugin Support Forum](https://wordpress.org/support/plugin/flexible-shipping/). Please upgrade to PRO version to get priority e-mail support as well as all pro features. [Upgrade Now &rarr;](https://www.wpdesk.net/products/flexible-shipping-pro-woocommerce/)
104
+
105
+ == Screenshots ==
106
+
107
+ 1. Main Settings in WooCommerce 2.5 and below.
108
+ 2. Main Settings in WooCommerce 2.6.
109
+ 3. Shipping Methods list.
110
+ 4. Add/Edit Shipping Method.
111
+ 5. Shipping Rules Settings.
112
+
113
+ == Upgrade Notice ==
114
+
115
+ If you are upgrading from the old Flexible Shipping version (1.3.2, woo-flexible-shipping) make sure to completely delete the old version first. If you install the new version without deleting the old one you may break your WordPress installation.
116
+
117
+ == Changelog ==
118
+
119
+ = 1.4 - 2016-06-14 =
120
+ * Converted to English
121
+ * Added Polish (pl_PL) translation
122
+ * Added FREE and PRO versions
123
+
124
+ = 1.3.2 - 2016-04-12 =
125
+ * Fixed a few notices
126
+
127
+ = 1.3.1 - 2016-03-14 =
128
+ * Fixed default shipping method in the checkout
129
+
130
+ = 1.3 - 2016-03-07 =
131
+ * Added enabling shipping method only for logged in users
132
+ * Fixed a notice in generate_shipping_methods_html
133
+
134
+ = 1.2 - 2016-01-26 =
135
+ * Automatic updates
136
+
137
+ = 1.1.1 - 2015-12-01 =
138
+ * Added WooCommerce 2.3 compatibility
139
+
140
+ = 1.0 - 2015-11-03 =
141
+ * First release!