WooCommerce Advanced Free Shipping - Version 1.0.10

Version Description

  • 25-08-2016 =

  • [Improvement] - Optimized asset scripts

  • [Improvement] - Refactored condition code (backend)

  • [Improvement] - Allow asterisk (*) in zipcode to allow 'begins with' type of matching functionality

  • [Improvement] - Allow dollar and percentage signs in the 'coupon' condition to setup the condition based on the amounts instead of solely coupon codes

  • [Improvement] - Add a link to the shipping rates overview page on the plugins page

  • [Improvement] - Add support for continents in the 'country' condition (requires WC 2.6+)

  • [Improvement] - Improved 'product' condition value fields (allow searching) and supports huge amounts of product

  • [Improvement] - Allow comma separated cities

Download this release

Release Info

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

Code changes from version 1.0.9 to 1.0.10

assets/css/parts/wp-conditions.scss ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPC 1.0.1
3
+ */
4
+
5
+ /**************************************************************
6
+ * Conditions
7
+ *************************************************************/
8
+ .wpc-conditions {
9
+
10
+ // Condition group
11
+ .wpc-condition-group {
12
+ margin-bottom: 30px;
13
+ background-color: #f5f5f5;
14
+ padding: 15px 20px 20px;
15
+ border: 1px solid #ddd;
16
+ -webkit-box-shadow: 0 1px 1px rgba( 0, 0, 0, .04 );
17
+ box-shadow: 0 1px 1px rgba( 0, 0, 0, .04 );
18
+ min-height: 30px;
19
+
20
+ // Condition row
21
+ .wpc-condition-wrap {
22
+ margin: 10px 0 5px;
23
+
24
+ .wpc-condition {
25
+ width: 30%;
26
+ }
27
+ .wpc-operator {
28
+ width: 12%;
29
+ min-width: 140px;
30
+ }
31
+ .wpc-value {
32
+ width: 30%;
33
+ height: 28px;
34
+ }
35
+ .wpc-description {
36
+ float: right;
37
+ }
38
+ input {
39
+ vertical-align: top;
40
+ }
41
+ }
42
+ }
43
+
44
+ // Or text
45
+ .or-text {
46
+ display: none !important;
47
+ }
48
+ .wpc-condition-group ~ .or-text,
49
+ .wpc-condition-group ~ .or-text ~ .wpc-condition-group .or-text { // Ensures the one in the first group isn't shown
50
+ display: block !important;
51
+ }
52
+
53
+ // Delete button
54
+ .wpc-condition-delete {
55
+ display: none;
56
+ opacity: 0;
57
+ transition: opacity .3s ease-in-out;
58
+ }
59
+ .wpc-condition-wrap:hover .wpc-condition-delete {
60
+ display: inline-block;
61
+ opacity: 1;
62
+ }
63
+
64
+ // Load icon
65
+ .wpc-condition-wrap.loading {
66
+ height: 30px;
67
+
68
+ .loading-icon {
69
+ width: 100%;
70
+ clear: both;
71
+ display: block;
72
+ text-align: center;
73
+ line-height: 110%;
74
+ margin: 0 1px;
75
+ }
76
+ }
77
+ }
78
+
79
+
80
+ /**************************************************************
81
+ * Select2
82
+ *************************************************************/
83
+ .wpc-condition-wrap {
84
+
85
+ .wpc-value.select2-container {
86
+ display: inline-block !important;
87
+ margin: 1px;
88
+
89
+ &.select2-container-active .select2-choice {
90
+ border: 1px solid #666;
91
+ }
92
+ &.select2-drop-above .select2-choice {
93
+ border-radius: 0 0 4px 4px;
94
+ border: 1px solid #666;
95
+ border-top-color: rgba(0, 0, 0, 0);
96
+ }
97
+ .select2-choice {
98
+ border-color: #ddd;
99
+ -webkit-border-radius: 5px;
100
+ -moz-border-radius: 5px;
101
+ border-radius: 5px;
102
+ height: 26px;
103
+ -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
104
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
105
+ }
106
+ }
107
+ .wpc-value.select2-dropdown-open .select2-choice {
108
+ border-bottom-color: rgba(0, 0, 0, 0);
109
+ -webkit-box-shadow: 0 1px 0 #fff inset;
110
+ box-shadow: 0 1px 0 #fff inset;
111
+ border-bottom-left-radius: 0;
112
+ border-bottom-right-radius: 0;
113
+ border: 1px solid #666;
114
+ outline: 0;
115
+ }
116
+ }
117
+
118
+
119
+ /************************
120
+ * Table / overview
121
+ ***********************/
122
+ .wpc-conditions-post-table {
123
+
124
+ .sort {
125
+ padding: 0 4px;
126
+ cursor: move;
127
+ text-align: center;
128
+ vertical-align: middle;
129
+
130
+ &:before {
131
+ content: "\e032";
132
+ font-family: WooCommerce;
133
+ text-align: center;
134
+ line-height: 1;
135
+ color: #999;
136
+ display: block;
137
+ width: 100%;
138
+ float: left;
139
+ height: 100%;
140
+ }
141
+ }
142
+ .sort:before,
143
+ .row-actions {
144
+ visibility: hidden !important;
145
+ }
146
+ tr:hover .sort:before,
147
+ tr:hover > td > .row-actions {
148
+ visibility: visible !important;
149
+ }
150
+
151
+ /* WooCommerce Add icon */
152
+ .add.button:before {
153
+ font-family: WooCommerce;
154
+ speak: none;
155
+ font-weight: 400;
156
+ font-variant: normal;
157
+ text-transform: none;
158
+ line-height: 1;
159
+ -webkit-font-smoothing: antialiased;
160
+ margin-right: 7px;
161
+ content: "\e007";
162
+ }
163
+ }
164
+
165
+
166
+ // Currency
167
+ .wpc-currency {
168
+ padding: 3px 10px;
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;
176
+ border: 1px solid #DDD;
177
+ border-right: none;
178
+ border-radius: 4px 0px 0px 4px;
179
+ margin: 1px 0px 1px 1px;
180
+ display: inline-block;
181
+
182
+ & + input {
183
+ margin-left: -4px;
184
+ line-height: 19px ;
185
+ width: 161px !important;
186
+ }
187
+ }
assets/css/woocommerce-advanced-free-shipping.min.css ADDED
@@ -0,0 +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}
assets/css/{admin-style.css → woocommerce-advanced-free-shipping.scss} RENAMED
@@ -1,3 +1,5 @@
 
 
1
  /* Hide visibility from admin */
2
  .post-type-wafs .misc-pub-visibility#visibility {
3
  display: none;
1
+ @import 'parts/wp-conditions';
2
+
3
  /* Hide visibility from admin */
4
  .post-type-wafs .misc-pub-visibility#visibility {
5
  display: none;
