Version Description
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.
Download this release
Release Info
Developer | jablonowski |
Plugin | Flexible Shipping for WooCommerce |
Version | 3.3.2 |
Comparing to | |
See all releases |
Code changes from version 3.3.1 to 3.3.2
- assets/js/ap_conditional_logic.js +61 -0
- assets/js/ap_conditional_logic.min.js +1 -0
- classes/class-flexible-shipping-plugin.php +4 -1
- classes/shipment/saas/views/order-metabox-fieldset.php +5 -0
- classes/shipping-method.php +15 -2
- flexible-shipping.php +3 -3
- readme.txt +5 -1
- vendor/autoload.php +1 -1
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +4 -4
assets/js/ap_conditional_logic.js
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Conditional Logic for Access Point
|
3 |
+
*
|
4 |
+
* @param field_name
|
5 |
+
* @param shipment_id
|
6 |
+
* @param conditions
|
7 |
+
* @constructor
|
8 |
+
*/
|
9 |
+
function ApConditionalLogic(field_name, shipment_id, conditions) {
|
10 |
+
this.field_name = field_name;
|
11 |
+
this.shipment_id = shipment_id;
|
12 |
+
this.conditions = conditions;
|
13 |
+
|
14 |
+
this.field_id = '#' + this.field_name + '_' + this.shipment_id;
|
15 |
+
|
16 |
+
this.field_id = this.createFieldId( this.field_name, this.shipment_id );
|
17 |
+
|
18 |
+
let conditional_logic = this;
|
19 |
+
this.conditions.forEach(function(value){
|
20 |
+
jQuery( conditional_logic.createFieldId( value.field, shipment_id ) ).on('change', function(event) {
|
21 |
+
conditional_logic.doLogic(event)
|
22 |
+
});
|
23 |
+
});
|
24 |
+
jQuery(document).ready(function(event) { conditional_logic.doLogic(event) });
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Create field id from field name and shipment id;
|
29 |
+
*
|
30 |
+
* @param field_name
|
31 |
+
* @param shipment_id
|
32 |
+
* @return {string}
|
33 |
+
*/
|
34 |
+
ApConditionalLogic.prototype.createFieldId = function( field_name, shipment_id ) {
|
35 |
+
return '#' + field_name + '_' + shipment_id;
|
36 |
+
};
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Do logic.
|
40 |
+
*
|
41 |
+
* @param event
|
42 |
+
*/
|
43 |
+
ApConditionalLogic.prototype.doLogic = function(event) {
|
44 |
+
let show_field = true;
|
45 |
+
let field_id = this.field_id;
|
46 |
+
let shipment_id = this.shipment_id;
|
47 |
+
let ap_conditional_logic = this;
|
48 |
+
this.conditions.forEach(function(condition) {
|
49 |
+
let cond_value = false;
|
50 |
+
if ( condition.cond === 'in' && condition.values.indexOf( jQuery( ap_conditional_logic.createFieldId( condition.field, shipment_id ) ).val() ) !== -1 ) {
|
51 |
+
cond_value = true;
|
52 |
+
}
|
53 |
+
show_field = show_field && cond_value;
|
54 |
+
});
|
55 |
+
var field_div = jQuery(field_id).closest('div');
|
56 |
+
if ( show_field ) {
|
57 |
+
field_div.show();
|
58 |
+
} else {
|
59 |
+
field_div.hide();
|
60 |
+
}
|
61 |
+
};
|
assets/js/ap_conditional_logic.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
function ApConditionalLogic(a,c,b){this.field_name=a;this.shipment_id=c;this.conditions=b;this.field_id="#"+this.field_name+"_"+this.shipment_id;this.field_id=this.createFieldId(this.field_name,this.shipment_id);let conditional_logic=this;this.conditions.forEach(function(d){jQuery(conditional_logic.createFieldId(d.field,c)).on("change",function(e){conditional_logic.doLogic(e)})});jQuery(document).ready(function(d){conditional_logic.doLogic(d)})}ApConditionalLogic.prototype.createFieldId=function(a,b){return"#"+a+"_"+b};ApConditionalLogic.prototype.doLogic=function(a){let show_field=true;let field_id=this.field_id;let shipment_id=this.shipment_id;let ap_conditional_logic=this;this.conditions.forEach(function(c){let cond_value=false;if(c.cond==="in"&&c.values.indexOf(jQuery(ap_conditional_logic.createFieldId(c.field,shipment_id)).val())!==-1){cond_value=true}show_field=show_field&&cond_value});var b=jQuery(field_id).closest("div");if(show_field){b.show()}else{b.hide()}};
|
classes/class-flexible-shipping-plugin.php
CHANGED
@@ -17,7 +17,7 @@ class Flexible_Shipping_Plugin
|
|
17 |
/**
|
18 |
* @var string
|
19 |
*/
|
20 |
-
private $scripts_version = FLEXIBLE_SHIPPING_VERSION . '.
|
21 |
|
22 |
/**
|
23 |
* @var WPDesk_Flexible_Shipping_Admin_Notices
|
@@ -415,6 +415,9 @@ class Flexible_Shipping_Plugin
|
|
415 |
wp_register_script( 'fs_admin_saas_platform', trailingslashit( $this->get_plugin_assets_url() ) . 'js/admin_saas_platform' . $suffix . '.js', array( 'jquery' ), $this->scripts_version );
|
416 |
wp_enqueue_script( 'fs_admin_saas_platform' );
|
417 |
|
|
|
|
|
|
|
418 |
wp_enqueue_style( 'fs_admin',
|
419 |
trailingslashit( $this->get_plugin_assets_url() ) . 'css/admin' . $suffix . '.css', array(),
|
420 |
$this->scripts_version );
|
17 |
/**
|
18 |
* @var string
|
19 |
*/
|
20 |
+
private $scripts_version = FLEXIBLE_SHIPPING_VERSION . '.198';
|
21 |
|
22 |
/**
|
23 |
* @var WPDesk_Flexible_Shipping_Admin_Notices
|
415 |
wp_register_script( 'fs_admin_saas_platform', trailingslashit( $this->get_plugin_assets_url() ) . 'js/admin_saas_platform' . $suffix . '.js', array( 'jquery' ), $this->scripts_version );
|
416 |
wp_enqueue_script( 'fs_admin_saas_platform' );
|
417 |
|
418 |
+
wp_register_script( 'fs_ap_conditional_logic', trailingslashit( $this->get_plugin_assets_url() ) . 'js/ap_conditional_logic' . $suffix . '.js', array( 'jquery' ), $this->scripts_version );
|
419 |
+
wp_enqueue_script( 'fs_ap_conditional_logic' );
|
420 |
+
|
421 |
wp_enqueue_style( 'fs_admin',
|
422 |
trailingslashit( $this->get_plugin_assets_url() ) . 'css/admin' . $suffix . '.css', array(),
|
423 |
$this->scripts_version );
|
classes/shipment/saas/views/order-metabox-fieldset.php
CHANGED
@@ -52,5 +52,10 @@
|
|
52 |
<?php else : ?>
|
53 |
<?php woocommerce_wp_text_input( $args ); ?>
|
54 |
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
55 |
</div>
|
56 |
<?php endforeach; ?>
|
52 |
<?php else : ?>
|
53 |
<?php woocommerce_wp_text_input( $args ); ?>
|
54 |
<?php endif; ?>
|
55 |
+
<?php if ( isset( $field['visible-when'] ) ) : ?>
|
56 |
+
<script type="text/javascript">
|
57 |
+
new ApConditionalLogic( '<?php echo esc_attr( $field['id'] ); ?>', <?php echo esc_attr( $id ); ?>, <?php echo wp_json_encode( $field['visible-when'] ); ?> );
|
58 |
+
</script>
|
59 |
+
<?php endif; ?>
|
60 |
</div>
|
61 |
<?php endforeach; ?>
|
classes/shipping-method.php
CHANGED
@@ -7,8 +7,15 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
|
|
7 |
|
8 |
const FIELD_METHOD_FREE_SHIPPING = 'method_free_shipping';
|
9 |
|
10 |
-
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
private $message_added = false;
|
13 |
|
14 |
|
@@ -487,6 +494,12 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
|
|
487 |
return $weight;
|
488 |
}
|
489 |
|
|
|
|
|
|
|
|
|
|
|
|
|
490 |
public function cart_weight() {
|
491 |
if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
|
492 |
add_filter( 'woocommerce_product_weight', array( $this, 'woocommerce_product_weight' ) );
|
@@ -495,7 +508,7 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
|
|
495 |
if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
|
496 |
remove_filter( 'woocommerce_product_weight', array( $this, 'woocommerce_product_weight' ) );
|
497 |
}
|
498 |
-
return $cart_weight;
|
499 |
}
|
500 |
|
501 |
/* Fix for Woocommerce 2.6 weight calculation */
|
7 |
|
8 |
const FIELD_METHOD_FREE_SHIPPING = 'method_free_shipping';
|
9 |
|
10 |
+
const META_DEFAULT = '_default';
|
11 |
|
12 |
+
const WEIGHT_ROUNDING_PRECISION = 6;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Message added.
|
16 |
+
*
|
17 |
+
* @var bool
|
18 |
+
*/
|
19 |
private $message_added = false;
|
20 |
|
21 |
|
494 |
return $weight;
|
495 |
}
|
496 |
|
497 |
+
/**
|
498 |
+
* Get cart weight.
|
499 |
+
* It rounds return value to declared precision.
|
500 |
+
*
|
501 |
+
* @return float
|
502 |
+
*/
|
503 |
public function cart_weight() {
|
504 |
if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
|
505 |
add_filter( 'woocommerce_product_weight', array( $this, 'woocommerce_product_weight' ) );
|
508 |
if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
|
509 |
remove_filter( 'woocommerce_product_weight', array( $this, 'woocommerce_product_weight' ) );
|
510 |
}
|
511 |
+
return round( $cart_weight, apply_filters( 'flexible_shipping_weight_rounding_precision', self::WEIGHT_ROUNDING_PRECISION ) );
|
512 |
}
|
513 |
|
514 |
/* Fix for Woocommerce 2.6 weight calculation */
|
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.3.
|
7 |
Author: WP Desk
|
8 |
Author URI: https://www.wpdesk.net/
|
9 |
Text Domain: flexible-shipping
|
@@ -45,8 +45,8 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
|
|
45 |
|
46 |
/* THESE TWO VARIABLES CAN BE CHANGED AUTOMATICALLY */
|
47 |
|
48 |
-
$plugin_version = '3.3.
|
49 |
-
$plugin_release_timestamp = '2019-04-
|
50 |
|
51 |
$plugin_name = 'Flexible Shipping';
|
52 |
$plugin_class_name = 'Flexible_Shipping_Plugin';
|
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.3.2
|
7 |
Author: WP Desk
|
8 |
Author URI: https://www.wpdesk.net/
|
9 |
Text Domain: flexible-shipping
|
45 |
|
46 |
/* THESE TWO VARIABLES CAN BE CHANGED AUTOMATICALLY */
|
47 |
|
48 |
+
$plugin_version = '3.3.2';
|
49 |
+
$plugin_release_timestamp = '2019-04-02';
|
50 |
|
51 |
$plugin_name = 'Flexible Shipping';
|
52 |
$plugin_class_name = 'Flexible_Shipping_Plugin';
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flexibleshipping.com/table-rate/
|
|
4 |
Tags: table rate, table rate shipping, woocommerce shipping, flexible shipping, woocommerce table rate shipping, cart based shipping, weight shipping, weight based shipping, totals based shipping, order based shipping, shipping zones, shipping classes
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.1.0
|
7 |
-
Stable tag: 3.3.
|
8 |
Requires PHP: 5.6
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
@@ -175,6 +175,10 @@ If you are upgrading from the old Flexible Shipping version (1.3.2, woo-flexible
|
|
175 |
|
176 |
== Changelog ==
|
177 |
|
|
|
|
|
|
|
|
|
178 |
3.3.1 - 2019-04-01
|
179 |
* Fixed CSV import with multiple shipping classes
|
180 |
|
4 |
Tags: table rate, table rate shipping, woocommerce shipping, flexible shipping, woocommerce table rate shipping, cart based shipping, weight shipping, weight based shipping, totals based shipping, order based shipping, shipping zones, shipping classes
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.1.0
|
7 |
+
Stable tag: 3.3.2
|
8 |
Requires PHP: 5.6
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
175 |
|
176 |
== Changelog ==
|
177 |
|
178 |
+
3.3.2
|
179 |
+
* Fixed weight calculation for float weight values
|
180 |
+
* Conditional logic on fields in order meta box
|
181 |
+
|
182 |
3.3.1 - 2019-04-01
|
183 |
* Fixed CSV import with multiple shipping classes
|
184 |
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInitaafcce658bff0f6e1b833865f9ebd08f::getLoader();
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInitd9c30b4fb507b157ad87e468dc8c9db0
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
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\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
@@ -48,19 +48,19 @@ class ComposerAutoloaderInitd9c30b4fb507b157ad87e468dc8c9db0
|
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
-
$includeFiles = Composer\Autoload\
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
-
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
function
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInitaafcce658bff0f6e1b833865f9ebd08f
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitaafcce658bff0f6e1b833865f9ebd08f', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitaafcce658bff0f6e1b833865f9ebd08f', '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\ComposerStaticInitaafcce658bff0f6e1b833865f9ebd08f::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
+
$includeFiles = Composer\Autoload\ComposerStaticInitaafcce658bff0f6e1b833865f9ebd08f::$files;
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
+
composerRequireaafcce658bff0f6e1b833865f9ebd08f($fileIdentifier, $file);
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
function composerRequireaafcce658bff0f6e1b833865f9ebd08f($fileIdentifier, $file)
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'46ae4ad8c3479aabff48f598a0e4b93f' => __DIR__ . '/..' . '/wpdesk/wp-mutex/src/WPDesk/functions.php',
|
@@ -656,9 +656,9 @@ class ComposerStaticInitd9c30b4fb507b157ad87e468dc8c9db0
|
|
656 |
public static function getInitializer(ClassLoader $loader)
|
657 |
{
|
658 |
return \Closure::bind(function () use ($loader) {
|
659 |
-
$loader->prefixLengthsPsr4 =
|
660 |
-
$loader->prefixDirsPsr4 =
|
661 |
-
$loader->classMap =
|
662 |
|
663 |
}, null, ClassLoader::class);
|
664 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInitaafcce658bff0f6e1b833865f9ebd08f
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'46ae4ad8c3479aabff48f598a0e4b93f' => __DIR__ . '/..' . '/wpdesk/wp-mutex/src/WPDesk/functions.php',
|
656 |
public static function getInitializer(ClassLoader $loader)
|
657 |
{
|
658 |
return \Closure::bind(function () use ($loader) {
|
659 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInitaafcce658bff0f6e1b833865f9ebd08f::$prefixLengthsPsr4;
|
660 |
+
$loader->prefixDirsPsr4 = ComposerStaticInitaafcce658bff0f6e1b833865f9ebd08f::$prefixDirsPsr4;
|
661 |
+
$loader->classMap = ComposerStaticInitaafcce658bff0f6e1b833865f9ebd08f::$classMap;
|
662 |
|
663 |
}, null, ClassLoader::class);
|
664 |
}
|