Version Description
- WooCommerce tested up to version updated.
Download this release
Release Info
Developer | ThemeHigh |
Plugin | WooCommerce Checkout Field Editor (Manager) Pro |
Version | 1.2.5 |
Comparing to | |
See all releases |
Code changes from version 1.0.9 to 1.2.5
assets/css/thwcfd-style.css
CHANGED
@@ -143,4 +143,8 @@ h1.nav-tab-wrapper, h2.nav-tab-wrapper, h3.nav-tab-wrapper {
|
|
143 |
border-bottom: 1px solid #CCC;
|
144 |
padding-bottom: 0px;
|
145 |
padding-left: 10px;
|
146 |
-
}
|
|
|
|
|
|
|
|
143 |
border-bottom: 1px solid #CCC;
|
144 |
padding-bottom: 0px;
|
145 |
padding-left: 10px;
|
146 |
+
}
|
147 |
+
|
148 |
+
/*.select2-drop {
|
149 |
+
z-index: 999999!important;
|
150 |
+
}*/
|
assets/js/thwcfd-admin.js
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
var wcfd_settings = (function($, window, document) {
|
|
|
|
|
2 |
$( "#wcfd_new_field_form_pp" ).dialog({
|
3 |
modal: true,
|
4 |
width: 500,
|
@@ -79,6 +81,7 @@ var wcfd_settings = (function($, window, document) {
|
|
79 |
wcfd_clear_form(form);
|
80 |
form.find("input[name=fname]").val(tabName);
|
81 |
form.find("select[name=ftype]").change();
|
|
|
82 |
|
83 |
$( "#wcfd_new_field_form_pp" ).dialog( "open" );
|
84 |
}
|
@@ -105,6 +108,8 @@ var wcfd_settings = (function($, window, document) {
|
|
105 |
var err_msgs = '';
|
106 |
if(name == ''){
|
107 |
err_msgs = 'Name is required';
|
|
|
|
|
108 |
}else if(type == ''){
|
109 |
err_msgs = 'Type is required';
|
110 |
}
|
@@ -214,6 +219,7 @@ var wcfd_settings = (function($, window, document) {
|
|
214 |
showinorder = is_custom == true ? showinorder : true;
|
215 |
|
216 |
var form = $("#wcfd_edit_field_form_pp");
|
|
|
217 |
form.find("input[name=rowId]").val(rowId);
|
218 |
form.find("input[name=fname]").val(name);
|
219 |
form.find("input[name=fnameNew]").val(name);
|
@@ -278,6 +284,8 @@ var wcfd_settings = (function($, window, document) {
|
|
278 |
var err_msgs = '';
|
279 |
if(name == ''){
|
280 |
err_msgs = 'Name is required';
|
|
|
|
|
281 |
}else if(type == ''){
|
282 |
err_msgs = 'Type is required';
|
283 |
}
|
@@ -357,6 +365,7 @@ var wcfd_settings = (function($, window, document) {
|
|
357 |
}
|
358 |
|
359 |
function wcfd_clear_form( form ){
|
|
|
360 |
form.find("input[name=fname]").val('');
|
361 |
form.find("input[name=fnameNew]").val('');
|
362 |
form.find("select[name=ftype]").prop('selectedIndex',0);
|
@@ -387,7 +396,7 @@ var wcfd_settings = (function($, window, document) {
|
|
387 |
|
388 |
showAllFields(form);
|
389 |
if(type === 'select'){
|
390 |
-
form.find('.rowPlaceholder').hide();
|
391 |
form.find('.rowValidate').hide();
|
392 |
}else{
|
393 |
form.find('.rowOptions').hide();
|
@@ -405,6 +414,11 @@ var wcfd_settings = (function($, window, document) {
|
|
405 |
$('#wcfd_checkout_fields tbody input:checkbox[name=select_field]').prop('checked', checkAll);
|
406 |
}
|
407 |
|
|
|
|
|
|
|
|
|
|
|
408 |
return {
|
409 |
openNewFieldForm : _openNewFieldForm,
|
410 |
openEditFieldForm : _openEditFieldForm,
|
1 |
var wcfd_settings = (function($, window, document) {
|
2 |
+
var MSG_INVALID_NAME = 'NAME/ID must begin with a lowercase letter ([a-z]) and may be followed by any number of lowercase letters, digits ([0-9]) and underscores ("_")';
|
3 |
+
|
4 |
$( "#wcfd_new_field_form_pp" ).dialog({
|
5 |
modal: true,
|
6 |
width: 500,
|
81 |
wcfd_clear_form(form);
|
82 |
form.find("input[name=fname]").val(tabName);
|
83 |
form.find("select[name=ftype]").change();
|
84 |
+
form.find("input[name=fclass]").val('form-row-wide');
|
85 |
|
86 |
$( "#wcfd_new_field_form_pp" ).dialog( "open" );
|
87 |
}
|
108 |
var err_msgs = '';
|
109 |
if(name == ''){
|
110 |
err_msgs = 'Name is required';
|
111 |
+
}else if(!isHtmlIdValid(name)){
|
112 |
+
err_msgs = MSG_INVALID_NAME;
|
113 |
}else if(type == ''){
|
114 |
err_msgs = 'Type is required';
|
115 |
}
|
219 |
showinorder = is_custom == true ? showinorder : true;
|
220 |
|
221 |
var form = $("#wcfd_edit_field_form_pp");
|
222 |
+
form.find('.err_msgs').html('');
|
223 |
form.find("input[name=rowId]").val(rowId);
|
224 |
form.find("input[name=fname]").val(name);
|
225 |
form.find("input[name=fnameNew]").val(name);
|
284 |
var err_msgs = '';
|
285 |
if(name == ''){
|
286 |
err_msgs = 'Name is required';
|
287 |
+
}else if(!isHtmlIdValid(name)){
|
288 |
+
err_msgs = MSG_INVALID_NAME;
|
289 |
}else if(type == ''){
|
290 |
err_msgs = 'Type is required';
|
291 |
}
|
365 |
}
|
366 |
|
367 |
function wcfd_clear_form( form ){
|
368 |
+
form.find('.err_msgs').html('');
|
369 |
form.find("input[name=fname]").val('');
|
370 |
form.find("input[name=fnameNew]").val('');
|
371 |
form.find("select[name=ftype]").prop('selectedIndex',0);
|
396 |
|
397 |
showAllFields(form);
|
398 |
if(type === 'select'){
|
399 |
+
//form.find('.rowPlaceholder').hide();
|
400 |
form.find('.rowValidate').hide();
|
401 |
}else{
|
402 |
form.find('.rowOptions').hide();
|
414 |
$('#wcfd_checkout_fields tbody input:checkbox[name=select_field]').prop('checked', checkAll);
|
415 |
}
|
416 |
|
417 |
+
function isHtmlIdValid(id) {
|
418 |
+
var re = /^[a-z\_]+[a-z0-9\_]*$/;
|
419 |
+
return re.test(id.trim());
|
420 |
+
}
|
421 |
+
|
422 |
return {
|
423 |
openNewFieldForm : _openNewFieldForm,
|
424 |
openEditFieldForm : _openEditFieldForm,
|
assets/js/thwcfd-checkout-field-editor-frontend.js
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function($) {
|
2 |
+
$('select.thwcfd-enhanced-select').select2({
|
3 |
+
minimumResultsForSearch: 10,
|
4 |
+
allowClear : true,
|
5 |
+
placeholder: $(this).data('placeholder')
|
6 |
+
}).addClass('enhanced');
|
7 |
+
});
|
checkout-form-designer.php
CHANGED
@@ -3,16 +3,28 @@
|
|
3 |
* Plugin Name: Woo Checkout Field Editor Pro
|
4 |
* Description: Customize WooCommerce checkout fields(Add, Edit, Delete and re-arrange fields).
|
5 |
* Author: ThemeHiGH
|
6 |
-
* Version: 1.
|
7 |
-
* Author URI:
|
8 |
-
* Plugin URI:
|
9 |
* Text Domain: thwcfd
|
10 |
* Domain Path: /languages
|
|
|
|
|
11 |
*/
|
12 |
|
13 |
if(!defined( 'ABSPATH' )) exit;
|
14 |
|
15 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
load_plugin_textdomain( 'thwcfd', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
17 |
|
18 |
/**
|
@@ -21,6 +33,11 @@ if(in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get
|
|
21 |
function thwcfd_init_checkout_field_editor_lite() {
|
22 |
global $supress_field_modification;
|
23 |
$supress_field_modification = false;
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
if(!class_exists('WC_Checkout_Field_Editor')){
|
26 |
require_once('classes/class-wc-checkout-field-editor.php');
|
@@ -35,6 +52,40 @@ if(in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get
|
|
35 |
}
|
36 |
add_action('init', 'thwcfd_init_checkout_field_editor_lite');
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
/**
|
39 |
* Hide Additional Fields title if no fields available.
|
40 |
*
|
@@ -61,43 +112,109 @@ if(in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get
|
|
61 |
}
|
62 |
add_filter('woocommerce_enable_order_notes_field', 'thwcfd_enable_order_notes_field', 1000);
|
63 |
|
64 |
-
|
65 |
-
$
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
/**
|
71 |
* wc_checkout_fields_modify_billing_fields function.
|
72 |
*
|
73 |
-
* @param mixed $
|
74 |
*/
|
75 |
-
function thwcfd_billing_fields_lite($
|
76 |
global $supress_field_modification;
|
77 |
|
78 |
if($supress_field_modification){
|
79 |
-
return $
|
|
|
|
|
|
|
|
|
|
|
80 |
}
|
81 |
-
|
82 |
-
return thwcfd_prepare_checkout_fields_lite(get_option('wc_fields_billing'), $old);
|
83 |
}
|
84 |
-
add_filter('woocommerce_billing_fields', 'thwcfd_billing_fields_lite', 1000);
|
85 |
|
86 |
/**
|
87 |
* wc_checkout_fields_modify_shipping_fields function.
|
88 |
*
|
89 |
* @param mixed $old
|
90 |
*/
|
91 |
-
function thwcfd_shipping_fields_lite($
|
92 |
global $supress_field_modification;
|
93 |
|
94 |
if ($supress_field_modification){
|
95 |
-
return $
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
-
|
98 |
-
return thwcfd_prepare_checkout_fields_lite(get_option('wc_fields_shipping'), $old);
|
99 |
}
|
100 |
-
add_filter('woocommerce_shipping_fields', 'thwcfd_shipping_fields_lite', 1000);
|
101 |
|
102 |
/**
|
103 |
* wc_checkout_fields_modify_shipping_fields function.
|
@@ -112,131 +229,111 @@ if(in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get
|
|
112 |
}
|
113 |
|
114 |
if($additional_fields = get_option('wc_fields_additional')){
|
115 |
-
$fields['order']
|
|
|
|
|
116 |
|
117 |
// check if order_comments is enabled/disabled
|
118 |
if(isset($additional_fields) && !$additional_fields['order_comments']['enabled']){
|
119 |
unset($fields['order']['order_comments']);
|
120 |
}
|
121 |
}
|
122 |
-
|
123 |
-
if(isset($fields['account']) && is_array($fields['account'])){
|
124 |
-
foreach( $fields['account'] as $name => $values ) {
|
125 |
-
$fields['account'][ $name ]['label'] = __($fields['account'][ $name ]['label'], 'woocommerce');
|
126 |
-
$fields['account'][ $name ]['placeholder'] = __($fields['account'][ $name ]['placeholder'], 'woocommerce');
|
127 |
-
}
|
128 |
-
}
|
129 |
-
|
130 |
if(isset($fields['order']) && is_array($fields['order'])){
|
131 |
-
|
132 |
-
if (isset($values['enabled']) && $values['enabled'] == false ) {
|
133 |
-
unset( $fields['order'][ $name ] );
|
134 |
-
}else{
|
135 |
-
$fields['order'][ $name ]['label'] = __($fields['order'][ $name ]['label'], 'woocommerce');
|
136 |
-
$fields['order'][ $name ]['placeholder'] = __($fields['order'][ $name ]['placeholder'], 'woocommerce');
|
137 |
-
}
|
138 |
-
}
|
139 |
}
|
140 |
|
141 |
return $fields;
|
142 |
}
|
143 |
add_filter('woocommerce_checkout_fields', 'thwcfd_checkout_fields_lite', 1000);
|
144 |
-
|
145 |
/**
|
146 |
-
* checkout_fields_modify_fields function.
|
147 |
*
|
148 |
-
* @param mixed $data
|
149 |
-
* @param mixed $old
|
150 |
*/
|
151 |
-
function
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
foreach( $fields as $name => $values ) {
|
160 |
-
// enabled
|
161 |
-
if ( $values['enabled'] == false ) {
|
162 |
-
unset( $fields[ $name ] );
|
163 |
-
}
|
164 |
-
|
165 |
-
// Replace locale field properties so they are unchanged
|
166 |
-
if ( in_array( $name, array(
|
167 |
-
'billing_country', 'billing_state', 'billing_city', 'billing_postcode',
|
168 |
-
'shipping_country', 'shipping_state', 'shipping_city', 'shipping_postcode',
|
169 |
-
'order_comments'
|
170 |
-
) ) ) {
|
171 |
-
if ( isset( $fields[ $name ] ) ) {
|
172 |
-
$fields[ $name ] = $old_fields[ $name ];
|
173 |
-
$fields[ $name ]['label'] = ! empty( $data[ $name ]['label'] ) ? $data[ $name ]['label'] : $old_fields[ $name ]['label'];
|
174 |
-
|
175 |
-
if ( ! empty( $data[ $name ]['placeholder'] ) ) {
|
176 |
-
$fields[ $name ]['placeholder'] = $data[ $name ]['placeholder'];
|
177 |
-
|
178 |
-
} elseif ( ! empty( $old_fields[ $name ]['placeholder'] ) ) {
|
179 |
-
$fields[ $name ]['placeholder'] = $old_fields[ $name ]['placeholder'];
|
180 |
-
|
181 |
-
} else {
|
182 |
-
$fields[ $name ]['placeholder'] = '';
|
183 |
}
|
184 |
-
|
185 |
-
$fields[ $name ]['class'] = $data[ $name ]['class'];
|
186 |
-
$fields[ $name ]['clear'] = $data[ $name ]['clear'];
|
187 |
}
|
188 |
}
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
}
|
195 |
-
return $fields;
|
196 |
}
|
197 |
}
|
198 |
|
199 |
/**
|
200 |
-
*
|
201 |
*
|
202 |
-
* @param mixed $
|
|
|
203 |
*/
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
|
|
233 |
}
|
234 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
}
|
236 |
-
}
|
|
|
|
|
|
|
237 |
}
|
238 |
}
|
239 |
-
|
|
|
|
|
|
|
240 |
|
241 |
/**
|
242 |
* Display custom fields in emails
|
@@ -244,29 +341,49 @@ if(in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get
|
|
244 |
* @param array $keys
|
245 |
* @return array
|
246 |
*/
|
247 |
-
function thwcfd_display_custom_fields_in_emails_lite($
|
248 |
-
$
|
249 |
$fields = array_merge(WC_Checkout_Field_Editor::get_fields('billing'), WC_Checkout_Field_Editor::get_fields('shipping'),
|
250 |
WC_Checkout_Field_Editor::get_fields('additional'));
|
251 |
|
252 |
// Loop through all custom fields to see if it should be added
|
253 |
-
foreach( $fields as $
|
254 |
if(isset($options['show_in_email']) && $options['show_in_email']){
|
255 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
}
|
257 |
}
|
258 |
|
259 |
-
return array_merge(
|
260 |
}
|
261 |
-
add_filter('
|
262 |
-
|
263 |
/**
|
264 |
* Display custom checkout fields on view order pages
|
265 |
*
|
266 |
* @param object $order
|
267 |
*/
|
268 |
function thwcfd_order_details_after_customer_details_lite($order){
|
269 |
-
|
|
|
|
|
|
|
|
|
270 |
|
271 |
$fields = array();
|
272 |
if(!wc_ship_to_billing_address_only() && $order->needs_shipping_address()){
|
@@ -275,25 +392,64 @@ if(in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get
|
|
275 |
}else{
|
276 |
$fields = array_merge(WC_Checkout_Field_Editor::get_fields('billing'), WC_Checkout_Field_Editor::get_fields('additional'));
|
277 |
}
|
278 |
-
|
279 |
-
$found = false;
|
280 |
-
$html = '';
|
281 |
-
|
282 |
-
// Loop through all custom fields to see if it should be added
|
283 |
-
foreach($fields as $name => $options){
|
284 |
-
$enabled = (isset($options['enabled']) && $options['enabled'] == false) ? false : true;
|
285 |
-
$is_custom_field = (isset($options['custom']) && $options['custom'] == true) ? true : false;
|
286 |
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
}
|
292 |
-
}
|
293 |
-
if($found){
|
294 |
-
echo '<dl>'. $html .'</dl>';
|
295 |
}
|
296 |
}
|
297 |
-
add_action('
|
298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
}
|
3 |
* Plugin Name: Woo Checkout Field Editor Pro
|
4 |
* Description: Customize WooCommerce checkout fields(Add, Edit, Delete and re-arrange fields).
|
5 |
* Author: ThemeHiGH
|
6 |
+
* Version: 1.2.5
|
7 |
+
* Author URI: https://www.themehigh.com
|
8 |
+
* Plugin URI: https://www.themehigh.com
|
9 |
* Text Domain: thwcfd
|
10 |
* Domain Path: /languages
|
11 |
+
* WC requires at least: 3.0.0
|
12 |
+
* WC tested up to: 3.3.0
|
13 |
*/
|
14 |
|
15 |
if(!defined( 'ABSPATH' )) exit;
|
16 |
|
17 |
+
if (!function_exists('is_woocommerce_active')){
|
18 |
+
function is_woocommerce_active(){
|
19 |
+
$active_plugins = (array) get_option('active_plugins', array());
|
20 |
+
if(is_multisite()){
|
21 |
+
$active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
|
22 |
+
}
|
23 |
+
return in_array('woocommerce/woocommerce.php', $active_plugins) || array_key_exists('woocommerce/woocommerce.php', $active_plugins);
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
if(is_woocommerce_active()) {
|
28 |
load_plugin_textdomain( 'thwcfd', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
29 |
|
30 |
/**
|
33 |
function thwcfd_init_checkout_field_editor_lite() {
|
34 |
global $supress_field_modification;
|
35 |
$supress_field_modification = false;
|
36 |
+
|
37 |
+
define('TH_WCFD_VERSION', '1.2.5');
|
38 |
+
!defined('TH_WCFD_BASE_NAME') && define('TH_WCFD_BASE_NAME', plugin_basename( __FILE__ ));
|
39 |
+
!defined('TH_WCFD_URL') && define('TH_WCFD_URL', plugins_url( '/', __FILE__ ));
|
40 |
+
!defined('TH_WCFD_ASSETS_URL') && define('TH_WCFD_ASSETS_URL', TH_WCFD_URL . 'assets/');
|
41 |
|
42 |
if(!class_exists('WC_Checkout_Field_Editor')){
|
43 |
require_once('classes/class-wc-checkout-field-editor.php');
|
52 |
}
|
53 |
add_action('init', 'thwcfd_init_checkout_field_editor_lite');
|
54 |
|
55 |
+
function thwcfd_is_locale_field( $field_name ){
|
56 |
+
if(!empty($field_name) && in_array($field_name, array(
|
57 |
+
'billing_address_1', 'billing_address_2', 'billing_state', 'billing_postcode', 'billing_city',
|
58 |
+
'shipping_address_1', 'shipping_address_2', 'shipping_state', 'shipping_postcode', 'shipping_city',
|
59 |
+
))){
|
60 |
+
return true;
|
61 |
+
}
|
62 |
+
return false;
|
63 |
+
}
|
64 |
+
|
65 |
+
function thwcfd_woocommerce_version_check( $version = '3.0' ) {
|
66 |
+
if(function_exists( 'is_woocommerce_active' ) && is_woocommerce_active() ) {
|
67 |
+
global $woocommerce;
|
68 |
+
if( version_compare( $woocommerce->version, $version, ">=" ) ) {
|
69 |
+
return true;
|
70 |
+
}
|
71 |
+
}
|
72 |
+
return false;
|
73 |
+
}
|
74 |
+
|
75 |
+
function thwcfd_enqueue_scripts(){
|
76 |
+
global $wp_scripts;
|
77 |
+
|
78 |
+
if(is_checkout()){
|
79 |
+
$in_footer = apply_filters( 'thwcfd_enqueue_script_in_footer', true );
|
80 |
+
|
81 |
+
wp_register_script('thwcfd-field-editor-script', TH_WCFD_ASSETS_URL.'js/thwcfd-checkout-field-editor-frontend.js',
|
82 |
+
array('jquery', 'select2'), TH_WCFD_VERSION, $in_footer);
|
83 |
+
|
84 |
+
wp_enqueue_script('thwcfd-field-editor-script');
|
85 |
+
}
|
86 |
+
}
|
87 |
+
add_action('wp_enqueue_scripts', 'thwcfd_enqueue_scripts');
|
88 |
+
|
89 |
/**
|
90 |
* Hide Additional Fields title if no fields available.
|
91 |
*
|
112 |
}
|
113 |
add_filter('woocommerce_enable_order_notes_field', 'thwcfd_enable_order_notes_field', 1000);
|
114 |
|
115 |
+
function thwcfd_woo_default_address_fields( $fields ) {
|
116 |
+
$sname = apply_filters('thwcfd_address_field_override_with', 'billing');
|
117 |
+
|
118 |
+
if($sname === 'billing' || $sname === 'shipping'){
|
119 |
+
$address_fields = get_option('wc_fields_'.$sname);
|
120 |
|
121 |
+
if(is_array($address_fields) && !empty($address_fields) && !empty($fields)){
|
122 |
+
$override_required = apply_filters( 'thwcfd_address_field_override_required', true );
|
123 |
+
|
124 |
+
foreach($fields as $name => $field) {
|
125 |
+
$fname = $sname.'_'.$name;
|
126 |
+
|
127 |
+
if(thwcfd_is_locale_field($fname) && $override_required){
|
128 |
+
$custom_field = isset($address_fields[$fname]) ? $address_fields[$fname] : false;
|
129 |
+
|
130 |
+
if($custom_field && !( isset($custom_field['enabled']) && $custom_field['enabled'] == false )){
|
131 |
+
$fields[$name]['required'] = isset($custom_field['required']) && $custom_field['required'] ? true : false;
|
132 |
+
}
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
return $fields;
|
139 |
+
}
|
140 |
+
add_filter('woocommerce_default_address_fields' , 'thwcfd_woo_default_address_fields' );
|
141 |
+
|
142 |
+
function thwcfd_prepare_country_locale($fields) {
|
143 |
+
if(is_array($fields)){
|
144 |
+
foreach($fields as $key => $props){
|
145 |
+
$override_ph = apply_filters('thwcfd_address_field_override_placeholder', true);
|
146 |
+
$override_label = apply_filters('thwcfd_address_field_override_label', true);
|
147 |
+
$override_required = apply_filters('thwcfd_address_field_override_required', false);
|
148 |
+
$override_priority = apply_filters('thwcfd_address_field_override_priority', true);
|
149 |
+
|
150 |
+
if($override_ph && isset($props['placeholder'])){
|
151 |
+
unset($fields[$key]['placeholder']);
|
152 |
+
}
|
153 |
+
if($override_label && isset($props['label'])){
|
154 |
+
unset($fields[$key]['label']);
|
155 |
+
}
|
156 |
+
if($override_required && isset($props['required'])){
|
157 |
+
unset($fields[$key]['required']);
|
158 |
+
}
|
159 |
+
|
160 |
+
if($override_priority && isset($props['priority'])){
|
161 |
+
unset($fields[$key]['priority']);
|
162 |
+
//unset($fields[$key]['order']);
|
163 |
+
}
|
164 |
+
}
|
165 |
+
}
|
166 |
+
return $fields;
|
167 |
+
}
|
168 |
+
add_filter('woocommerce_get_country_locale_default', 'thwcfd_prepare_country_locale');
|
169 |
+
add_filter('woocommerce_get_country_locale_base', 'thwcfd_prepare_country_locale');
|
170 |
+
|
171 |
+
function thwcfd_woo_get_country_locale($locale) {
|
172 |
+
if(is_array($locale)){
|
173 |
+
foreach($locale as $country => $fields){
|
174 |
+
$locale[$country] = thwcfd_prepare_country_locale($fields);
|
175 |
+
}
|
176 |
+
}
|
177 |
+
return $locale;
|
178 |
+
}
|
179 |
+
add_filter('woocommerce_get_country_locale', 'thwcfd_woo_get_country_locale');
|
180 |
+
|
181 |
/**
|
182 |
* wc_checkout_fields_modify_billing_fields function.
|
183 |
*
|
184 |
+
* @param mixed $fields
|
185 |
*/
|
186 |
+
function thwcfd_billing_fields_lite($fields, $country){
|
187 |
global $supress_field_modification;
|
188 |
|
189 |
if($supress_field_modification){
|
190 |
+
return $fields;
|
191 |
+
}
|
192 |
+
if(is_wc_endpoint_url('edit-address')){
|
193 |
+
return $fields;
|
194 |
+
}else{
|
195 |
+
return thwcfd_prepare_address_fields(get_option('wc_fields_billing'), $fields, 'billing', $country);
|
196 |
}
|
|
|
|
|
197 |
}
|
198 |
+
add_filter('woocommerce_billing_fields', 'thwcfd_billing_fields_lite', 1000, 2);
|
199 |
|
200 |
/**
|
201 |
* wc_checkout_fields_modify_shipping_fields function.
|
202 |
*
|
203 |
* @param mixed $old
|
204 |
*/
|
205 |
+
function thwcfd_shipping_fields_lite($fields, $country){
|
206 |
global $supress_field_modification;
|
207 |
|
208 |
if ($supress_field_modification){
|
209 |
+
return $fields;
|
210 |
+
}
|
211 |
+
if(is_wc_endpoint_url('edit-address')){
|
212 |
+
return $fields;
|
213 |
+
}else{
|
214 |
+
return thwcfd_prepare_address_fields(get_option('wc_fields_shipping'), $fields, 'shipping', $country);
|
215 |
}
|
|
|
|
|
216 |
}
|
217 |
+
add_filter('woocommerce_shipping_fields', 'thwcfd_shipping_fields_lite', 1000, 2);
|
218 |
|
219 |
/**
|
220 |
* wc_checkout_fields_modify_shipping_fields function.
|
229 |
}
|
230 |
|
231 |
if($additional_fields = get_option('wc_fields_additional')){
|
232 |
+
if( isset($fields['order']) && is_array($fields['order']) ){
|
233 |
+
$fields['order'] = $additional_fields + $fields['order'];
|
234 |
+
}
|
235 |
|
236 |
// check if order_comments is enabled/disabled
|
237 |
if(isset($additional_fields) && !$additional_fields['order_comments']['enabled']){
|
238 |
unset($fields['order']['order_comments']);
|
239 |
}
|
240 |
}
|
241 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
if(isset($fields['order']) && is_array($fields['order'])){
|
243 |
+
$fields['order'] = thwcfd_prepare_checkout_fields_lite($fields['order'], false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
}
|
245 |
|
246 |
return $fields;
|
247 |
}
|
248 |
add_filter('woocommerce_checkout_fields', 'thwcfd_checkout_fields_lite', 1000);
|
249 |
+
|
250 |
/**
|
|
|
251 |
*
|
|
|
|
|
252 |
*/
|
253 |
+
function thwcfd_prepare_address_fields($fieldset, $original_fieldset = false, $sname = 'billing', $country){
|
254 |
+
if(is_array($fieldset) && !empty($fieldset)) {
|
255 |
+
$locale = WC()->countries->get_country_locale();
|
256 |
+
if(isset($locale[ $country ]) && is_array($locale[ $country ])) {
|
257 |
+
foreach($locale[ $country ] as $key => $value){
|
258 |
+
if(is_array($value) && isset($fieldset[$sname.'_'.$key])){
|
259 |
+
if(isset($value['required'])){
|
260 |
+
$fieldset[$sname.'_'.$key]['required'] = $value['required'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
}
|
|
|
|
|
|
|
262 |
}
|
263 |
}
|
264 |
+
}
|
265 |
+
$fieldset = thwcfd_prepare_checkout_fields_lite($fieldset, $original_fieldset);
|
266 |
+
return $fieldset;
|
267 |
+
}else {
|
268 |
+
return $original_fieldset;
|
|
|
|
|
269 |
}
|
270 |
}
|
271 |
|
272 |
/**
|
273 |
+
* checkout_fields_modify_fields function.
|
274 |
*
|
275 |
+
* @param mixed $data
|
276 |
+
* @param mixed $old
|
277 |
*/
|
278 |
+
function thwcfd_prepare_checkout_fields_lite($fields, $original_fields) {
|
279 |
+
if(is_array($fields) && !empty($fields)) {
|
280 |
+
foreach($fields as $name => $field) {
|
281 |
+
if(isset($field['enabled']) && $field['enabled'] == false ) {
|
282 |
+
unset($fields[$name]);
|
283 |
+
}else{
|
284 |
+
$new_field = false;
|
285 |
+
|
286 |
+
if($original_fields && isset($original_fields[$name])){
|
287 |
+
$new_field = $original_fields[$name];
|
288 |
+
|
289 |
+
$new_field['label'] = isset($field['label']) ? $field['label'] : '';
|
290 |
+
$new_field['placeholder'] = isset($field['placeholder']) ? $field['placeholder'] : '';
|
291 |
+
|
292 |
+
$new_field['class'] = isset($field['class']) && is_array($field['class']) ? $field['class'] : array();
|
293 |
+
$new_field['label_class'] = isset($field['label_class']) && is_array($field['label_class']) ? $field['label_class'] : array();
|
294 |
+
$new_field['validate'] = isset($field['validate']) && is_array($field['validate']) ? $field['validate'] : array();
|
295 |
+
|
296 |
+
/*if(!thwcfd_is_locale_field($name)){
|
297 |
+
$new_field['required'] = isset($field['required']) ? $field['required'] : 0;
|
298 |
+
}*/
|
299 |
+
$new_field['required'] = isset($field['required']) ? $field['required'] : 0;
|
300 |
+
$new_field['clear'] = isset($field['clear']) ? $field['clear'] : 0;
|
301 |
+
}else{
|
302 |
+
$new_field = $field;
|
303 |
+
}
|
304 |
+
|
305 |
+
if(isset($new_field['type']) && $new_field['type'] === 'select'){
|
306 |
+
if(apply_filters('thwcfd_enable_select2_for_select_fields', true)){
|
307 |
+
$new_field['input_class'][] = 'thwcfd-enhanced-select';
|
308 |
}
|
309 |
}
|
310 |
+
|
311 |
+
$new_field['order'] = isset($field['order']) && is_numeric($field['order']) ? $field['order'] : 0;
|
312 |
+
if(isset($new_field['order']) && is_numeric($new_field['order'])){
|
313 |
+
$priority = ($new_field['order']+1)*10;
|
314 |
+
$new_field['priority'] = $priority;
|
315 |
+
//$new_field['priority'] = $new_field['order'];
|
316 |
+
}
|
317 |
+
|
318 |
+
if(isset($new_field['label'])){
|
319 |
+
$new_field['label'] = __($new_field['label'], 'woocommerce');
|
320 |
+
}
|
321 |
+
if(isset($new_field['placeholder'])){
|
322 |
+
$new_field['placeholder'] = __($new_field['placeholder'], 'woocommerce');
|
323 |
+
}
|
324 |
+
|
325 |
+
$fields[$name] = $new_field;
|
326 |
}
|
327 |
+
}
|
328 |
+
return $fields;
|
329 |
+
}else {
|
330 |
+
return $original_fields;
|
331 |
}
|
332 |
}
|
333 |
+
|
334 |
+
/*****************************************
|
335 |
+
----- Display Field Values - START ------
|
336 |
+
*****************************************/
|
337 |
|
338 |
/**
|
339 |
* Display custom fields in emails
|
341 |
* @param array $keys
|
342 |
* @return array
|
343 |
*/
|
344 |
+
function thwcfd_display_custom_fields_in_emails_lite($ofields, $sent_to_admin, $order){
|
345 |
+
$custom_fields = array();
|
346 |
$fields = array_merge(WC_Checkout_Field_Editor::get_fields('billing'), WC_Checkout_Field_Editor::get_fields('shipping'),
|
347 |
WC_Checkout_Field_Editor::get_fields('additional'));
|
348 |
|
349 |
// Loop through all custom fields to see if it should be added
|
350 |
+
foreach( $fields as $key => $options ) {
|
351 |
if(isset($options['show_in_email']) && $options['show_in_email']){
|
352 |
+
$value = '';
|
353 |
+
if(thwcfd_woo_version_check()){
|
354 |
+
$value = get_post_meta( $order->get_id(), $key, true );
|
355 |
+
}else{
|
356 |
+
$value = get_post_meta( $order->id, $key, true );
|
357 |
+
}
|
358 |
+
|
359 |
+
if(!empty($value)){
|
360 |
+
$label = isset($options['label']) && $options['label'] ? $options['label'] : $key;
|
361 |
+
$label = esc_attr($label);
|
362 |
+
|
363 |
+
$custom_field = array();
|
364 |
+
$custom_field['label'] = $label;
|
365 |
+
$custom_field['value'] = $value;
|
366 |
+
|
367 |
+
$custom_fields[$key] = $custom_field;
|
368 |
+
}
|
369 |
}
|
370 |
}
|
371 |
|
372 |
+
return array_merge($ofields, $custom_fields);
|
373 |
}
|
374 |
+
add_filter('woocommerce_email_order_meta_fields', 'thwcfd_display_custom_fields_in_emails_lite', 10, 3);
|
375 |
+
|
376 |
/**
|
377 |
* Display custom checkout fields on view order pages
|
378 |
*
|
379 |
* @param object $order
|
380 |
*/
|
381 |
function thwcfd_order_details_after_customer_details_lite($order){
|
382 |
+
if(thwcfd_woocommerce_version_check()){
|
383 |
+
$order_id = $order->get_id();
|
384 |
+
}else{
|
385 |
+
$order_id = $order->id;
|
386 |
+
}
|
387 |
|
388 |
$fields = array();
|
389 |
if(!wc_ship_to_billing_address_only() && $order->needs_shipping_address()){
|
392 |
}else{
|
393 |
$fields = array_merge(WC_Checkout_Field_Editor::get_fields('billing'), WC_Checkout_Field_Editor::get_fields('additional'));
|
394 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
|
396 |
+
if(is_array($fields) && !empty($fields)){
|
397 |
+
$fields_html = '';
|
398 |
+
// Loop through all custom fields to see if it should be added
|
399 |
+
foreach($fields as $name => $options){
|
400 |
+
$enabled = (isset($options['enabled']) && $options['enabled'] == false) ? false : true;
|
401 |
+
$is_custom_field = (isset($options['custom']) && $options['custom'] == true) ? true : false;
|
402 |
+
|
403 |
+
if(isset($options['show_in_order']) && $options['show_in_order'] && $enabled && $is_custom_field){
|
404 |
+
$value = get_post_meta($order_id, $name, true);
|
405 |
+
|
406 |
+
if(!empty($value)){
|
407 |
+
$label = isset($options['label']) && !empty($options['label']) ? __( $options['label'], 'woocommerce' ) : $name;
|
408 |
+
|
409 |
+
if(is_account_page()){
|
410 |
+
if(apply_filters( 'thwcfd_view_order_customer_details_table_view', true )){
|
411 |
+
$fields_html .= '<tr><th>'. esc_attr($label) .':</th><td>'. wptexturize($value) .'</td></tr>';
|
412 |
+
}else{
|
413 |
+
$fields_html .= '<br/><dt>'. esc_attr($label) .':</dt><dd>'. wptexturize($value) .'</dd>';
|
414 |
+
}
|
415 |
+
}else{
|
416 |
+
if(apply_filters( 'thwcfd_thankyou_customer_details_table_view', true )){
|
417 |
+
$fields_html .= '<tr><th>'. esc_attr($label) .':</th><td>'. wptexturize($value) .'</td></tr>';
|
418 |
+
}else{
|
419 |
+
$fields_html .= '<br/><dt>'. esc_attr($label) .':</dt><dd>'. wptexturize($value) .'</dd>';
|
420 |
+
}
|
421 |
+
}
|
422 |
+
}
|
423 |
+
}
|
424 |
+
}
|
425 |
+
|
426 |
+
if($fields_html){
|
427 |
+
do_action( 'thwcfd_order_details_before_custom_fields_table', $order );
|
428 |
+
?>
|
429 |
+
<table class="woocommerce-table woocommerce-table--custom-fields shop_table custom-fields">
|
430 |
+
<?php
|
431 |
+
echo $fields_html;
|
432 |
+
?>
|
433 |
+
</table>
|
434 |
+
<?php
|
435 |
+
do_action( 'thwcfd_order_details_after_custom_fields_table', $order );
|
436 |
}
|
|
|
|
|
|
|
437 |
}
|
438 |
}
|
439 |
+
add_action('woocommerce_order_details_after_order_table', 'thwcfd_order_details_after_customer_details_lite', 20, 1);
|
440 |
+
|
441 |
+
/*****************************************
|
442 |
+
----- Display Field Values - END --------
|
443 |
+
*****************************************/
|
444 |
+
|
445 |
+
function thwcfd_woo_version_check( $version = '3.0' ) {
|
446 |
+
if(function_exists( 'is_woocommerce_active' ) && is_woocommerce_active() ) {
|
447 |
+
global $woocommerce;
|
448 |
+
if( version_compare( $woocommerce->version, $version, ">=" ) ) {
|
449 |
+
return true;
|
450 |
+
}
|
451 |
+
}
|
452 |
+
return false;
|
453 |
+
}
|
454 |
+
|
455 |
}
|
classes/class-wc-checkout-field-editor-export-handler.php
CHANGED
@@ -8,8 +8,8 @@ class WC_Checkout_Field_Editor_Export_Handler {
|
|
8 |
$this->fields = $this->get_fields();
|
9 |
|
10 |
// Customer / Order CSV Export column headers/data
|
11 |
-
add_filter( 'wc_customer_order_csv_export_order_headers', array( $this, 'thwcfd_order_csv_export_order_headers' ), 10, 2 );
|
12 |
-
add_filter( 'wc_customer_order_csv_export_order_row', array( $this, 'thwcfd_customer_order_csv_export_order_row' ), 10, 4 );
|
13 |
}
|
14 |
|
15 |
/**
|
8 |
$this->fields = $this->get_fields();
|
9 |
|
10 |
// Customer / Order CSV Export column headers/data
|
11 |
+
//add_filter( 'wc_customer_order_csv_export_order_headers', array( $this, 'thwcfd_order_csv_export_order_headers' ), 10, 2 );
|
12 |
+
//add_filter( 'wc_customer_order_csv_export_order_row', array( $this, 'thwcfd_customer_order_csv_export_order_row' ), 10, 4 );
|
13 |
}
|
14 |
|
15 |
/**
|
classes/class-wc-checkout-field-editor.php
CHANGED
@@ -9,7 +9,7 @@ class WC_Checkout_Field_Editor {
|
|
9 |
/**
|
10 |
* __construct function.
|
11 |
*/
|
12 |
-
function __construct() {
|
13 |
// Validation rules are controlled by the local fields and can't be changed
|
14 |
$this->locale_fields = array(
|
15 |
'billing_address_1', 'billing_address_2', 'billing_state', 'billing_postcode', 'billing_city',
|
@@ -19,26 +19,43 @@ class WC_Checkout_Field_Editor {
|
|
19 |
|
20 |
add_action('admin_menu', array($this, 'admin_menu'));
|
21 |
add_filter('woocommerce_screen_ids', array($this, 'add_screen_id'));
|
|
|
22 |
add_action('woocommerce_checkout_update_order_meta', array($this, 'save_data'), 10, 2);
|
23 |
}
|
24 |
|
25 |
/**
|
26 |
* menu function.
|
27 |
*/
|
28 |
-
function admin_menu() {
|
29 |
$this->screen_id = add_submenu_page('woocommerce', __('WooCommerce Checkout Form Designer', 'thwcfd'), __('Checkout Form', 'thwcfd'),
|
30 |
'manage_woocommerce', 'checkout_form_designer', array($this, 'the_designer'));
|
31 |
|
32 |
add_action('admin_print_scripts-'. $this->screen_id, array($this, 'enqueue_admin_scripts'));
|
33 |
}
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
/**
|
36 |
* scripts function.
|
37 |
*/
|
38 |
-
function enqueue_admin_scripts() {
|
39 |
wp_enqueue_style ('thwcfd-style', plugins_url('/assets/css/thwcfd-style.css', dirname(__FILE__)));
|
40 |
wp_enqueue_script('thwcfd-admin-script', plugins_url('/assets/js/thwcfd-admin.js', dirname(__FILE__)), array('jquery', 'jquery-ui-dialog', 'jquery-ui-sortable',
|
41 |
-
'woocommerce_admin', 'select2', 'jquery-tiptip'),
|
42 |
}
|
43 |
|
44 |
public function output_premium_version_notice(){
|
@@ -51,11 +68,13 @@ class WC_Checkout_Field_Editor {
|
|
51 |
<p><strong><i>WooCommerce Checkout Field Editor Pro</i></strong> premium version provides more features to design your checkout page.</p>
|
52 |
<ul>
|
53 |
<li>12 field types available,<br/>(<i>Text, Hidden, Password, Textarea, Radio, Checkbox, Select, Multi-select, Date Picker, Time Picker, Heading, Label</i>).</li>
|
|
|
|
|
54 |
<li>Option to add more sections in addition to the core sections (billing, shipping and additional) in checkout page.</li>
|
55 |
</ul>
|
56 |
</td>
|
57 |
<td>
|
58 |
-
<a target="_blank" href="
|
59 |
<img src="<?php echo plugins_url( '../assets/css/upgrade-btn.png', __FILE__ ); ?>" />
|
60 |
</a>
|
61 |
</td>
|
@@ -65,28 +84,18 @@ class WC_Checkout_Field_Editor {
|
|
65 |
</div>
|
66 |
<?php
|
67 |
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* add_screen_id function.
|
71 |
-
*/
|
72 |
-
function add_screen_id($ids){
|
73 |
-
$ids[] = 'woocommerce_page_checkout_form_designer';
|
74 |
-
$ids[] = strtolower(__('WooCommerce', 'thwcfd')) .'_page_checkout_form_designer';
|
75 |
-
|
76 |
-
return $ids;
|
77 |
-
}
|
78 |
|
79 |
/**
|
80 |
* Reset checkout fields.
|
81 |
*/
|
82 |
-
function reset_checkout_fields() {
|
83 |
delete_option('wc_fields_billing');
|
84 |
delete_option('wc_fields_shipping');
|
85 |
delete_option('wc_fields_additional');
|
86 |
echo '<div class="updated"><p>'. __('SUCCESS: Checkout fields successfully reset', 'thwcfd') .'</p></div>';
|
87 |
}
|
88 |
|
89 |
-
function is_reserved_field_name( $field_name ){
|
90 |
if($field_name && in_array($field_name, array(
|
91 |
'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2', 'billing_city', 'billing_state',
|
92 |
'billing_country', 'billing_postcode', 'billing_phone', 'billing_email',
|
@@ -98,7 +107,7 @@ class WC_Checkout_Field_Editor {
|
|
98 |
return false;
|
99 |
}
|
100 |
|
101 |
-
function is_default_field_name($field_name){
|
102 |
if($field_name && in_array($field_name, array(
|
103 |
'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2', 'billing_city', 'billing_state',
|
104 |
'billing_country', 'billing_postcode', 'billing_phone', 'billing_email',
|
@@ -113,14 +122,14 @@ class WC_Checkout_Field_Editor {
|
|
113 |
/**
|
114 |
* Save Data function.
|
115 |
*/
|
116 |
-
function save_data($order_id, $posted){
|
117 |
$types = array('billing', 'shipping', 'additional');
|
118 |
|
119 |
foreach($types as $type){
|
120 |
$fields = $this->get_fields($type);
|
121 |
|
122 |
foreach($fields as $name => $field){
|
123 |
-
if(
|
124 |
$value = wc_clean($posted[$name]);
|
125 |
if($value){
|
126 |
update_post_meta($order_id, $name, $value);
|
@@ -151,14 +160,14 @@ class WC_Checkout_Field_Editor {
|
|
151 |
return $fields;
|
152 |
}
|
153 |
|
154 |
-
function sort_fields_by_order($a, $b){
|
155 |
if(!isset($a['order']) || $a['order'] == $b['order']){
|
156 |
return 0;
|
157 |
}
|
158 |
return ($a['order'] < $b['order']) ? -1 : 1;
|
159 |
}
|
160 |
|
161 |
-
function get_field_types(){
|
162 |
return array(
|
163 |
'text' => 'Text',
|
164 |
'select' => 'Select',
|
@@ -168,7 +177,7 @@ class WC_Checkout_Field_Editor {
|
|
168 |
/*
|
169 |
* New field form popup
|
170 |
*/
|
171 |
-
function wcfd_new_field_form_pp(){
|
172 |
$field_types = $this->get_field_types();
|
173 |
?>
|
174 |
<div id="wcfd_new_field_form_pp" title="New Checkout Field" class="wcfd_popup_wrapper">
|
@@ -207,10 +216,10 @@ class WC_Checkout_Field_Editor {
|
|
207 |
<td>Class</td>
|
208 |
<td><input type="text" name="fclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
209 |
</tr>
|
210 |
-
|
211 |
<td>Label Class</td>
|
212 |
<td><input type="text" name="flabelclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
213 |
-
</tr
|
214 |
<tr class="rowValidate">
|
215 |
<td>Validation</td>
|
216 |
<td>
|
@@ -218,6 +227,8 @@ class WC_Checkout_Field_Editor {
|
|
218 |
style="width: 250px; height:30px;">
|
219 |
<option value="email">Email</option>
|
220 |
<option value="phone">Phone</option>
|
|
|
|
|
221 |
</select>
|
222 |
</td>
|
223 |
</tr>
|
@@ -257,7 +268,7 @@ class WC_Checkout_Field_Editor {
|
|
257 |
/*
|
258 |
* New field form popup
|
259 |
*/
|
260 |
-
function wcfd_edit_field_form_pp(){
|
261 |
$field_types = $this->get_field_types();
|
262 |
?>
|
263 |
<div id="wcfd_edit_field_form_pp" title="Edit Checkout Field" class="wcfd_popup_wrapper">
|
@@ -300,10 +311,10 @@ class WC_Checkout_Field_Editor {
|
|
300 |
<td>Class</td>
|
301 |
<td><input type="text" name="fclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
302 |
</tr>
|
303 |
-
|
304 |
<td>Label Class</td>
|
305 |
<td><input type="text" name="flabelclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
306 |
-
</tr
|
307 |
<tr class="rowValidate">
|
308 |
<td>Validation</td>
|
309 |
<td>
|
@@ -311,6 +322,8 @@ class WC_Checkout_Field_Editor {
|
|
311 |
style="width: 250px; height:30px;">
|
312 |
<option value="email">Email</option>
|
313 |
<option value="phone">Phone</option>
|
|
|
|
|
314 |
</select>
|
315 |
</td>
|
316 |
</tr>
|
@@ -347,7 +360,7 @@ class WC_Checkout_Field_Editor {
|
|
347 |
<?php
|
348 |
}
|
349 |
|
350 |
-
function render_tabs_and_sections(){
|
351 |
$tabs = array( 'fields' => 'Checkout Fields' );
|
352 |
$tab = isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
|
353 |
|
@@ -382,11 +395,11 @@ class WC_Checkout_Field_Editor {
|
|
382 |
$this->output_premium_version_notice();
|
383 |
}
|
384 |
|
385 |
-
function get_current_tab(){
|
386 |
return isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
|
387 |
}
|
388 |
|
389 |
-
function get_current_section(){
|
390 |
$tab = $this->get_current_tab();
|
391 |
$section = '';
|
392 |
if($tab === 'fields'){
|
@@ -395,7 +408,7 @@ class WC_Checkout_Field_Editor {
|
|
395 |
return $section;
|
396 |
}
|
397 |
|
398 |
-
function render_checkout_fields_heading_row(){
|
399 |
?>
|
400 |
<th class="sort"></th>
|
401 |
<th class="check-column" style="padding-left:0px !important;"><input type="checkbox" style="margin-left:7px;" onclick="thwcfdSelectAllCheckoutFields(this)"/></th>
|
@@ -411,7 +424,7 @@ class WC_Checkout_Field_Editor {
|
|
411 |
<?php
|
412 |
}
|
413 |
|
414 |
-
function render_actions_row($section){
|
415 |
?>
|
416 |
<th colspan="7">
|
417 |
<button type="button" class="button button-primary" onclick="openNewFieldForm('<?php echo $section; ?>')"><?php _e( '+ Add field', 'thwcfd' ); ?></button>
|
@@ -421,19 +434,20 @@ class WC_Checkout_Field_Editor {
|
|
421 |
</th>
|
422 |
<th colspan="4">
|
423 |
<input type="submit" name="save_fields" class="button-primary" value="<?php _e( 'Save changes', 'thwcfd' ) ?>" style="float:right" />
|
424 |
-
<input type="submit" name="reset_fields" class="button" value="<?php _e( 'Reset to default fields', 'thwcfd' ) ?>" style="float:right; margin-right: 5px;"
|
|
|
425 |
</th>
|
426 |
<?php
|
427 |
}
|
428 |
|
429 |
-
function the_designer() {
|
430 |
$tab = $this->get_current_tab();
|
431 |
if($tab === 'fields'){
|
432 |
$this->checkout_form_field_editor();
|
433 |
}
|
434 |
}
|
435 |
|
436 |
-
function checkout_form_field_editor() {
|
437 |
$section = $this->get_current_section();
|
438 |
|
439 |
echo '<div class="wrap woocommerce"><div class="icon32 icon32-attributes" id="icon-woocommerce"><br /></div>';
|
@@ -477,31 +491,31 @@ class WC_Checkout_Field_Editor {
|
|
477 |
$options['placeholder'] = '';
|
478 |
}
|
479 |
|
480 |
-
if( isset( $options['options'] ) ) {
|
481 |
$options['options'] = implode("|", $options['options']);
|
482 |
}else{
|
483 |
$options['options'] = '';
|
484 |
}
|
485 |
|
486 |
-
if( isset( $options['class'] ) ) {
|
487 |
$options['class'] = implode(",", $options['class']);
|
488 |
}else{
|
489 |
$options['class'] = '';
|
490 |
}
|
491 |
|
492 |
-
if( isset( $options['label_class'] ) ) {
|
493 |
$options['label_class'] = implode(",", $options['label_class']);
|
494 |
}else{
|
495 |
$options['label_class'] = '';
|
496 |
}
|
497 |
|
498 |
-
if( isset( $options['validate'] ) ) {
|
499 |
$options['validate'] = implode(",", $options['validate']);
|
500 |
}else{
|
501 |
$options['validate'] = '';
|
502 |
}
|
503 |
|
504 |
-
if (
|
505 |
$options['required'] = '1';
|
506 |
} else {
|
507 |
$options['required'] = '0';
|
@@ -587,7 +601,7 @@ class WC_Checkout_Field_Editor {
|
|
587 |
<?php
|
588 |
}
|
589 |
|
590 |
-
function save_options( $section ) {
|
591 |
$o_fields = $this->get_fields( $section );
|
592 |
$fields = $o_fields;
|
593 |
//$core_fields = array_keys( WC()->countries->get_address_fields( WC()->countries->get_base_country(), $section . '_' ) );
|
@@ -664,7 +678,7 @@ class WC_Checkout_Field_Editor {
|
|
664 |
$fields[$name]['type'] = empty( $f_types[$i] ) ? $o_type : wc_clean( $f_types[$i] );
|
665 |
$fields[$name]['label'] = empty( $f_labels[$i] ) ? '' : wp_kses_post( trim( stripslashes( $f_labels[$i] ) ) );
|
666 |
$fields[$name]['placeholder'] = empty( $f_placeholder[$i] ) ? '' : wc_clean( stripslashes( $f_placeholder[$i] ) );
|
667 |
-
$fields[$name]['options'] = empty( $f_options[$i] ) ? array() : array_map( 'wc_clean', explode( '|', $f_options[$i] ) );
|
668 |
|
669 |
$fields[$name]['class'] = empty( $f_class[$i] ) ? array() : array_map( 'wc_clean', explode( ',', $f_class[$i] ) );
|
670 |
$fields[$name]['label_class'] = empty( $f_label_class[$i] ) ? array() : array_map( 'wc_clean', explode( ',', $f_label_class[$i] ) );
|
@@ -673,13 +687,13 @@ class WC_Checkout_Field_Editor {
|
|
673 |
$fields[$name]['clear'] = empty( $f_clear[$i] ) ? false : true;
|
674 |
|
675 |
$fields[$name]['enabled'] = empty( $f_enabled[$i] ) ? false : true;
|
676 |
-
$fields[$name]['order'] =
|
677 |
|
678 |
if (!empty( $fields[$name]['options'] )) {
|
679 |
$fields[$name]['options'] = array_combine( $fields[$name]['options'], $fields[$name]['options'] );
|
680 |
}
|
681 |
|
682 |
-
if (!in_array( $name, $this->locale_fields )){
|
683 |
$fields[$name]['validate'] = empty( $f_validation[$i] ) ? array() : explode( ',', $f_validation[$i] );
|
684 |
}
|
685 |
|
@@ -704,45 +718,5 @@ class WC_Checkout_Field_Editor {
|
|
704 |
echo '<div class="error"><p> ' . __( 'Your changes were not saved due to an error (or you made none!).', 'thwcfd' ) . '</p></div>';
|
705 |
}
|
706 |
}
|
707 |
-
|
708 |
-
/*
|
709 |
-
function get_woocommerce_checkout_fields(){
|
710 |
-
$billing = array(
|
711 |
-
'billing_first_name',
|
712 |
-
'billing_last_name',
|
713 |
-
'billing_company',
|
714 |
-
'billing_address_1',
|
715 |
-
'billing_address_2',
|
716 |
-
'billing_city',
|
717 |
-
'billing_postcode',
|
718 |
-
'billing_country',
|
719 |
-
'billing_state',
|
720 |
-
'billing_email',
|
721 |
-
'billing_phone'
|
722 |
-
);
|
723 |
-
$shipping = array(
|
724 |
-
'shipping_first_name',
|
725 |
-
'shipping_last_name',
|
726 |
-
'shipping_company',
|
727 |
-
'shipping_address_1',
|
728 |
-
'shipping_address_2',
|
729 |
-
'shipping_city',
|
730 |
-
'shipping_postcode',
|
731 |
-
'shipping_country',
|
732 |
-
'shipping_state',
|
733 |
-
);
|
734 |
-
$account = array(
|
735 |
-
'account_username',
|
736 |
-
'account_password',
|
737 |
-
'account_password-2',
|
738 |
-
);
|
739 |
-
$order = array(
|
740 |
-
'order_comments',
|
741 |
-
);
|
742 |
-
}
|
743 |
-
|
744 |
-
function get_properties(){
|
745 |
-
$properties = array('type', 'label', 'placeholder', 'class', 'required', 'clear', 'label_class', 'options');
|
746 |
-
}
|
747 |
-
*/
|
748 |
}
|
9 |
/**
|
10 |
* __construct function.
|
11 |
*/
|
12 |
+
public function __construct() {
|
13 |
// Validation rules are controlled by the local fields and can't be changed
|
14 |
$this->locale_fields = array(
|
15 |
'billing_address_1', 'billing_address_2', 'billing_state', 'billing_postcode', 'billing_city',
|
19 |
|
20 |
add_action('admin_menu', array($this, 'admin_menu'));
|
21 |
add_filter('woocommerce_screen_ids', array($this, 'add_screen_id'));
|
22 |
+
add_filter('plugin_action_links_'.TH_WCFD_BASE_NAME, array($this, 'add_settings_link'));
|
23 |
add_action('woocommerce_checkout_update_order_meta', array($this, 'save_data'), 10, 2);
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
* menu function.
|
28 |
*/
|
29 |
+
public function admin_menu() {
|
30 |
$this->screen_id = add_submenu_page('woocommerce', __('WooCommerce Checkout Form Designer', 'thwcfd'), __('Checkout Form', 'thwcfd'),
|
31 |
'manage_woocommerce', 'checkout_form_designer', array($this, 'the_designer'));
|
32 |
|
33 |
add_action('admin_print_scripts-'. $this->screen_id, array($this, 'enqueue_admin_scripts'));
|
34 |
}
|
35 |
|
36 |
+
/**
|
37 |
+
* add_screen_id function.
|
38 |
+
*/
|
39 |
+
public function add_screen_id($ids){
|
40 |
+
$ids[] = 'woocommerce_page_checkout_form_designer';
|
41 |
+
$ids[] = strtolower(__('WooCommerce', 'thwcfd')) .'_page_checkout_form_designer';
|
42 |
+
|
43 |
+
return $ids;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function add_settings_link($links) {
|
47 |
+
$settings_link = '<a href="'.admin_url('admin.php?page=checkout_form_designer').'">'. __('Settings') .'</a>';
|
48 |
+
array_unshift($links, $settings_link);
|
49 |
+
return $links;
|
50 |
+
}
|
51 |
+
|
52 |
/**
|
53 |
* scripts function.
|
54 |
*/
|
55 |
+
public function enqueue_admin_scripts() {
|
56 |
wp_enqueue_style ('thwcfd-style', plugins_url('/assets/css/thwcfd-style.css', dirname(__FILE__)));
|
57 |
wp_enqueue_script('thwcfd-admin-script', plugins_url('/assets/js/thwcfd-admin.js', dirname(__FILE__)), array('jquery', 'jquery-ui-dialog', 'jquery-ui-sortable',
|
58 |
+
'woocommerce_admin', 'select2', 'jquery-tiptip'), TH_WCFD_VERSION, true);
|
59 |
}
|
60 |
|
61 |
public function output_premium_version_notice(){
|
68 |
<p><strong><i>WooCommerce Checkout Field Editor Pro</i></strong> premium version provides more features to design your checkout page.</p>
|
69 |
<ul>
|
70 |
<li>12 field types available,<br/>(<i>Text, Hidden, Password, Textarea, Radio, Checkbox, Select, Multi-select, Date Picker, Time Picker, Heading, Label</i>).</li>
|
71 |
+
<li>Conditionally display fields based on cart items and other field(s) values.</li>
|
72 |
+
<li>Add an extra cost to the cart total based on field selection.</li>
|
73 |
<li>Option to add more sections in addition to the core sections (billing, shipping and additional) in checkout page.</li>
|
74 |
</ul>
|
75 |
</td>
|
76 |
<td>
|
77 |
+
<a target="_blank" href="https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/" class="">
|
78 |
<img src="<?php echo plugins_url( '../assets/css/upgrade-btn.png', __FILE__ ); ?>" />
|
79 |
</a>
|
80 |
</td>
|
84 |
</div>
|
85 |
<?php
|
86 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
/**
|
89 |
* Reset checkout fields.
|
90 |
*/
|
91 |
+
public function reset_checkout_fields() {
|
92 |
delete_option('wc_fields_billing');
|
93 |
delete_option('wc_fields_shipping');
|
94 |
delete_option('wc_fields_additional');
|
95 |
echo '<div class="updated"><p>'. __('SUCCESS: Checkout fields successfully reset', 'thwcfd') .'</p></div>';
|
96 |
}
|
97 |
|
98 |
+
public function is_reserved_field_name( $field_name ){
|
99 |
if($field_name && in_array($field_name, array(
|
100 |
'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2', 'billing_city', 'billing_state',
|
101 |
'billing_country', 'billing_postcode', 'billing_phone', 'billing_email',
|
107 |
return false;
|
108 |
}
|
109 |
|
110 |
+
public function is_default_field_name($field_name){
|
111 |
if($field_name && in_array($field_name, array(
|
112 |
'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2', 'billing_city', 'billing_state',
|
113 |
'billing_country', 'billing_postcode', 'billing_phone', 'billing_email',
|
122 |
/**
|
123 |
* Save Data function.
|
124 |
*/
|
125 |
+
public function save_data($order_id, $posted){
|
126 |
$types = array('billing', 'shipping', 'additional');
|
127 |
|
128 |
foreach($types as $type){
|
129 |
$fields = $this->get_fields($type);
|
130 |
|
131 |
foreach($fields as $name => $field){
|
132 |
+
if(isset($field['custom']) && $field['custom'] && isset($posted[$name])){
|
133 |
$value = wc_clean($posted[$name]);
|
134 |
if($value){
|
135 |
update_post_meta($order_id, $name, $value);
|
160 |
return $fields;
|
161 |
}
|
162 |
|
163 |
+
public function sort_fields_by_order($a, $b){
|
164 |
if(!isset($a['order']) || $a['order'] == $b['order']){
|
165 |
return 0;
|
166 |
}
|
167 |
return ($a['order'] < $b['order']) ? -1 : 1;
|
168 |
}
|
169 |
|
170 |
+
public function get_field_types(){
|
171 |
return array(
|
172 |
'text' => 'Text',
|
173 |
'select' => 'Select',
|
177 |
/*
|
178 |
* New field form popup
|
179 |
*/
|
180 |
+
public function wcfd_new_field_form_pp(){
|
181 |
$field_types = $this->get_field_types();
|
182 |
?>
|
183 |
<div id="wcfd_new_field_form_pp" title="New Checkout Field" class="wcfd_popup_wrapper">
|
216 |
<td>Class</td>
|
217 |
<td><input type="text" name="fclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
218 |
</tr>
|
219 |
+
<!--<tr class="rowLabelClass">
|
220 |
<td>Label Class</td>
|
221 |
<td><input type="text" name="flabelclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
222 |
+
</tr>-->
|
223 |
<tr class="rowValidate">
|
224 |
<td>Validation</td>
|
225 |
<td>
|
227 |
style="width: 250px; height:30px;">
|
228 |
<option value="email">Email</option>
|
229 |
<option value="phone">Phone</option>
|
230 |
+
<option value="postcode">Postcode</option>
|
231 |
+
<option value="state">State</option>
|
232 |
</select>
|
233 |
</td>
|
234 |
</tr>
|
268 |
/*
|
269 |
* New field form popup
|
270 |
*/
|
271 |
+
public function wcfd_edit_field_form_pp(){
|
272 |
$field_types = $this->get_field_types();
|
273 |
?>
|
274 |
<div id="wcfd_edit_field_form_pp" title="Edit Checkout Field" class="wcfd_popup_wrapper">
|
311 |
<td>Class</td>
|
312 |
<td><input type="text" name="fclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
313 |
</tr>
|
314 |
+
<!--<tr class="rowLabelClass">
|
315 |
<td>Label Class</td>
|
316 |
<td><input type="text" name="flabelclass" placeholder="Seperate classes with comma" style="width:250px;"/></td>
|
317 |
+
</tr>-->
|
318 |
<tr class="rowValidate">
|
319 |
<td>Validation</td>
|
320 |
<td>
|
322 |
style="width: 250px; height:30px;">
|
323 |
<option value="email">Email</option>
|
324 |
<option value="phone">Phone</option>
|
325 |
+
<option value="postcode">Postcode</option>
|
326 |
+
<option value="state">State</option>
|
327 |
</select>
|
328 |
</td>
|
329 |
</tr>
|
360 |
<?php
|
361 |
}
|
362 |
|
363 |
+
public function render_tabs_and_sections(){
|
364 |
$tabs = array( 'fields' => 'Checkout Fields' );
|
365 |
$tab = isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
|
366 |
|
395 |
$this->output_premium_version_notice();
|
396 |
}
|
397 |
|
398 |
+
public function get_current_tab(){
|
399 |
return isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'fields';
|
400 |
}
|
401 |
|
402 |
+
public function get_current_section(){
|
403 |
$tab = $this->get_current_tab();
|
404 |
$section = '';
|
405 |
if($tab === 'fields'){
|
408 |
return $section;
|
409 |
}
|
410 |
|
411 |
+
public function render_checkout_fields_heading_row(){
|
412 |
?>
|
413 |
<th class="sort"></th>
|
414 |
<th class="check-column" style="padding-left:0px !important;"><input type="checkbox" style="margin-left:7px;" onclick="thwcfdSelectAllCheckoutFields(this)"/></th>
|
424 |
<?php
|
425 |
}
|
426 |
|
427 |
+
public function render_actions_row($section){
|
428 |
?>
|
429 |
<th colspan="7">
|
430 |
<button type="button" class="button button-primary" onclick="openNewFieldForm('<?php echo $section; ?>')"><?php _e( '+ Add field', 'thwcfd' ); ?></button>
|
434 |
</th>
|
435 |
<th colspan="4">
|
436 |
<input type="submit" name="save_fields" class="button-primary" value="<?php _e( 'Save changes', 'thwcfd' ) ?>" style="float:right" />
|
437 |
+
<input type="submit" name="reset_fields" class="button" value="<?php _e( 'Reset to default fields', 'thwcfd' ) ?>" style="float:right; margin-right: 5px;"
|
438 |
+
onclick="return confirm('Are you sure you want to reset to default fields? all your changes will be deleted.');"/>
|
439 |
</th>
|
440 |
<?php
|
441 |
}
|
442 |
|
443 |
+
public function the_designer() {
|
444 |
$tab = $this->get_current_tab();
|
445 |
if($tab === 'fields'){
|
446 |
$this->checkout_form_field_editor();
|
447 |
}
|
448 |
}
|
449 |
|
450 |
+
public function checkout_form_field_editor() {
|
451 |
$section = $this->get_current_section();
|
452 |
|
453 |
echo '<div class="wrap woocommerce"><div class="icon32 icon32-attributes" id="icon-woocommerce"><br /></div>';
|
491 |
$options['placeholder'] = '';
|
492 |
}
|
493 |
|
494 |
+
if( isset( $options['options'] ) && is_array($options['options']) ) {
|
495 |
$options['options'] = implode("|", $options['options']);
|
496 |
}else{
|
497 |
$options['options'] = '';
|
498 |
}
|
499 |
|
500 |
+
if( isset( $options['class'] ) && is_array($options['class']) ) {
|
501 |
$options['class'] = implode(",", $options['class']);
|
502 |
}else{
|
503 |
$options['class'] = '';
|
504 |
}
|
505 |
|
506 |
+
if( isset( $options['label_class'] ) && is_array($options['label_class']) ) {
|
507 |
$options['label_class'] = implode(",", $options['label_class']);
|
508 |
}else{
|
509 |
$options['label_class'] = '';
|
510 |
}
|
511 |
|
512 |
+
if( isset( $options['validate'] ) && is_array($options['validate']) ) {
|
513 |
$options['validate'] = implode(",", $options['validate']);
|
514 |
}else{
|
515 |
$options['validate'] = '';
|
516 |
}
|
517 |
|
518 |
+
if ( isset( $options['required'] ) && $options['required'] == 1 ) {
|
519 |
$options['required'] = '1';
|
520 |
} else {
|
521 |
$options['required'] = '0';
|
601 |
<?php
|
602 |
}
|
603 |
|
604 |
+
public function save_options( $section ) {
|
605 |
$o_fields = $this->get_fields( $section );
|
606 |
$fields = $o_fields;
|
607 |
//$core_fields = array_keys( WC()->countries->get_address_fields( WC()->countries->get_base_country(), $section . '_' ) );
|
678 |
$fields[$name]['type'] = empty( $f_types[$i] ) ? $o_type : wc_clean( $f_types[$i] );
|
679 |
$fields[$name]['label'] = empty( $f_labels[$i] ) ? '' : wp_kses_post( trim( stripslashes( $f_labels[$i] ) ) );
|
680 |
$fields[$name]['placeholder'] = empty( $f_placeholder[$i] ) ? '' : wc_clean( stripslashes( $f_placeholder[$i] ) );
|
681 |
+
$fields[$name]['options'] = empty( $f_options[$i] ) ? array() : array_map( 'wc_clean', explode( '|', trim(stripslashes($f_options[$i])) ) );
|
682 |
|
683 |
$fields[$name]['class'] = empty( $f_class[$i] ) ? array() : array_map( 'wc_clean', explode( ',', $f_class[$i] ) );
|
684 |
$fields[$name]['label_class'] = empty( $f_label_class[$i] ) ? array() : array_map( 'wc_clean', explode( ',', $f_label_class[$i] ) );
|
687 |
$fields[$name]['clear'] = empty( $f_clear[$i] ) ? false : true;
|
688 |
|
689 |
$fields[$name]['enabled'] = empty( $f_enabled[$i] ) ? false : true;
|
690 |
+
$fields[$name]['order'] = isset($f_order[$i]) && is_numeric($f_order[$i]) ? wc_clean( $f_order[$i] ) : '';
|
691 |
|
692 |
if (!empty( $fields[$name]['options'] )) {
|
693 |
$fields[$name]['options'] = array_combine( $fields[$name]['options'], $fields[$name]['options'] );
|
694 |
}
|
695 |
|
696 |
+
if (!in_array( $name, $this->locale_fields ) || apply_filters('thwcfd_allow_address_field_validation_override', false, $name)){
|
697 |
$fields[$name]['validate'] = empty( $f_validation[$i] ) ? array() : explode( ',', $f_validation[$i] );
|
698 |
}
|
699 |
|
718 |
echo '<div class="error"><p> ' . __( 'Your changes were not saved due to an error (or you made none!).', 'thwcfd' ) . '</p></div>';
|
719 |
}
|
720 |
}
|
721 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
722 |
}
|
readme.txt
CHANGED
@@ -1,40 +1,42 @@
|
|
1 |
-
===
|
2 |
Contributors: ThemeHigh
|
3 |
-
Donate link:
|
4 |
-
Tags: checkout field editor, checkout field customizer, checkout form editor, checkout form customizer, checkout, WooCommerce checkout, checkout form designer, checkout
|
5 |
-
Requires at least:
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
-
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
= Introduction =
|
16 |
-
Woo Checkout Field Editor Pro plugin provides an easy way to customise (add, edit, delete and change display order) your fields displayed on WooCommerce checkout page. This plugin requires WooCommerce to be installed, activated, and configured.
|
17 |
|
18 |
= BASIC FEATURES =
|
19 |
-
* <strong>Add new custom field(s).</strong> You can add custom field(s) in Billing, Shipping and Additional fields sections. New field form contains options to provide values for Type, Name, Label, Placeholder, Class, Label Class etc. It also has the option to choose validations rules from a predefined list.
|
20 |
* <strong>Edit field(s).</strong> You can edit core and custom field(s) in Billing, Shipping and Additional fields sections. In edit form you have the option to provide new values for Name, Type, Label, Placeholder, Class, Label Class, validation rules etc(availability of these options may change based on the field types).
|
21 |
* Available field types are <strong>Input Text</strong> and <strong>Select</strong>
|
22 |
* <strong>Display in Order Details page and Email.</strong> You can decide on a field whether it need to be displayed in Order Details page and Email using the the checkboxes ‘Display in Order Detail Pages’ and ‘Display in Emails’. These checkboxes are availabe in both the ‘New Field’ and ‘Edit Field’ forms.
|
23 |
* <strong>Remove field(s).</strong> You can remove field(s) from displaying in checkout page, order details page and emails. Removing core fields may leads to unexpected results with some plugins. We are not recommending this.
|
24 |
* <strong>Enable/Disable field(s).</strong> You can enable/disable field(s)(temporarily remove) from displaying in checkout page, order details page and emails. Disabling core fields may leads to unexpected results with some plugins. We are not recommending this.
|
25 |
-
* <strong>Change
|
26 |
* <strong>Reset to default field set.</strong> You can reset all your changes back to the original WooCommerce fields set using the button ‘Reset to default fields’.
|
27 |
|
28 |
= BUY PREMIUM VERSION =
|
29 |
-
|
|
|
30 |
|
31 |
<blockquote>
|
32 |
= PREMIUM VERSION FEATURES =
|
33 |
<ul>
|
34 |
-
<li><strong>
|
35 |
<p>Available field types:</p>
|
36 |
<ol>
|
37 |
<li><strong>Text</strong> – A basic input text field.</li>
|
|
|
38 |
<li><strong>Password</strong> – An input password text box.</li>
|
39 |
<li><strong>Textarea</strong> – A textarea field.</li>
|
40 |
<li><strong>Radio</strong> – Radio button input (for selecting one of many choices)</li>
|
@@ -42,9 +44,13 @@ Woo Checkout Field Editor Pro plugin provides an easy way to customise (add, edi
|
|
42 |
<li><strong>Select</strong> – A drop-down list (for selecting one of many choices)</li>
|
43 |
<li><strong>Multi-select</strong> – A drop-down list (allows multiple selections from many choices)</li>
|
44 |
<li><strong>Date picker</strong> – Select a date from a popup.</li>
|
|
|
45 |
<li><strong>Heading</strong> – Display a heading/ title</li>
|
|
|
46 |
</ol>
|
47 |
</li>
|
|
|
|
|
48 |
<li><strong>Add new section:</strong> Add new section(s) in predefined positions in checkout page.
|
49 |
<p>Available positions:</p>
|
50 |
<ol>
|
@@ -67,10 +73,10 @@ Woo Checkout Field Editor Pro plugin provides an easy way to customise (add, edi
|
|
67 |
|
68 |
== Installation ==
|
69 |
= Minimum Requirements =
|
70 |
-
* WooCommerce
|
71 |
-
* WordPress
|
72 |
-
* PHP version 5.2.4 or greater
|
73 |
-
* MySQL version 5.0 or greater
|
74 |
|
75 |
= Automatic installation =
|
76 |
1. Log in to your WordPress dashboard
|
@@ -96,6 +102,54 @@ Yes. There is a button 'reset to default fields' to go back to the WooCommerce d
|
|
96 |
8. Newly added field
|
97 |
|
98 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
= 1.0.9 =
|
100 |
* Fix for enhanced select pre populate issue in admin settings page.
|
101 |
|
1 |
+
=== WooCommerce Checkout Field Editor (Manager) Pro ===
|
2 |
Contributors: ThemeHigh
|
3 |
+
Donate link: https://themehigh.com/
|
4 |
+
Tags: checkout field editor, woocommerce checkout field editor, checkout manager, woocommerce checkout manager, checkout field customizer, checkout form editor, checkout form customizer, checkout, WooCommerce checkout, checkout form designer, checkout
|
5 |
+
Requires at least: 4.0
|
6 |
+
Tested up to: 4.9
|
7 |
+
Stable tag: 1.2.5
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
WooCommerce Checkout Field Editor Pro - The best WooCommerce checkout manager plugin to customize checkout fields on your WooCommerce checkout page.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
= Introduction =
|
16 |
+
If you are wondering how to add custom field in WooCommerce checkout page, you are at the right place. Woo Checkout Field Editor Pro plugin provides an easy way to customise (add, edit, delete and change display order) your fields displayed on WooCommerce checkout page. This plugin requires WooCommerce to be installed, activated, and configured.
|
17 |
|
18 |
= BASIC FEATURES =
|
19 |
+
* <strong>Add new custom field(s).</strong> Adding custom fields to the WooCommerce checkout page is a breeze now. You can add custom field(s) in Billing, Shipping and Additional fields sections. New field form contains options to provide values for Type, Name, Label, Placeholder, Class, Label Class etc. It also has the option to choose validations rules from a predefined list.
|
20 |
* <strong>Edit field(s).</strong> You can edit core and custom field(s) in Billing, Shipping and Additional fields sections. In edit form you have the option to provide new values for Name, Type, Label, Placeholder, Class, Label Class, validation rules etc(availability of these options may change based on the field types).
|
21 |
* Available field types are <strong>Input Text</strong> and <strong>Select</strong>
|
22 |
* <strong>Display in Order Details page and Email.</strong> You can decide on a field whether it need to be displayed in Order Details page and Email using the the checkboxes ‘Display in Order Detail Pages’ and ‘Display in Emails’. These checkboxes are availabe in both the ‘New Field’ and ‘Edit Field’ forms.
|
23 |
* <strong>Remove field(s).</strong> You can remove field(s) from displaying in checkout page, order details page and emails. Removing core fields may leads to unexpected results with some plugins. We are not recommending this.
|
24 |
* <strong>Enable/Disable field(s).</strong> You can enable/disable field(s)(temporarily remove) from displaying in checkout page, order details page and emails. Disabling core fields may leads to unexpected results with some plugins. We are not recommending this.
|
25 |
+
* <strong>Change checkout fields order.</strong> You can easily manage the display order of checkout fields from admin side by just moving fields up and down.
|
26 |
* <strong>Reset to default field set.</strong> You can reset all your changes back to the original WooCommerce fields set using the button ‘Reset to default fields’.
|
27 |
|
28 |
= BUY PREMIUM VERSION =
|
29 |
+
Check out the premium version of WooCommerce Checkout Field Editor Pro - The best WooCommerce checkout manager plugin which helps you to customize checkout fields displayed on your WooCommerce checkout page. Add custom fields to WooCommerce checkout page easily.
|
30 |
+
<a rel="nofollow" href="https://www.themehigh.com/product/woocommerce-checkout-field-editor-pro/?utm_source=wordpress&utm_medium=referral&utm_content=tracking">Buy Now!</a>
|
31 |
|
32 |
<blockquote>
|
33 |
= PREMIUM VERSION FEATURES =
|
34 |
<ul>
|
35 |
+
<li><strong>12 field types are available:</strong> In Add New Field form and Edit Field form you can choose field type from a list of 12 including 10 input fields and one field for title/heading and one for label.
|
36 |
<p>Available field types:</p>
|
37 |
<ol>
|
38 |
<li><strong>Text</strong> – A basic input text field.</li>
|
39 |
+
<li><strong>Hidden</strong> – A hidden field.</li>
|
40 |
<li><strong>Password</strong> – An input password text box.</li>
|
41 |
<li><strong>Textarea</strong> – A textarea field.</li>
|
42 |
<li><strong>Radio</strong> – Radio button input (for selecting one of many choices)</li>
|
44 |
<li><strong>Select</strong> – A drop-down list (for selecting one of many choices)</li>
|
45 |
<li><strong>Multi-select</strong> – A drop-down list (allows multiple selections from many choices)</li>
|
46 |
<li><strong>Date picker</strong> – Select a date from a popup.</li>
|
47 |
+
<li><strong>Time picker</strong> – Select a time from a popup.</li>
|
48 |
<li><strong>Heading</strong> – Display a heading/ title</li>
|
49 |
+
<li><strong>Label</strong> – Display a label/ text</li>
|
50 |
</ol>
|
51 |
</li>
|
52 |
+
<li><strong>Conditional Fields:</strong> Conditionally display fields based on cart items and other field(s) values.</li>
|
53 |
+
<li><strong>Price Fields:</strong> Add an extra cost to the cart total based on field selection.</li>
|
54 |
<li><strong>Add new section:</strong> Add new section(s) in predefined positions in checkout page.
|
55 |
<p>Available positions:</p>
|
56 |
<ol>
|
73 |
|
74 |
== Installation ==
|
75 |
= Minimum Requirements =
|
76 |
+
* WooCommerce 3.0 or greater
|
77 |
+
* WordPress 4.0 or greater
|
78 |
+
* PHP version 5.2.4 or greater (PHP 5.6 or greater is recommended)
|
79 |
+
* MySQL version 5.0 or greater (MySQL 5.6 or greater is recommended)
|
80 |
|
81 |
= Automatic installation =
|
82 |
1. Log in to your WordPress dashboard
|
102 |
8. Newly added field
|
103 |
|
104 |
== Changelog ==
|
105 |
+
= 1.2.5 =
|
106 |
+
* WooCommerce tested up to version updated.
|
107 |
+
|
108 |
+
= 1.2.4 =
|
109 |
+
* Improvement for checkout fields display ordering.
|
110 |
+
|
111 |
+
= 1.2.3 =
|
112 |
+
* Replaced the hooks those are removed from WooCommerce version 3.2.0.
|
113 |
+
|
114 |
+
= 1.2.2 =
|
115 |
+
* Replaced deprecated hook.
|
116 |
+
|
117 |
+
= 1.2.1 =
|
118 |
+
* Fix for required validation issue with default address fields.
|
119 |
+
* Added placeholder for select field.
|
120 |
+
* Added confirmation check for reset button.
|
121 |
+
|
122 |
+
= 1.2.0 =
|
123 |
+
* Fix for required validation issue with default address fields.
|
124 |
+
|
125 |
+
= 1.1.9 =
|
126 |
+
* Fix for required validation issue with default address fields.
|
127 |
+
|
128 |
+
= 1.1.8 =
|
129 |
+
* Fix for the issue of showing wrong value for placeholder text.
|
130 |
+
|
131 |
+
= 1.1.7 =
|
132 |
+
* Fix for checkout fields sorting(display order) issue.
|
133 |
+
|
134 |
+
= 1.1.6 =
|
135 |
+
* Multisite support added
|
136 |
+
* Removed deprecated function call.
|
137 |
+
|
138 |
+
= 1.1.5 =
|
139 |
+
* Updated plugin to make it compatible with WooCommerce version 3.0.0
|
140 |
+
|
141 |
+
= 1.1.4 =
|
142 |
+
* Fix for unsupported operand types issue.
|
143 |
+
|
144 |
+
= 1.1.3 =
|
145 |
+
* Fix for Address Fields property modification issues.
|
146 |
+
|
147 |
+
= 1.1.2 =
|
148 |
+
* Fix for 'Invalid argument passed' warning message.
|
149 |
+
|
150 |
+
= 1.1.1 =
|
151 |
+
* Fix for 'Undefined index' warning/error message.
|
152 |
+
|
153 |
= 1.0.9 =
|
154 |
* Fix for enhanced select pre populate issue in admin settings page.
|
155 |
|