WooCommerce Advanced Free Shipping - Version 1.0.11

Version Description

  • 05-09-2016 =

  • [Fix] - State condition field only displayed states of the last country

  • [Fix] - Inability to add new conditions due to error

Download this release

Release Info

Developer sormano
Plugin Icon 128x128 WooCommerce Advanced Free Shipping
Version 1.0.11
Comparing to
See all releases

Code changes from version 1.0.10 to 1.0.11

assets/css/parts/wp-conditions.scss CHANGED
@@ -169,7 +169,8 @@
169
  font-size: 14px;
170
  font-weight: 400;
171
  line-height: 19px;
172
- height: 19px;
 
173
  color: #555;
174
  text-align: center;
175
  background-color: #EEE;
169
  font-size: 14px;
170
  font-weight: 400;
171
  line-height: 19px;
172
+ height: 27px;
173
+ box-sizing: border-box;
174
  color: #555;
175
  text-align: center;
176
  background-color: #EEE;
assets/css/woocommerce-advanced-free-shipping.min.css CHANGED
@@ -1 +1 @@
1
- .wpc-conditions .wpc-condition-group{margin-bottom:30px;background-color:#f5f5f5;padding:15px 20px 20px;border:1px solid #ddd;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.04);box-shadow:0 1px 1px rgba(0,0,0,0.04);min-height:30px}.wpc-conditions .wpc-condition-group .wpc-condition-wrap{margin:10px 0 5px}.wpc-conditions .wpc-condition-group .wpc-condition-wrap .wpc-condition{width:30%}.wpc-conditions .wpc-condition-group .wpc-condition-wrap .wpc-operator{width:12%;min-width:140px}.wpc-conditions .wpc-condition-group .wpc-condition-wrap .wpc-value{width:30%;height:28px}.wpc-conditions .wpc-condition-group .wpc-condition-wrap .wpc-description{float:right}.wpc-conditions .wpc-condition-group .wpc-condition-wrap input{vertical-align:top}.wpc-conditions .or-text{display:none !important}.wpc-conditions .wpc-condition-group ~ .or-text,.wpc-conditions .wpc-condition-group ~ .or-text ~ .wpc-condition-group .or-text{display:block !important}.wpc-conditions .wpc-condition-delete{display:none;opacity:0;transition:opacity .3s ease-in-out}.wpc-conditions .wpc-condition-wrap:hover .wpc-condition-delete{display:inline-block;opacity:1}.wpc-conditions .wpc-condition-wrap.loading{height:30px}.wpc-conditions .wpc-condition-wrap.loading .loading-icon{width:100%;clear:both;display:block;text-align:center;line-height:110%;margin:0 1px}.wpc-condition-wrap .wpc-value.select2-container{display:inline-block !important;margin:1px}.wpc-condition-wrap .wpc-value.select2-container.select2-container-active .select2-choice{border:1px solid #666}.wpc-condition-wrap .wpc-value.select2-container.select2-drop-above .select2-choice{border-radius:0 0 4px 4px;border:1px solid #666;border-top-color:transparent}.wpc-condition-wrap .wpc-value.select2-container .select2-choice{border-color:#ddd;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;height:26px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.07);box-shadow:inset 0 1px 2px rgba(0,0,0,0.07)}.wpc-condition-wrap .wpc-value.select2-dropdown-open .select2-choice{border-bottom-color:transparent;-webkit-box-shadow:0 1px 0 #fff inset;box-shadow:0 1px 0 #fff inset;border-bottom-left-radius:0;border-bottom-right-radius:0;border:1px solid #666;outline:0}.wpc-conditions-post-table .sort{padding:0 4px;cursor:move;text-align:center;vertical-align:middle}.wpc-conditions-post-table .sort:before{content:"\e032";font-family:WooCommerce;text-align:center;line-height:1;color:#999;display:block;width:100%;float:left;height:100%}.wpc-conditions-post-table .sort:before,.wpc-conditions-post-table .row-actions{visibility:hidden !important}.wpc-conditions-post-table tr:hover .sort:before,.wpc-conditions-post-table tr:hover>td>.row-actions{visibility:visible !important}.wpc-conditions-post-table .add.button:before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;margin-right:7px;content:"\e007"}.wpc-currency{padding:3px 10px;font-size:14px;font-weight:400;line-height:19px;height:19px;color:#555;text-align:center;background-color:#EEE;border:1px solid #DDD;border-right:none;border-radius:4px 0px 0px 4px;margin:1px 0px 1px 1px;display:inline-block}.wpc-currency+input{margin-left:-4px;line-height:19px;width:161px !important}.post-type-wafs .misc-pub-visibility#visibility{display:none}.wafs-option label{display:inline-block;width:150px}.wafs_conditions_meta_box>p:first-child+div>.or_match{display:none}.condition-group{margin-bottom:30px;background-color:#f5f5f5;padding:15px 20px 20px;border:1px solid #ddd;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.04);box-shadow:0 1px 1px rgba(0,0,0,0.04)}.wafs-condition-wrap{margin:10px 0px 5px}.wafs-condition-wrap .wafs-condition{width:30%}.wafs-condition-wrap .wafs-operator{width:12%;min-width:140px}.wafs-condition-wrap .wafs-value{width:30%}.wafs-condition-wrap input{vertical-align:top}#wafs_conditions p+p{display:none}.wafs_desc{display:none;position:absolute;background:rgba(0,0,0,0.8);min-width:25px;max-width:200px;border-radius:6px;padding:5px 10px;color:white;margin-top:10px;right:40px;text-align:center}.wafs_desc:after{border-top:0px solid transparent;border-right:10px solid transparent;border-left:10px solid transparent;border-bottom:10px solid rgba(0,0,0,0.8);content:' ';position:absolute;top:-10px;right:10px;z-index:999}.wafs_tip:hover ~ .wafs_desc{display:block !important}.wafs-description{width:40px;float:right;line-height:20px}.wafs-condition-wrap ~ .loading-icon{display:block}.loading-icon{width:30%;clear:both;display:inline-block;text-align:center;line-height:110%;margin:0 1px}.condition-delete{display:none;opacity:0;transition:opacity .3s ease-in-out}.wafs-condition-wrap:hover .condition-delete{display:inline-block;opacity:1}.add.button:before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;margin-right:7px;content:"\e007"}#advanced_free_shipping_shipping_methods tr .row-actions{visibility:hidden}#advanced_free_shipping_shipping_methods tr:hover>td>.row-actions{visibility:visible !important}
1
+ .wpc-conditions .wpc-condition-group{margin-bottom:30px;background-color:#f5f5f5;padding:15px 20px 20px;border:1px solid #ddd;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.04);box-shadow:0 1px 1px rgba(0,0,0,0.04);min-height:30px}.wpc-conditions .wpc-condition-group .wpc-condition-wrap{margin:10px 0 5px}.wpc-conditions .wpc-condition-group .wpc-condition-wrap .wpc-condition{width:30%}.wpc-conditions .wpc-condition-group .wpc-condition-wrap .wpc-operator{width:12%;min-width:140px}.wpc-conditions .wpc-condition-group .wpc-condition-wrap .wpc-value{width:30%;height:28px}.wpc-conditions .wpc-condition-group .wpc-condition-wrap .wpc-description{float:right}.wpc-conditions .wpc-condition-group .wpc-condition-wrap input{vertical-align:top}.wpc-conditions .or-text{display:none !important}.wpc-conditions .wpc-condition-group ~ .or-text,.wpc-conditions .wpc-condition-group ~ .or-text ~ .wpc-condition-group .or-text{display:block !important}.wpc-conditions .wpc-condition-delete{display:none;opacity:0;transition:opacity .3s ease-in-out}.wpc-conditions .wpc-condition-wrap:hover .wpc-condition-delete{display:inline-block;opacity:1}.wpc-conditions .wpc-condition-wrap.loading{height:30px}.wpc-conditions .wpc-condition-wrap.loading .loading-icon{width:100%;clear:both;display:block;text-align:center;line-height:110%;margin:0 1px}.wpc-condition-wrap .wpc-value.select2-container{display:inline-block !important;margin:1px}.wpc-condition-wrap .wpc-value.select2-container.select2-container-active .select2-choice{border:1px solid #666}.wpc-condition-wrap .wpc-value.select2-container.select2-drop-above .select2-choice{border-radius:0 0 4px 4px;border:1px solid #666;border-top-color:transparent}.wpc-condition-wrap .wpc-value.select2-container .select2-choice{border-color:#ddd;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;height:26px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.07);box-shadow:inset 0 1px 2px rgba(0,0,0,0.07)}.wpc-condition-wrap .wpc-value.select2-dropdown-open .select2-choice{border-bottom-color:transparent;-webkit-box-shadow:0 1px 0 #fff inset;box-shadow:0 1px 0 #fff inset;border-bottom-left-radius:0;border-bottom-right-radius:0;border:1px solid #666;outline:0}.wpc-conditions-post-table .sort{padding:0 4px;cursor:move;text-align:center;vertical-align:middle}.wpc-conditions-post-table .sort:before{content:"\e032";font-family:WooCommerce;text-align:center;line-height:1;color:#999;display:block;width:100%;float:left;height:100%}.wpc-conditions-post-table .sort:before,.wpc-conditions-post-table .row-actions{visibility:hidden !important}.wpc-conditions-post-table tr:hover .sort:before,.wpc-conditions-post-table tr:hover>td>.row-actions{visibility:visible !important}.wpc-conditions-post-table .add.button:before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;margin-right:7px;content:"\e007"}.wpc-currency{padding:3px 10px;font-size:14px;font-weight:400;line-height:19px;height:27px;box-sizing:border-box;color:#555;text-align:center;background-color:#EEE;border:1px solid #DDD;border-right:none;border-radius:4px 0px 0px 4px;margin:1px 0px 1px 1px;display:inline-block}.wpc-currency+input{margin-left:-4px;line-height:19px;width:161px !important}.post-type-wafs .misc-pub-visibility#visibility{display:none}.wafs-option label{display:inline-block;width:150px}.wafs_conditions_meta_box>p:first-child+div>.or_match{display:none}.condition-group{margin-bottom:30px;background-color:#f5f5f5;padding:15px 20px 20px;border:1px solid #ddd;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.04);box-shadow:0 1px 1px rgba(0,0,0,0.04)}.wafs-condition-wrap{margin:10px 0px 5px}.wafs-condition-wrap .wafs-condition{width:30%}.wafs-condition-wrap .wafs-operator{width:12%;min-width:140px}.wafs-condition-wrap .wafs-value{width:30%}.wafs-condition-wrap input{vertical-align:top}#wafs_conditions p+p{display:none}.wafs_desc{display:none;position:absolute;background:rgba(0,0,0,0.8);min-width:25px;max-width:200px;border-radius:6px;padding:5px 10px;color:white;margin-top:10px;right:40px;text-align:center}.wafs_desc:after{border-top:0px solid transparent;border-right:10px solid transparent;border-left:10px solid transparent;border-bottom:10px solid rgba(0,0,0,0.8);content:' ';position:absolute;top:-10px;right:10px;z-index:999}.wafs_tip:hover ~ .wafs_desc{display:block !important}.wafs-description{width:40px;float:right;line-height:20px}.wafs-condition-wrap ~ .loading-icon{display:block}.loading-icon{width:30%;clear:both;display:inline-block;text-align:center;line-height:110%;margin:0 1px}.condition-delete{display:none;opacity:0;transition:opacity .3s ease-in-out}.wafs-condition-wrap:hover .condition-delete{display:inline-block;opacity:1}.add.button:before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;margin-right:7px;content:"\e007"}#advanced_free_shipping_shipping_methods tr .row-actions{visibility:hidden}#advanced_free_shipping_shipping_methods tr:hover>td>.row-actions{visibility:visible !important}
includes/admin/class-wafs-condition.php CHANGED
@@ -231,12 +231,12 @@ class WAFS_Condition {
231
  $values['type'] = 'select';
232
  $values['class'][] = 'wc-enhanced-select';
233
 
 
234
  foreach ( WC()->countries->states as $country => $states ) :
235
 
236
  if ( empty( $states ) ) continue; // Don't show country if it has no states
237
  if ( ! array_key_exists( $country, WC()->countries->get_allowed_countries() ) ) continue; // Skip unallowed countries
238
 
239
- $country_states = array();
240
  foreach ( $states as $state_key => $state ) :
241
  $country_states[ WC()->countries->countries[ $country ] ][ $country . '_' . $state_key ] = $state;
242
  endforeach;
231
  $values['type'] = 'select';
232
  $values['class'][] = 'wc-enhanced-select';
233
 
234
+ $country_states = array();
235
  foreach ( WC()->countries->states as $country => $states ) :
236
 
237
  if ( empty( $states ) ) continue; // Don't show country if it has no states
238
  if ( ! array_key_exists( $country, WC()->countries->get_allowed_countries() ) ) continue; // Skip unallowed countries
239
 
 
240
  foreach ( $states as $state_key => $state ) :
241
  $country_states[ WC()->countries->countries[ $country ] ][ $country . '_' . $state_key ] = $state;
242
  endforeach;
includes/class-wafs-match-conditions.php CHANGED
@@ -369,13 +369,15 @@ class WAFS_Match_Conditions {
369
  if ( ! isset( WC()->customer ) ) return $match;
370
 
371
  $user_zipcode = WC()->customer->get_shipping_postcode();
 
372
 
373
  // Prepare allowed values.
374
  $zipcodes = (array) preg_split( '/,+ */', $value );
375
 
376
  // Remove all non- letters and numbers
377
  foreach ( $zipcodes as $key => $zipcode ) :
378
- $zipcodes[ $key ] = preg_replace( '/[^0-9a-zA-Z-\*]/', '', $zipcode );
 
379
  endforeach;
380
 
381
  if ( '==' == $operator ) :
@@ -385,10 +387,7 @@ class WAFS_Match_Conditions {
385
  // @since 1.0.9 - Wildcard support (*)
386
  if ( strpos( $zipcode, '*' ) !== false ) :
387
 
388
- $user_zipcode = preg_replace( '/[^0-9a-zA-Z]/', '', $user_zipcode );
389
- $zipcode = str_replace( '*', '', $zipcode );
390
-
391
- if ( empty( $zipcode ) ) continue;
392
 
393
  $parts = explode( '-', $zipcode );
394
  if ( count( $parts ) > 1 ) :
@@ -398,10 +397,7 @@ class WAFS_Match_Conditions {
398
  endif;
399
 
400
  else :
401
-
402
- // BC when not using asterisk (wildcard)
403
- $match = ( (double) $user_zipcode == (double) $zipcode );
404
-
405
  endif;
406
 
407
  if ( $match == true ) {
@@ -420,10 +416,7 @@ class WAFS_Match_Conditions {
420
  // @since 1.0.9 - Wildcard support (*)
421
  if ( strpos( $zipcode, '*' ) !== false ) :
422
 
423
- $user_zipcode = preg_replace( '/[^0-9a-zA-Z]/', '', $user_zipcode );
424
- $zipcode = str_replace( '*', '', $zipcode );
425
-
426
- if ( empty( $zipcode ) ) continue;
427
 
428
  $parts = explode( '-', $zipcode );
429
  if ( count( $parts ) > 1 ) :
@@ -437,14 +430,11 @@ class WAFS_Match_Conditions {
437
  endif;
438
 
439
  else :
440
-
441
- // BC when not using asterisk (wildcard)
442
- $zipcode_match = ( (double) $user_zipcode == (double) $zipcode );
443
 
444
  if ( $zipcode_match == true ) :
445
  return $match = false;
446
  endif;
447
-
448
  endif;
449
 
450
  endforeach;
@@ -545,12 +535,30 @@ class WAFS_Match_Conditions {
545
  */
546
  public function wafs_match_condition_country( $match, $operator, $value ) {
547
 
548
- if ( ! isset( WC()->customer ) ) return $match;
 
 
 
 
 
 
 
 
549
 
550
  if ( '==' == $operator ) :
551
- $match = ( preg_match( "/^$value$/i", WC()->customer->get_shipping_country() ) );
 
 
 
 
 
552
  elseif ( '!=' == $operator ) :
553
- $match = ( ! preg_match( "/^$value$/i", WC()->customer->get_shipping_country() ) );
 
 
 
 
 
554
  endif;
555
 
556
  return $match;
369
  if ( ! isset( WC()->customer ) ) return $match;
370
 
371
  $user_zipcode = WC()->customer->get_shipping_postcode();
372
+ $user_zipcode = preg_replace( '/[^0-9a-zA-Z]/', '', $user_zipcode );
373
 
374
  // Prepare allowed values.
375
  $zipcodes = (array) preg_split( '/,+ */', $value );
376
 
377
  // Remove all non- letters and numbers
378
  foreach ( $zipcodes as $key => $zipcode ) :
379
+ $zip = preg_replace( '/[^0-9a-zA-Z\-\*]/', '', $zipcode );
380
+ $zipcodes[ $key ] = strtoupper( $zip );
381
  endforeach;
382
 
383
  if ( '==' == $operator ) :
387
  // @since 1.0.9 - Wildcard support (*)
388
  if ( strpos( $zipcode, '*' ) !== false ) :
389
 
390
+ $zipcode = str_replace( '*', '', $zipcode );
 
 
 
391
 
392
  $parts = explode( '-', $zipcode );
393
  if ( count( $parts ) > 1 ) :
397
  endif;
398
 
399
  else :
400
+ $match = ( (double) $user_zipcode == (double) $zipcode ); // BC when not using asterisk (wildcard)
 
 
 
401
  endif;
402
 
403
  if ( $match == true ) {
416
  // @since 1.0.9 - Wildcard support (*)
417
  if ( strpos( $zipcode, '*' ) !== false ) :
418
 
419
+ $zipcode = str_replace( '*', '', $zipcode );
 
 
 
420
 
421
  $parts = explode( '-', $zipcode );
422
  if ( count( $parts ) > 1 ) :
430
  endif;
431
 
432
  else :
433
+ $zipcode_match = ( (double) $user_zipcode == (double) $zipcode ); // BC when not using asterisk (wildcard)
 
 
434
 
435
  if ( $zipcode_match == true ) :
436
  return $match = false;
437
  endif;
 
438
  endif;
439
 
440
  endforeach;
535
  */
536
  public function wafs_match_condition_country( $match, $operator, $value ) {
537
 
538
+ if ( ! isset( WC()->customer ) ) :
539
+ return $match;
540
+ endif;
541
+
542
+ $user_country = WC()->customer->get_shipping_country();
543
+
544
+ if ( method_exists( WC()->countries, 'get_continent_code_for_country' ) ) :
545
+ $user_continent = WC()->countries->get_continent_code_for_country( $user_country );
546
+ endif;
547
 
548
  if ( '==' == $operator ) :
549
+ $match = stripos( $user_country, $value ) === 0;
550
+
551
+ // Check for continents if available
552
+ if ( ! $match && isset( $user_continent ) && strpos( $value, 'CO_' ) === 0 ) :
553
+ $match = stripos( $user_continent, str_replace( 'CO_','', $value ) ) === 0;
554
+ endif;
555
  elseif ( '!=' == $operator ) :
556
+ $match = stripos( $user_country, $value ) === false;
557
+
558
+ // Check for continents if available
559
+ if ( ! $match && isset( $user_continent ) && strpos( $value, 'CO_' ) === 0 ) :
560
+ $match = stripos( $user_continent, str_replace( 'CO_','', $value ) ) === false;
561
+ endif;
562
  endif;
563
 
564
  return $match;
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: sormano
3
  Tags: woocommerce, shipping, woocommerce shipping, woocommerce free shipping, woocommerce free, woocommerce advanced free shipping, wc free shipping, wc shipping, advanced shipping, pro shipping, table rate shipping, country shipping, free shipping
4
  Requires at least: 4.0
5
  Tested up to: 4.6
6
- Stable tag: 1.0.10
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -65,6 +65,11 @@ WooCommerce Advanced Free Shipping is an plugin which allows you to set up advan
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
68
  = 1.0.10 - 25-08-2016 =
69
 
70
  * [Improvement] - Optimized asset scripts
3
  Tags: woocommerce, shipping, woocommerce shipping, woocommerce free shipping, woocommerce free, woocommerce advanced free shipping, wc free shipping, wc shipping, advanced shipping, pro shipping, table rate shipping, country shipping, free shipping
4
  Requires at least: 4.0
5
  Tested up to: 4.6
6
+ Stable tag: 1.0.11
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
65
 
66
  == Changelog ==
67
 
68
+ = 1.0.11 - 05-09-2016 =
69
+
70
+ * [Fix] - State condition field only displayed states of the last country
71
+ * [Fix] - Inability to add new conditions due to error
72
+
73
  = 1.0.10 - 25-08-2016 =
74
 
75
  * [Improvement] - Optimized asset scripts
woocommerce-advanced-free-shipping.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WooCommerce Advanced Free Shipping
4
  * Plugin URI: https://wordpress.org/plugins/woocommerce-advanced-free-shipping/
5
  * Description: WooCommerce Advanced Free Shipping is an plugin which allows you to set up advanced free shipping conditions.
6
- * Version: 1.0.10
7
  * Author: Jeroen Sormani
8
  * Author URI: http://jeroensormani.com/
9
  * Text Domain: woocommerce-advanced-free-shipping
@@ -48,7 +48,7 @@ class WooCommerce_Advanced_Free_Shipping {
48
  * @since 1.0.4
49
  * @var string $version Plugin version number.
50
  */
51
- public $version = '1.0.10';
52
 
53
 
54
  /**
3
  * Plugin Name: WooCommerce Advanced Free Shipping
4
  * Plugin URI: https://wordpress.org/plugins/woocommerce-advanced-free-shipping/
5
  * Description: WooCommerce Advanced Free Shipping is an plugin which allows you to set up advanced free shipping conditions.
6
+ * Version: 1.0.11
7
  * Author: Jeroen Sormani
8
  * Author URI: http://jeroensormani.com/
9
  * Text Domain: woocommerce-advanced-free-shipping
48
  * @since 1.0.4
49
  * @var string $version Plugin version number.
50
  */
51
+ public $version = '1.0.11';
52
 
53
 
54
  /**