assets/js/wafs-js.js DELETED
@@ -1,83 +0,0 @@
1
- jQuery( function( $ ) {
2
-
3
- var loading_icon = '<span class="loading-icon"><img src="images/wpspin_light.gif"/></span>';
4
-
5
- // Add condition
6
- $( '#wafs_conditions' ).on( 'click', '.condition-add', function() {
7
-
8
- var data = { action: 'wafs_add_condition', group: $( this ).attr( 'data-group' ), nonce: wafs.nonce };
9
-
10
- $( '.condition-group-' + data.group ).append( loading_icon ).children( ':last' );
11
-
12
- $.post( ajaxurl, data, function( response ) {
13
- $( '.condition-group-' + data.group ).append( response ).children( ':last' ).hide().fadeIn( 'normal' );
14
- $( '.condition-group-' + data.group + ' .loading-icon' ).children( ':first' ).remove();
15
- });
16
-
17
- });
18
-
19
- // Delete condition
20
- $( '#wafs_conditions' ).on( 'click', '.condition-delete', function() {
21
-
22
- if ( $( this ).closest( '.condition-group' ).children( '.wafs-condition-wrap' ).length == 1 ) {
23
- $( this ).closest( '.condition-group' ).fadeOut( 'normal', function() { $( this ).remove(); });
24
-
25
- } else {
26
- $( this ).closest( '.wafs-condition-wrap' ).fadeOut( 'normal', function() { $( this ).remove(); });
27
- }
28
-
29
- });
30
-
31
- // Add condition group
32
- $( '#wafs_conditions' ).on( 'click', '.condition-group-add', function() {
33
-
34
- // Display loading icon
35
- $( '.wafs_conditions' ).append( loading_icon ).children( ':last' );
36
-
37
- var data = {
38
- action: 'wafs_add_condition_group',
39
- group: parseInt( $( '.condition-group' ).last().attr( 'data-group') ) + 1,
40
- nonce: wafs.nonce
41
- };
42
-
43
- // Insert condition group
44
- $.post( ajaxurl, data, function( response ) {
45
- $( '.condition-group ~ .loading-icon' ).last().remove();
46
- $( '.wafs_conditions' ).append( response ).children( ':last' ).hide().fadeIn( 'normal' );
47
- });
48
-
49
- });
50
-
51
- // Update condition values
52
- $( '#wafs_conditions' ).on( 'change', '.wafs-condition', function () {
53
-
54
- var data = {
55
- action: 'wafs_update_condition_value',
56
- id: $( this ).attr( 'data-id' ),
57
- group: $( this ).attr( 'data-group' ),
58
- condition: $( this ).val(),
59
- nonce: wafs.nonce
60
- };
61
-
62
- var replace = '.wafs-value-wrap-' + data.id;
63
-
64
- $( replace ).html( loading_icon );
65
-
66
- $.post( ajaxurl, data, function( response ) {
67
- $( replace ).replaceWith( response );
68
- });
69
-
70
- // Update condition description
71
- var description = {
72
- action: 'wafs_update_condition_description',
73
- condition: data.condition,
74
- nonce: wafs.nonce
75
- };
76
-
77
- $.post( ajaxurl, description, function( description_response ) {
78
- $( replace + ' ~ .wafs-description' ).replaceWith( description_response );
79
- });
80
-
81
- });
82
-
83
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/woocommerce-advanced-free-shipping.js ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function( $ ) {
2
+
3
+ /**************************************************************
4
+ * WPC - 1.0.1
5
+ *************************************************************/
6
+
7
+ // Add condition
8
+ $( document.body ).on( 'click', '.wpc-condition-add', function() {
9
+
10
+ var $this = $( this );
11
+ var data = {
12
+ action: wpc.action_prefix + 'add_condition',
13
+ group: $( this ).attr( 'data-group' ),
14
+ nonce: wpc.nonce
15
+ };
16
+ var condition_group = $this.parents( '.wpc-conditions' ).find( '.wpc-condition-group-' + data.group );
17
+
18
+ var loading_icon = '<div class="wpc-condition-wrap loading"></div>';
19
+ condition_group.append( loading_icon ).children( ':last' ).block({ message: null, overlayCSS: { background: '', opacity: 0.6 } });
20
+
21
+ $.post( ajaxurl, data, function( response ) {
22
+ condition_group.find( ' .wpc-condition-wrap.loading' ).first().replaceWith( function() {
23
+ return $( response ).hide().fadeIn( 'normal' );
24
+ });
25
+ });
26
+
27
+ });
28
+
29
+ // Delete condition
30
+ $( document.body ).on( 'click', '.wpc-condition-delete', function() {
31
+
32
+ if ( $( this ).closest( '.wpc-condition-group' ).children( '.wpc-condition-wrap' ).length == 1 ) {
33
+ $( this ).closest( '.wpc-condition-group' ).fadeOut( 'normal', function() {
34
+ $( this ).next( '.or-text' ).remove();
35
+ $( this ).remove();
36
+ });
37
+ } else {
38
+ $( this ).closest( '.wpc-condition-wrap' ).slideUp( 'fast', function() { $( this ).remove(); });
39
+ }
40
+
41
+ });
42
+
43
+ // Add condition group
44
+ $( document.body ).on( 'click', '.wpc-condition-group-add', function() {
45
+
46
+ var condition_group_loading = '<div class="wpc-condition-group loading"></div>';
47
+ var conditions = $( this ).prev( '.wpc-conditions' );
48
+ var data = {
49
+ action: wpc.action_prefix + 'add_condition_group',
50
+ group: parseInt( $( this ).prev( '.wpc-conditions' ).find( '.wpc-condition-group' ).length ),
51
+ nonce: wpc.nonce
52
+ };
53
+
54
+ // Display loading icon
55
+ conditions.append( condition_group_loading ).children( ':last' ).block({ message: null, overlayCSS: { background: '', opacity: 0.6 } });
56
+
57
+ // Insert condition group
58
+ $.post( ajaxurl, data, function( response ) {
59
+ conditions.find( '.wpc-condition-group.loading' ).first().replaceWith( function() {
60
+ return $( response ).hide().fadeIn( 'normal' );
61
+ });
62
+ });
63
+
64
+ });
65
+
66
+ // Update condition values
67
+ $( document.body ).on( 'change', '.wpc-condition', function () {
68
+
69
+ var loading_wrap = '<span style="width: 30%; border: 1px solid transparent; display: inline-block;">&nbsp;</span>';
70
+ var data = {
71
+ action: wpc.action_prefix + 'update_condition_value',
72
+ id: $( this ).attr( 'data-id' ),
73
+ group: $( this ).attr( 'data-group' ),
74
+ condition: $( this ).val(),
75
+ nonce: wpc.nonce
76
+ };
77
+ var condition_group = $( this ).parents( '.wpc-conditions' ).find( '.wpc-condition-group-' + data.group );
78
+ var replace = '.wpc-value-wrap-' + data.id;
79
+
80
+ // Loading icon
81
+ condition_group.find( replace ).html( loading_wrap ).block({ message: null, overlayCSS: { background: '', opacity: 0.6 } });
82
+
83
+ // Replace value field
84
+ $.post( ajaxurl, data, function( response ) {
85
+ condition_group.find( replace ).replaceWith( response );
86
+ $( document.body ).trigger( 'wc-enhanced-select-init' );
87
+ });
88
+
89
+ // Update condition description
90
+ var description = {
91
+ action: wpc.action_prefix + 'update_condition_description',
92
+ condition: data.condition,
93
+ nonce: wpc.nonce
94
+ };
95
+
96
+ $.post( ajaxurl, description, function( description_response ) {
97
+ condition_group.find( replace + ' ~ .wpc-description' ).replaceWith( description_response );
98
+ // Tooltip
99
+ $( '.tips, .help_tip, .woocommerce-help-tip' ).tipTip({ 'attribute': 'data-tip', 'fadeIn': 50, 'fadeOut': 50, 'delay': 200 });
100
+ })
101
+
102
+ });
103
+
104
+ });
assets/js/woocommerce-advanced-free-shipping.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(function($){$(document.body).on("click",".wpc-condition-add",function(){var n=$(this),o={action:wpc.action_prefix+"add_condition",group:$(this).attr("data-group"),nonce:wpc.nonce},i=n.parents(".wpc-conditions").find(".wpc-condition-group-"+o.group),t='<div class="wpc-condition-wrap loading"></div>';i.append(t).children(":last").block({message:null,overlayCSS:{background:"",opacity:.6}}),$.post(ajaxurl,o,function(n){i.find(" .wpc-condition-wrap.loading").first().replaceWith(function(){return $(n).hide().fadeIn("normal")})})}),$(document.body).on("click",".wpc-condition-delete",function(){1==$(this).closest(".wpc-condition-group").children(".wpc-condition-wrap").length?$(this).closest(".wpc-condition-group").fadeOut("normal",function(){$(this).next(".or-text").remove(),$(this).remove()}):$(this).closest(".wpc-condition-wrap").slideUp("fast",function(){$(this).remove()})}),$(document.body).on("click",".wpc-condition-group-add",function(){var n='<div class="wpc-condition-group loading"></div>',o=$(this).prev(".wpc-conditions"),i={action:wpc.action_prefix+"add_condition_group",group:parseInt($(this).prev(".wpc-conditions").find(".wpc-condition-group").length),nonce:wpc.nonce};o.append(n).children(":last").block({message:null,overlayCSS:{background:"",opacity:.6}}),$.post(ajaxurl,i,function(n){o.find(".wpc-condition-group.loading").first().replaceWith(function(){return $(n).hide().fadeIn("normal")})})}),$(document.body).on("change",".wpc-condition",function(){var n='<span style="width: 30%; border: 1px solid transparent; display: inline-block;">&nbsp;</span>',o={action:wpc.action_prefix+"update_condition_value",id:$(this).attr("data-id"),group:$(this).attr("data-group"),condition:$(this).val(),nonce:wpc.nonce},i=$(this).parents(".wpc-conditions").find(".wpc-condition-group-"+o.group),t=".wpc-value-wrap-"+o.id;i.find(t).html(n).block({message:null,overlayCSS:{background:"",opacity:.6}}),$.post(ajaxurl,o,function(n){i.find(t).replaceWith(n),$(document.body).trigger("wc-enhanced-select-init")});var c={action:wpc.action_prefix+"update_condition_description",condition:o.condition,nonce:wpc.nonce};$.post(ajaxurl,c,function(n){i.find(t+" ~ .wpc-description").replaceWith(n),$(".tips, .help_tip, .woocommerce-help-tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})})})});
codeoversight.yml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ php:
2
+ align_array_elements: space
3
+ align_doc_tags: double_space
4
+ align_variables: space
5
+ closing_newline: add
6
+ closing_php_tag: remove
7
+ control_structure_parentheses_inner_whitespace: whitespace
8
+ doc_function_whitespace: no_space
9
+ else_if_whitespace: no_space
10
+ exclamation_whitespace: whitespace
11
+ force_control_structure_braces: force
12
+ function_args_separator_whitespace: whitespace
13
+ function_parentheses_inner_whitespace: whitespace
14
+ indentation_whitespace: tab
15
+ opening_doc_asterisk: double
16
+ php_tag_casing: lower
17
+ php_tags: full_php_tags
18
+ remove_double_semicolon: remove
19
+ remove_empty_trailing_leading_doc_lines: remove
20
+ semicolon_before_closing_php_tag: add
21
+ static_array_index_whitespace: no_space
22
+ string_operator_whitespace: whitespace
23
+ trailing_whitespace: remove
24
+ true_false_casing: lower
25
+ type_cast_casing: lower
26
+ type_cast_inner_whitespace: no_space
27
+ use_quotes: single_quotes
28
+ variable_array_index_whitespace: whitespace
29
+ whitespace_after_control_structure: whitespace
30
+ whitespace_after_doc_asterisk: single_space
31
+ whitespace_after_else: space
32
+ whitespace_after_function_open: newline
33
+ whitespace_after_function: double_newline
34
+ whitespace_before_control_structure_brace: space
35
+ whitespace_before_doc_asterisk: space
36
+ whitespace_before_else: space
37
+ whitespace_before_function_brace: space
38
+ whitespace_before_function_close: newline
39
+ whitespace_before_function_parentheses: no_space
includes/admin/admin-functions.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+
4
+ if ( ! function_exists( 'wpc_html_field' ) ) {
5
+
6
+ /**
7
+ * Output html field.
8
+ *
9
+ * Output a new HTML field.
10
+ *
11
+ * @since 1.1.6
12
+ *
13
+ * @param array $args
14
+ */
15
+ function wpc_html_field( $args = array() ) {
16
+
17
+ $args = wp_parse_args( $args, array(
18
+ 'id' => '',
19
+ 'type' => 'text',
20
+ 'name' => '',
21
+ 'class' => '',
22
+ 'value' => null,
23
+ 'default' => '',
24
+ 'placeholder' => '',
25
+ 'custom_attributes' => isset( $args['custom_attr'] ) ? $args['custom_attr'] : array(), // BC
26
+ ) );
27
+
28
+ $type = ! empty( $args['field'] ) ? $args['field'] : $args['type'];
29
+ $class = is_array( $args['class'] ) ? implode( ' ', array_map( 'sanitize_html_class', $args['class'] ) ) : sanitize_html_class( $args['class'] );
30
+ $value = isset( $args['value'] ) ? $args['value'] : '';
31
+ $name = isset( $args['name'] ) ? $args['name'] : $args['id'];
32
+ $custom_attributes = array();
33
+ if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
34
+ foreach ( $args['custom_attributes'] as $k => $v ) {
35
+ $custom_attributes[ $k ] = esc_attr( $k ) . '="' . esc_attr( $v ) . '"';
36
+ }
37
+ }
38
+
39
+ switch ( $type ) :
40
+
41
+ case 'text' :
42
+ case 'number' :
43
+ ?><input
44
+ name="<?php echo esc_attr( $name ); ?>"
45
+ type="<?php echo $args['type']; ?>"
46
+ id="<?php echo esc_attr( $args['id'] ); ?>"
47
+ value="<?php echo esc_attr( $value ); ?>"
48
+ class="input-text <?php echo $class; ?>"
49
+ <?php echo implode( ' ', $custom_attributes ); ?>
50
+ placeholder='<?php echo esc_attr( $args['placeholder'] ); ?>'
51
+ ><?php
52
+ break;
53
+
54
+ case 'dropdown' :
55
+ case 'select' :
56
+
57
+ $options = is_array( $args['options'] ) ? $args['options'] : array();
58
+
59
+ ?><select
60
+ name="<?php echo esc_attr( $args['name'] ); ?>"
61
+ id="<?php echo esc_attr( $args['id'] ); ?>"
62
+ class="input-select <?php echo $class; ?>"
63
+ <?php echo implode( ' ', $custom_attributes ); ?>
64
+ ><?php
65
+
66
+ foreach ( $options as $index => $values ) :
67
+
68
+ if ( ! is_array( $values ) ) :
69
+ ?><option value='<?php echo esc_attr( $index ); ?>' <?php selected( $index, $value ); ?>><?php echo esc_attr( $values ); ?></option><?php
70
+ else :
71
+ ?><optgroup label='<?php echo esc_attr( $index ); ?>'><?php
72
+ foreach ( $values as $k => $v ) :
73
+ ?><option value='<?php echo esc_attr( $k ); ?>' <?php selected( $k, $value ); ?>><?php echo esc_attr( $v ); ?></option><?php
74
+ endforeach;
75
+ ?></optgroup><?php
76
+ endif;
77
+
78
+ endforeach;
79
+
80
+ if ( empty( $options ) ) :
81
+ ?><option readonly disabled><?php
82
+ _e( 'There are no options available', 'woocommerce-advanced-fees' );
83
+ ?></option><?php
84
+ endif;
85
+
86
+ ?></select><?php
87
+ break;
88
+
89
+ default :
90
+ case 'hook' :
91
+
92
+ do_action( 'woocommerce_advanced_fees_condition_value_field_type_' . $args['type'], $args );
93
+ break;
94
+
95
+ endswitch;
96
+
97
+ }
98
+
99
+
100
+ }
includes/admin/class-wafs-admin.php CHANGED
@@ -42,6 +42,12 @@ class WAFS_Admin {
42
  // Keep WC menu open while in WAFS edit screen
43
  add_action( 'admin_head', array( $this, 'menu_highlight' ) );
44
 
 
 
 
 
 
 
45
  }
46
 
47
 
@@ -54,20 +60,24 @@ class WAFS_Admin {
54
  */
55
  public function admin_enqueue_scripts() {
56
 
57
- wp_register_style( 'wafs-style', plugins_url( 'assets/css/admin-style.css', WAFS()->file ), array(), WAFS()->version );
58
- wp_register_script( 'wafs-js', plugins_url( 'assets/js/wafs-js.js', WAFS()->file ), array( 'jquery' ), WAFS()->version, true );
59
- wp_localize_script( 'wafs-js', 'wafs', array(
60
- 'nonce' => wp_create_nonce( 'wafs-ajax-nonce' ),
 
 
 
 
61
  ) );
62
 
63
  if (
64
  ( isset( $_REQUEST['post'] ) && 'wafs' == get_post_type( $_REQUEST['post'] ) ) ||
65
  ( isset( $_REQUEST['post_type'] ) && 'wafs' == $_REQUEST['post_type'] ) ||
66
- ( isset( $_REQUEST['section'] ) && 'wafs_free_shipping_method' == $_REQUEST['section'] )
67
  ) :
68
 
69
- wp_enqueue_style( 'wafs-style' );
70
- wp_enqueue_script( 'wafs-js' );
71
  wp_dequeue_script( 'autosave' );
72
 
73
  endif;
@@ -113,4 +123,29 @@ class WAFS_Admin {
113
  }
114
 
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
42
  // Keep WC menu open while in WAFS edit screen
43
  add_action( 'admin_head', array( $this, 'menu_highlight' ) );
44
 
45
+ global $pagenow;
46
+ if ( 'plugins.php' == $pagenow ) :
47
+ // Plugins page
48
+ add_filter( 'plugin_action_links_' . plugin_basename( WAFS()->file ), array( $this, 'add_plugin_action_links' ), 10, 2 );
49
+ endif;
50
+
51
  }
52
 
53
 
60
  */
61
  public function admin_enqueue_scripts() {
62
 
63
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
64
+
65
+ wp_register_style( 'woocommerce-advanced-free-shipping', plugins_url( 'assets/css/woocommerce-advanced-free-shipping.min.css', WAFS()->file ), array(), WAFS()->version );
66
+ wp_register_script( 'woocommerce-advanced-free-shipping', plugins_url( 'assets/js/woocommerce-advanced-free-shipping' . $suffix . '.js', WAFS()->file ), array( 'jquery' ), WAFS()->version, true );
67
+ wp_localize_script( 'woocommerce-advanced-free-shipping', 'wpc', array(
68
+ 'nonce' => wp_create_nonce( 'wpc-ajax-nonce' ),
69
+ 'action_prefix' => 'wafs_',
70
+ 'asset_url' => plugins_url( 'assets/', WAFS()->file ),
71
  ) );
72
 
73
  if (
74
  ( isset( $_REQUEST['post'] ) && 'wafs' == get_post_type( $_REQUEST['post'] ) ) ||
75
  ( isset( $_REQUEST['post_type'] ) && 'wafs' == $_REQUEST['post_type'] ) ||
76
+ ( isset( $_REQUEST['section'] ) && 'advanced_free_shipping' == $_REQUEST['section'] )
77
  ) :
78
 
79
+ wp_enqueue_style( 'woocommerce-advanced-free-shipping' );
80
+ wp_enqueue_script( 'woocommerce-advanced-free-shipping' );
81
  wp_dequeue_script( 'autosave' );
82
 
83
  endif;
123
  }
124
 
125
 
126
+ /**
127
+ * Plugin action links.
128
+ *
129
+ * Add links to the plugins.php page below the plugin name
130
+ * and besides the 'activate', 'edit', 'delete' action links.
131
+ *
132
+ * @since 1.0.10
133
+ *
134
+ * @param array $links List of existing links.
135
+ * @param string $file Name of the current plugin being looped.
136
+ * @return array List of modified links.
137
+ */
138
+ public function add_plugin_action_links( $links, $file ) {
139
+
140
+ if ( $file == plugin_basename( WAFS()->file ) ) :
141
+ $links = array_merge( array(
142
+ '<a href="' . esc_url( admin_url( '/admin.php?page=wc-settings&tab=shipping&section=advanced_free_shipping' ) ) . '">' . __( 'Settings', 'woocommerce-advanced-free-shipping' ) . '</a>'
143
+ ), $links );
144
+ endif;
145
+
146
+ return $links;
147
+
148
+ }
149
+
150
+
151
  }
includes/admin/class-wafs-condition.php ADDED
@@ -0,0 +1,350 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+
4
+ /**
5
+ * Condition class.
6
+ *
7
+ * Represents a single condition in a condition group.
8
+ *
9
+ * @author Jeroen Sormani
10
+ * @version 1.0.0
11
+ */
12
+ class WAFS_Condition {
13
+
14
+
15
+ /**
16
+ * Condition ID.
17
+ *
18
+ * @since 1.0.0
19
+ * @var string $id Condition ID.
20
+ */
21
+ public $id;
22
+
23
+ /**
24
+ * Condition.
25
+ *
26
+ * @since 1.0.0
27
+ * @var string $condition Condition slug.
28
+ */
29
+ public $condition;
30
+
31
+ /**
32
+ * Operator.
33
+ *
34
+ * @since 1.0.0
35
+ * @var string $operator Operator slug.
36
+ */
37
+ public $operator;
38
+
39
+ /**
40
+ * Value.
41
+ *
42
+ * @since 1.0.0
43
+ * @var string $value Condition value.
44
+ */
45
+ public $value;
46
+
47
+ /**
48
+ * Group ID.
49
+ *
50
+ * @since 1.0.0
51
+ * @var string $group Condition group ID.
52
+ */
53
+ public $group;
54
+
55
+
56
+ /**
57
+ * Constructor.
58
+ *
59
+ * @since 1.0.0
60
+ */
61
+ public function __construct( $id = null, $group = 0, $condition = null, $operator = null, $value = null ) {
62
+
63
+ $this->id = $id;
64
+ $this->group = $group;
65
+ $this->condition = $condition;
66
+ $this->operator = $operator;
67
+ $this->value = $value;
68
+
69
+ if ( ! $id ) {
70
+ $this->id = rand();
71
+ }
72
+
73
+ }
74
+
75
+
76
+ /**
77
+ * Output condition row.
78
+ *
79
+ * Output the full condition row which includes: condition, operator, value, add/delete buttons and
80
+ * the description.
81
+ *
82
+ * @since 1.1.6
83
+ */
84
+ public function output_condition_row() {
85
+
86
+ $wp_condition = $this;
87
+ require 'views/html-condition-row.php';
88
+
89
+ }
90
+
91
+
92
+ /**
93
+ * Get conditions.
94
+ *
95
+ * Get a list with the available conditions.
96
+ *
97
+ * @since 1.1.6
98
+ *
99
+ * @return array List of available conditions for a condition row.
100
+ */
101
+ public function get_conditions() {
102
+
103
+ $conditions = array(
104
+ __( 'Cart', 'woocommerce-advanced-free-shipping' ) => array(
105
+ 'subtotal' => __( 'Subtotal', 'woocommerce-advanced-free-shipping' ),
106
+ 'subtotal_ex_tax' => __( 'Subtotal ex. taxes', 'woocommerce-advanced-free-shipping' ),
107
+ 'tax' => __( 'Tax', 'woocommerce-advanced-free-shipping' ),
108
+ 'quantity' => __( 'Quantity', 'woocommerce-advanced-free-shipping' ),
109
+ 'contains_product' => __( 'Contains product', 'woocommerce-advanced-free-shipping' ),
110
+ 'coupon' => __( 'Coupon', 'woocommerce-advanced-free-shipping' ),
111
+ 'weight' => __( 'Weight', 'woocommerce-advanced-free-shipping' ),
112
+ 'contains_shipping_class' => __( 'Contains shipping class', 'woocommerce-advanced-free-shipping' ),
113
+ ),
114
+ __( 'User Details', 'woocommerce-advanced-free-shipping' ) => array(
115
+ 'zipcode' => __( 'Zipcode', 'woocommerce-advanced-free-shipping' ),
116
+ 'city' => __( 'City', 'woocommerce-advanced-free-shipping' ),
117
+ 'state' => __( 'State', 'woocommerce-advanced-free-shipping' ),
118
+ 'country' => __( 'Country', 'woocommerce-advanced-free-shipping' ),
119
+ 'role' => __( 'User role', 'woocommerce-advanced-free-shipping' ),
120
+ ),
121
+ __( 'Product', 'woocommerce-advanced-free-shipping' ) => array(
122
+ 'width' => __( 'Width', 'woocommerce-advanced-free-shipping' ),
123
+ 'height' => __( 'Height', 'woocommerce-advanced-free-shipping' ),
124
+ 'length' => __( 'Length', 'woocommerce-advanced-free-shipping' ),
125
+ 'stock' => __( 'Stock', 'woocommerce-advanced-free-shipping' ),
126
+ 'stock_status' => __( 'Stock status', 'woocommerce-advanced-free-shipping' ),
127
+ 'category' => __( 'Category', 'woocommerce-advanced-free-shipping' ),
128
+ ),
129
+ );
130
+ $conditions = apply_filters( 'wafs_conditions', $conditions );
131
+
132
+ return $conditions;
133
+
134
+ }
135
+
136
+
137
+ /**
138
+ * Get available operators.
139
+ *
140
+ * Get a list with the available operators for the conditions.
141
+ *
142
+ * @since 1.1.6
143
+ *
144
+ * @return array List of available operators.
145
+ */
146
+ public function get_operators() {
147
+
148
+ $operators = array(
149
+ '==' => __( 'Equal to', 'woocommerce-advanced-free-shipping' ),
150
+ '!=' => __( 'Not equal to', 'woocommerce-advanced-free-shipping' ),
151
+ '>=' => __( 'Greater or equal to', 'woocommerce-advanced-free-shipping' ),
152
+ '<=' => __( 'Less or equal to ', 'woocommerce-advanced-free-shipping' ),
153
+ );
154
+ $operators = apply_filters( 'wafs_operators', $operators );
155
+
156
+ return $operators;
157
+
158
+ }
159
+
160
+
161
+ /**
162
+ * Get value field args.
163
+ *
164
+ * Get the value field args that are condition dependent. This usually includes
165
+ * type, class and placeholder.
166
+ *
167
+ * @since 1.1.6
168
+ *
169
+ * @return array
170
+ */
171
+ public function get_value_field_args() {
172
+
173
+ // Defaults
174
+ $values = array(
175
+ 'name' => 'conditions[' . absint( $this->group ) . '][' . absint( $this->id ) . '][value]',
176
+ 'placeholder' => '',
177
+ 'type' => 'text',
178
+ 'class' => array( 'wpc-value' )
179
+ );
180
+
181
+
182
+
183
+ switch ( $this->condition ) :
184
+
185
+ default:
186
+ case 'subtotal' :
187
+ case 'subtotal_ex_tax' :
188
+ case 'tax' :
189
+ case 'quantity' :
190
+ case 'coupon' :
191
+ case 'weight' :
192
+ $values['type'] = 'text';
193
+ break;
194
+
195
+ case 'contains_product' :
196
+
197
+ $product = wc_get_product( $this->value );
198
+ if ( $product ) {
199
+ $values['custom_attributes']['data-selected'] = $product->get_formatted_name();
200
+ }
201
+
202
+ $values['type'] = 'text';
203
+ $values['placeholder'] = __( 'Search for a product', 'woocommerce-advanced-messages' );
204
+ $values['class'][] = 'wc-product-search';
205
+
206
+ break;
207
+
208
+ case 'contains_shipping_class' :
209
+
210
+ $values['type'] = 'select';
211
+ $values['options'][''] = __( 'No shipping class', 'woocommerce' );
212
+
213
+ // Get all shipping classes
214
+ foreach ( get_terms( 'product_shipping_class', array( 'hide_empty' => false ) ) as $shipping_class ) :
215
+ $values['options'][ $shipping_class->slug ] = $shipping_class->name;
216
+ endforeach;
217
+
218
+ break;
219
+
220
+ /**
221
+ * User details
222
+ */
223
+
224
+ case 'zipcode' :
225
+ case 'city' :
226
+ $values['type'] = 'text';
227
+ break;
228
+
229
+ case 'state' :
230
+
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;
243
+
244
+ $values['options'] = $country_states;
245
+
246
+ endforeach;
247
+
248
+ break;
249
+
250
+ case 'country' :
251
+
252
+ $values['field'] = 'select';
253
+ $values['class'][] = 'wc-enhanced-select';
254
+
255
+ $countries = WC()->countries->get_allowed_countries() + WC()->countries->get_shipping_countries();
256
+ $continents = array();
257
+ if ( method_exists( WC()->countries, 'get_continents' ) ) :
258
+ foreach ( WC()->countries->get_continents() as $k => $v ) :
259
+ $continents[ 'CO_' . $k ] = $v['name']; // Add prefix for country key compatibility
260
+ endforeach;
261
+ endif;
262
+
263
+ if ( $continents ) {
264
+ $values['options'][ __( 'Continents', 'woocommerce' ) ] = $continents;
265
+ }
266
+ $values['options'][ __( 'Countries', 'woocommerce' ) ] = $countries;
267
+
268
+ break;
269
+
270
+ case 'role' :
271
+ $values['type'] = 'select';
272
+ $roles = array_keys( get_editable_roles() );
273
+ $values['options'] = array_combine( $roles, $roles );
274
+ break;
275
+
276
+ /**
277
+ * Product
278
+ */
279
+
280
+ case 'width' :
281
+ case 'height' :
282
+ case 'length' :
283
+ case 'stock' :
284
+ $values['type'] = 'text';
285
+ break;
286
+
287
+ case 'stock_status' :
288
+
289
+ $values['type'] = 'select';
290
+ $values['options'] = array(
291
+ 'instock' => __( 'In stock', 'woocommerce-advanced-free-shipping' ),
292
+ 'outofstock' => __( 'Out of stock', 'woocommerce-advanced-free-shipping' ),
293
+ );
294
+
295
+ break;
296
+
297
+ case 'category' :
298
+
299
+ $values['type'] = 'select';
300
+ $values['class'][] = 'wc-enhanced-select';
301
+
302
+ $categories = get_terms( 'product_cat', array( 'hide_empty' => false ) );
303
+ foreach ( $categories as $category ) :
304
+ $values['options'][ $category->slug ] = $category->name;
305
+ endforeach;
306
+
307
+ break;
308
+
309
+
310
+ endswitch;
311
+
312
+ $values = apply_filters( 'wafs_values', $values, $this->condition );
313
+
314
+
315
+ $values = apply_filters( 'woocommerce_advanced_free_shipping_values', $values, $this->condition );
316
+
317
+ return $values;
318
+
319
+ }
320
+
321
+
322
+ /**
323
+ * Get description.
324
+ *
325
+ * Return the description related to this condition.
326
+ *
327
+ * @since 1.0.0
328
+ */
329
+ public function get_description() {
330
+
331
+ $descriptions = array(
332
+ 'state' => __( 'States must be installed in WC.', 'woocommerce-advanced-free-shipping' ),
333
+ 'weight' => __( 'Weight calculated on all the cart contents', 'woocommerce-advanced-free-shipping' ),
334
+ 'length' => __( 'Compared to lengthiest product in cart', 'woocommerce-advanced-free-shipping' ),
335
+ 'width' => __( 'Compared to widest product in cart', 'woocommerce-advanced-free-shipping' ),
336
+ 'height' => __( 'Compared to highest product in cart', 'woocommerce-advanced-free-shipping' ),
337
+ 'stock_status' => __( 'All products in cart must match stock status', 'woocommerce-advanced-free-shipping' ),
338
+ 'category' => __( 'All products in cart must match category', 'woocommerce-advanced-free-shipping' ),
339
+ 'contains_product' => __( 'Cart must contain one of this product', 'woocommerce-advanced-free-shipping' ),
340
+ 'contains_shipping_class' => __( 'Cart must contain at least one product with the selected shipping class', 'woocommerce-advanced-free-shipping' ),
341
+ );
342
+
343
+ $descriptions = apply_filters( 'wafs_descriptions', $descriptions );
344
+
345
+ return isset( $descriptions[ $this->condition ] ) ? $descriptions[ $this->condition ] : '';
346
+
347
+ }
348
+
349
+
350
+ }
includes/admin/settings/conditions/class-wafs-condition.php DELETED
@@ -1,227 +0,0 @@
1
- <?php
2
- /**
3
- * Class WAFS_Condition.
4
- *
5
- * Create a condition rule.
6
- *
7
- * @class WAFS_Condition
8
- * @author Jeroen Sormani
9
- * @package WooCommerce Advanced Free Shipping
10
- * @version 1.0.0
11
- */
12
-
13
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
-
15
- class WAFS_Condition {
16
-
17
-
18
- /**
19
- * Condition.
20
- *
21
- * @since 1.0.0
22
- * @access public
23
- * @var string $condition Condition slug.
24
- */
25
- public $condition;
26
-
27
-
28
- /**
29
- * Operator.
30
- *
31
- * @since 1.0.0
32
- * @access public
33
- * @var string $operaor operator slug.
34
- */
35
- public $operator;
36
-
37
-
38
- /**
39
- * Value.
40
- *
41
- * @since 1.0.0
42
- * @access public
43
- * @var string $value Condition value.
44
- */
45
- public $value;
46
-
47
-
48
- /**
49
- * Group ID.
50
- *
51
- * @since 1.0.0
52
- * @access public
53
- * @var string $group Condition grou ID.
54
- */
55
- public $group;
56
-
57
-
58
- /**
59
- * Condition id.
60
- *
61
- * @since 1.0.0
62
- * @access public
63
- * @var string $id Condition ID.
64
- */
65
- public $id;
66
-
67
-
68
- /**
69
- * Constructor.
70
- *
71
- * @since 1.0.0
72
- */
73
- public function __construct( $id = null, $group = 0, $condition = null, $operator = null, $value = null ) {
74
-
75
- $this->id = $id;
76
- $this->group = $group;
77
- $this->condition = $condition;
78
- $this->operator = $operator;
79
- $this->value = $value;
80
-
81
- if ( ! $id ) {
82
- $this->id = rand();
83
- }
84
-
85
- $this->wafs_create_object();
86
-
87
- }
88
-
89
-
90
- /**
91
- * Condition rule.
92
- *
93
- * Create an condition rule object.
94
- *
95
- * @since 1.0.0
96
- */
97
- public function wafs_create_object() {
98
-
99
- ?><div class='wafs-condition-wrap'><?php
100
-
101
- do_action( 'wafs_before_condition', $this );
102
-
103
- $this->wafs_condition_conditions();
104
- $this->wafs_condition_operator();
105
- $this->wafs_condition_values();
106
-
107
- $this->wafs_add_condition_button();
108
- $this->wafs_remove_condition_button();
109
-
110
- $this->wafs_condition_description();
111
-
112
- do_action( 'wafs_after_condition', $this );
113
-
114
- ?></div><?php
115
-
116
- }
117
-
118
-
119
- /**
120
- * Condition dropdown.
121
- *
122
- * Render and load condition dropdown.
123
- *
124
- * @since 1.0.0
125
- */
126
- public function wafs_condition_conditions() {
127
-
128
- wafs_condition_conditions( $this->id, $this->group, $this->condition );
129
-
130
- }
131
-
132
-
133
- /**
134
- * Operator dropdown.
135
- *
136
- * Render and load operator dropdown.
137
- *
138
- * @since 1.0.0
139
- */
140
- public function wafs_condition_operator() {
141
-
142
- wafs_condition_operator( $this->id, $this->group, $this->operator );
143
-
144
- }
145
-
146
-
147
- /**
148
- * Value dropdown.
149
- *
150
- * Render and load value dropdown.
151
- *
152
- * @since 1.0.0
153
- */
154
- public function wafs_condition_values() {
155
-
156
- wafs_condition_values( $this->id, $this->group, $this->condition, $this->value );
157
-
158
- }
159
-
160
-
161
- /**
162
- * Add button.
163
- *
164
- * Display a add button at the end of the condition rule.
165
- *
166
- * @since 1.0.0
167
- */
168
- public function wafs_add_condition_button() {
169
-
170
- ?>
171
- <a class='button condition-add' data-group='<?php echo absint( $this->group ); ?>' href='javascript:void(0);'>+</a>
172
- <?php
173
-
174
- }
175
-
176
-
177
- /**
178
- * Remove button.
179
- *
180
- * Display aa remove button at the end of the condition rule.
181
- *
182
- * @since 1.0.0
183
- */
184
- public function wafs_remove_condition_button() {
185
-
186
- ?>
187
- <a class='button condition-delete' href='javascript:void(0);'>-</a>
188
- <?php
189
-
190
- }
191
-
192
-
193
- /**
194
- * Description.
195
- *
196
- * Display an description at the end of the condition rule.
197
- *
198
- * @since 1.0.0
199
- */
200
- public function wafs_condition_description() {
201
-
202
- wafs_condition_description( $this->condition );
203
-
204
- }
205
-
206
-
207
- }
208
-
209
- /**
210
- * Load condition keys dropdown.
211
- */
212
- require_once plugin_dir_path( __FILE__ ) . 'condition-conditions.php';
213
-
214
- /**
215
- * Load condition operator dropdown.
216
- */
217
- require_once plugin_dir_path( __FILE__ ) . 'condition-operators.php';
218
-
219
- /**
220
- * Load condition value dropdown.
221
- */
222
- require_once plugin_dir_path( __FILE__ ) . 'condition-values.php';
223
-
224
- /**
225
- * Load condition descriptions.
226
- */
227
- require_once plugin_dir_path( __FILE__ ) . 'condition-descriptions.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin/settings/conditions/condition-conditions.php DELETED
@@ -1,68 +0,0 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
-
4
- /**
5
- * Create condition dropdown.
6
- *
7
- * Set all conditions and create dropdown for it.
8
- *
9
- * @since 1.0.0
10
- *
11
- * @param mixed $id Throw in the condition ID.
12
- * @param midex $group Condition group ID.
13
- * @param string $current_value Current chosen slug.
14
- */
15
- function wafs_condition_conditions( $id, $group = 0, $current_value = 'subtotal' ) {
16
-
17
- $conditions = array(
18
- __( 'Cart', 'woocommerce-advanced-free-shipping' ) => array(
19
- 'subtotal' => __( 'Subtotal', 'woocommerce-advanced-free-shipping' ),
20
- 'subtotal_ex_tax' => __( 'Subtotal ex. taxes', 'woocommerce-advanced-free-shipping' ),
21
- 'tax' => __( 'Tax', 'woocommerce-advanced-free-shipping' ),
22
- 'quantity' => __( 'Quantity', 'woocommerce-advanced-free-shipping' ),
23
- 'contains_product' => __( 'Contains product', 'woocommerce-advanced-free-shipping' ),
24
- 'coupon' => __( 'Coupon', 'woocommerce-advanced-free-shipping' ),
25
- 'weight' => __( 'Weight', 'woocommerce-advanced-free-shipping' ),
26
- 'contains_shipping_class' => __( 'Contains shipping class', 'woocommerce-advanced-free-shipping' ),
27
- ),
28
- __( 'User Details', 'woocommerce-advanced-free-shipping' ) => array(
29
- 'zipcode' => __( 'Zipcode', 'woocommerce-advanced-free-shipping' ),
30
- 'city' => __( 'City', 'woocommerce-advanced-free-shipping' ),
31
- 'state' => __( 'State', 'woocommerce-advanced-free-shipping' ),
32
- 'country' => __( 'Country', 'woocommerce-advanced-free-shipping' ),
33
- 'role' => __( 'User role', 'woocommerce-advanced-free-shipping' ),
34
- ),
35
- __( 'Product', 'woocommerce-advanced-free-shipping' ) => array(
36
- 'width' => __( 'Width', 'woocommerce-advanced-free-shipping' ),
37
- 'height' => __( 'Height', 'woocommerce-advanced-free-shipping' ),
38
- 'length' => __( 'Length', 'woocommerce-advanced-free-shipping' ),
39
- 'stock' => __( 'Stock', 'woocommerce-advanced-free-shipping' ),
40
- 'stock_status' => __( 'Stock status', 'woocommerce-advanced-free-shipping' ),
41
- 'category' => __( 'Category', 'woocommerce-advanced-free-shipping' ),
42
- ),
43
- );
44
-
45
- $conditions = apply_filters( 'wafs_conditions', $conditions );
46
-
47
- ?><span class='wafs-condition-wrap wafs-condition-wrap-<?php echo absint( $id ); ?>'>
48
-
49
- <select class='wafs-condition' data-group='<?php echo absint( $group ); ?>' data-id='<?php echo absint( $id ); ?>'
50
- name='_wafs_shipping_method_conditions[<?php echo absint( $group ); ?>][<?php echo absint( $id ); ?>][condition]'><?php
51
-
52
- foreach ( $conditions as $option_group => $values ) :
53
-
54
- ?><optgroup label='<?php echo esc_attr( $option_group ); ?>'><?php
55
-
56
- foreach ( $values as $key => $value ) :
57
- ?><option value='<?php echo esc_attr( $key ); ?>' <?php selected( $key, $current_value ); ?>><?php echo esc_html( $value ); ?></option><?php
58
- endforeach;
59
-
60
- ?></optgroup><?php
61
-
62
- endforeach;
63
-
64
- ?></select>
65
-
66
- </span><?php
67
-
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin/settings/conditions/condition-descriptions.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
-
4
- /**
5
- * Descriptions.
6
- *
7
- * Display a description icon + tooltip on hover.
8
- *
9
- * @since 1.0.0
10
- *
11
- * @param string $condition Condition to show description for.
12
- */
13
- function wafs_condition_description( $condition ) {
14
-
15
- $descriptions = array(
16
- 'state' => __( 'States must be installed in WC.', 'woocommerce-advanced-free-shipping' ),
17
- 'weight' => __( 'Weight calculated on all the cart contents', 'woocommerce-advanced-free-shipping' ),
18
- 'length' => __( 'Compared to lengthiest product in cart', 'woocommerce-advanced-free-shipping' ),
19
- 'width' => __( 'Compared to widest product in cart', 'woocommerce-advanced-free-shipping' ),
20
- 'height' => __( 'Compared to highest product in cart', 'woocommerce-advanced-free-shipping' ),
21
- 'stock_status' => __( 'All products in cart must match stock status', 'woocommerce-advanced-free-shipping' ),
22
- 'category' => __( 'All products in cart must match category', 'woocommerce-advanced-free-shipping' ),
23
- 'contains_product' => __( 'Cart must contain one of this product', 'woocommerce-advanced-free-shipping' ),
24
- 'contains_shipping_class' => __( 'Cart must contain at least one product with the selected shipping class', 'woocommerce-advanced-free-shipping' ),
25
- );
26
-
27
- $descriptions = apply_filters( 'wafs_descriptions', $descriptions );
28
-
29
- // Display description
30
- if ( ! isset( $descriptions[ $condition ] ) ) :
31
- ?><span class='wafs-description no-description'></span><?php
32
- return;
33
- endif;
34
-
35
- ?><span class='wafs-description <?php echo sanitize_html_class( $condition ); ?>-description'>
36
-
37
- <div class='description'>
38
-
39
- <img class='wafs_tip' src='<?php echo WC()->plugin_url(); ?>/assets/images/help.png' height='24' width='24' />
40
-
41
- <div class='wafs_desc'><?php
42
- echo esc_html( $descriptions[ $condition ] );
43
- ?></div>
44
-
45
- </div>
46
-
47
- </span><?php
48
-
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin/settings/conditions/condition-operators.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
-
4
- /**
5
- * Create operator dropdown.
6
- *
7
- * Set all operators and create dropdown for it.
8
- *
9
- * @since 1.0.0
10
- *
11
- * @param int $id Throw in the condition ID.
12
- * @param int $group Condition group ID.
13
- * @param string $current_value Current chosen slug.
14
- */
15
- function wafs_condition_operator( $id, $group = 0, $current_value = '==' ) {
16
-
17
- $operators = array(
18
- '==' => __( 'Equal to', 'woocommerce-advanced-free-shipping' ),
19
- '!=' => __( 'Not equal to', 'woocommerce-advanced-free-shipping' ),
20
- '>=' => __( 'Greater or equal to', 'woocommerce-advanced-free-shipping' ),
21
- '<=' => __( 'Less or equal to ', 'woocommerce-advanced-free-shipping' ),
22
- );
23
-
24
- $operators = apply_filters( 'wafs_operators', $operators );
25
-
26
- ?><span class='wafs-operator-wrap wafs-operator-wrap-<?php echo absint( $id ); ?>'>
27
-
28
- <select id='' class='wafs-operator' name='_wafs_shipping_method_conditions[<?php echo absint( $group ); ?>][<?php echo absint( $id ); ?>][operator]'>
29
-
30
- <?php foreach ( $operators as $key => $value ) :
31
-
32
- ?><option value='<?php echo esc_attr( $key ); ?>' <?php selected( $key, $current_value ); ?>><?php echo esc_html( $value ); ?></option><?php
33
-
34
- endforeach; ?>
35
-
36
- </select>
37
-
38
- </span><?php
39
-
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin/settings/conditions/condition-values.php DELETED
@@ -1,250 +0,0 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
-
4
- /**
5
- * Create value input.
6
- *
7
- * Set all value and create an input field for it.
8
- *
9
- * @since 1.0.0
10
- *
11
- * @param int $id Throw in the condition ID.
12
- * @param int $group Condition group ID.
13
- * @param string $condition Condition where the value input is used for.
14
- * @param string $current_value Current chosen slug.
15
- */
16
- function wafs_condition_values( $id, $group = 0, $condition = 'subtotal', $current_value = '' ) {
17
-
18
- // Defaults
19
- $values = array( 'placeholder' => '', 'min' => '', 'max' => '', 'field' => 'text', 'options' => array() );
20
-
21
- switch ( $condition ) :
22
-
23
- default:
24
- case 'subtotal' :
25
-
26
- $values['field'] = 'number';
27
-
28
- break;
29
-
30
- case 'subtotal_ex_tax' :
31
-
32
- $values['field'] = 'number';
33
-
34
- break;
35
-
36
- case 'tax' :
37
-
38
- $values['field'] = 'number';
39
-
40
- break;
41
-
42
- case 'quantity' :
43
-
44
- $values['field'] = 'number';
45
-
46
- break;
47
-
48
- case 'contains_product' :
49
-
50
- $values['field'] = 'select';
51
-
52
- $products = get_posts( array( 'posts_per_page' => '-1', 'post_type' => 'product', 'order' => 'asc', 'orderby' => 'title' ) );
53
- foreach ( $products as $product ) :
54
- $values['options'][ $product->ID ] = $product->post_title;
55
- endforeach;
56
-
57
- break;
58
-
59
- case 'coupon' :
60
-
61
- $values['field'] = 'text';
62
-
63
- break;
64
-
65
- case 'weight' :
66
-