Version Description
2017/03/04 =
Adicionado suporte ao WooCommerce 3.0.
Alterado o plugin de mscara de jquery.maskedinput para jquery.mask. (Possvel com a ajuda de Thiago Guimares).
Corrigida a mscara dos campos telefone e celular, permitido ter 10 ou 11 dgitos sem alterar a experincia do usurio. (Possvel com a ajuda de Thiago Guimares).
Alterados os tipos dos campos telefone, celular, cep, data de nascimento para
tel
quando o pas selecionado for BR. (Possvel com a ajuda de Thiago Guimares).Alterados os tipos dos campos cpf, cnpj para
tel
e e-mail paraemail
. (Possvel com a ajuda de Thiago Guimares).
=
Download this release
Release Info
Developer | claudiosanches |
Plugin | WooCommerce Extra Checkout Fields for Brazil |
Version | 3.5.0 |
Comparing to | |
See all releases |
Code changes from version 3.4.6 to 3.5.0
- assets/css/admin/admin.css +1 -1
- assets/css/admin/admin.scss +1 -11
- assets/css/admin/settings.css +1 -0
- assets/css/admin/settings.scss +42 -0
- assets/js/frontend/frontend.js +24 -24
- assets/js/frontend/frontend.min.js +1 -1
- assets/js/jquery-maskedinput/jquery.maskedinput.js +0 -182
- assets/js/jquery-maskedinput/jquery.maskedinput.min.js +0 -7
- assets/js/jquery.mask/jquery.mask.js +540 -0
- assets/js/jquery.mask/jquery.mask.min.js +18 -0
- includes/admin/{class-wc-ecfb-admin.php → class-extra-checkout-fields-for-brazil-admin.php} +17 -12
- includes/admin/{class-wc-ecfb-customer.php → class-extra-checkout-fields-for-brazil-customer.php} +36 -29
- includes/admin/class-extra-checkout-fields-for-brazil-order.php +327 -0
- includes/admin/{class-wc-ecfb-settings.php → class-extra-checkout-fields-for-brazil-settings.php} +24 -38
- includes/admin/class-wc-ecfb-order.php +0 -394
- includes/admin/views/html-admin-help-message.php +17 -0
- includes/admin/views/html-checkbox-field.php +18 -0
- includes/admin/views/html-legacy-order-billing-data.php +55 -0
- includes/admin/views/html-order-billing-data.php +55 -0
- includes/admin/views/html-select-field.php +19 -0
- includes/admin/views/html-settings-page.php +10 -6
- includes/class-extra-checkout-fields-for-brazil-api.php +437 -0
- includes/{class-wc-ecfb-formatting.php → class-extra-checkout-fields-for-brazil-formatting.php} +15 -9
- includes/{class-wc-ecfb-front-end.php → class-extra-checkout-fields-for-brazil-front-end.php} +107 -94
- includes/class-extra-checkout-fields-for-brazil-integrations.php +129 -0
- includes/class-wc-ecfb-api.php +0 -319
- includes/class-wc-ecfb-plugins-support.php +0 -86
- languages/woocommerce-extra-checkout-fields-for-brazil.pot +197 -224
- readme.txt +11 -52
- uninstall.php +6 -0
- woocommerce-extra-checkout-fields-for-brazil.php +47 -17
assets/css/admin/admin.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
#order_data .order_data_column ._billing_persontype_field,#order_data .order_data_column ._billing_cpf_field,#order_data .order_data_column ._billing_rg_field,#order_data .order_data_column ._billing_cnpj_field,#order_data .order_data_column ._billing_ie_field{clear:both !important;width:100% !important}#order_data .order_data_column ._billing_sex_field,#order_data .order_data_column ._billing_number_field,#order_data .order_data_column ._shipping_number_field{float:right !important
|
1 |
+
#order_data .order_data_column ._billing_persontype_field,#order_data .order_data_column ._billing_cpf_field,#order_data .order_data_column ._billing_rg_field,#order_data .order_data_column ._billing_cnpj_field,#order_data .order_data_column ._billing_ie_field{clear:both !important;width:100% !important}#order_data .order_data_column ._billing_sex_field,#order_data .order_data_column ._billing_number_field,#order_data .order_data_column ._shipping_number_field{float:right !important;clear:right !important}
|
assets/css/admin/admin.scss
CHANGED
@@ -14,17 +14,7 @@
|
|
14 |
._billing_number_field,
|
15 |
._shipping_number_field {
|
16 |
float: right !important;
|
17 |
-
|
18 |
-
}
|
19 |
-
|
20 |
-
&.panel {
|
21 |
-
.order_data_column .address {
|
22 |
-
display: none;
|
23 |
-
}
|
24 |
-
|
25 |
-
/* To WooCommerce 1.6.6 or earlier */
|
26 |
-
.order_data .address {
|
27 |
-
display: none;
|
28 |
}
|
29 |
}
|
30 |
}
|
14 |
._billing_number_field,
|
15 |
._shipping_number_field {
|
16 |
float: right !important;
|
17 |
+
clear: right !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
}
|
20 |
}
|
assets/css/admin/settings.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.woocommerce-message a.button-primary,.woocommerce-message button.button-primary{background:#bb77ae;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,0.25),0 1px 0 #a36597;color:#fff;text-shadow:0 -1px 1px #a36597, 1px 0 1px #a36597, 0 1px 1px #a36597, -1px 0 1px #a36597;display:inline-block}.woocommerce-message a.button-primary:hover,.woocommerce-message a.button-primary:focus,.woocommerce-message a.button-primary:active,.woocommerce-message button.button-primary:hover,.woocommerce-message button.button-primary:focus,.woocommerce-message button.button-primary:active{background:#a36597;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,0.25),0 1px 0 #a36597}.woocommerce-message{position:relative;border-left-color:#cc99c2 !important;overflow:hidden}.woocommerce-message a.woocommerce-message-close{position:absolute;top:10px;right:10px;padding:10px 15px 10px 21px;font-size:13px;line-height:1.23076923;text-decoration:none}.woocommerce-message a.woocommerce-message-close::before{position:absolute;top:8px;left:0;-webkit-transition:all 0.1s ease-in-out;transition:all 0.1s ease-in-out}
|
assets/css/admin/settings.scss
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.woocommerce-message {
|
2 |
+
a.button-primary,
|
3 |
+
button.button-primary {
|
4 |
+
background: #bb77ae;
|
5 |
+
border-color: #a36597;
|
6 |
+
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
7 |
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
8 |
+
color: #fff;
|
9 |
+
text-shadow: 0 -1px 1px #a36597, 1px 0 1px #a36597, 0 1px 1px #a36597, -1px 0 1px #a36597;
|
10 |
+
display: inline-block;
|
11 |
+
|
12 |
+
&:hover, &:focus, &:active {
|
13 |
+
background: #a36597;
|
14 |
+
border-color: #a36597;
|
15 |
+
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
16 |
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
.woocommerce-message {
|
22 |
+
position: relative;
|
23 |
+
border-left-color: #cc99c2 !important;
|
24 |
+
overflow: hidden;
|
25 |
+
|
26 |
+
a.woocommerce-message-close {
|
27 |
+
position: absolute;
|
28 |
+
top: 10px;
|
29 |
+
right: 10px;
|
30 |
+
padding: 10px 15px 10px 21px;
|
31 |
+
font-size: 13px;
|
32 |
+
line-height: 1.23076923;
|
33 |
+
text-decoration: none;
|
34 |
+
&::before {
|
35 |
+
position: absolute;
|
36 |
+
top: 8px;
|
37 |
+
left: 0;
|
38 |
+
-webkit-transition: all 0.1s ease-in-out;
|
39 |
+
transition: all 0.1s ease-in-out;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
assets/js/frontend/frontend.js
CHANGED
@@ -11,7 +11,9 @@ jQuery( function( $ ) {
|
|
11 |
* Initialize frontend actions
|
12 |
*/
|
13 |
init: function() {
|
14 |
-
|
|
|
|
|
15 |
|
16 |
if ( '0' !== wcbcf_public_params.person_type ) {
|
17 |
this.person_type_fields();
|
@@ -112,44 +114,42 @@ jQuery( function( $ ) {
|
|
112 |
},
|
113 |
|
114 |
maskBilling: function() {
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
$( '#billing_birthdate' ).
|
119 |
-
$( '#billing_postcode' ).mask( '99999-999' );
|
120 |
},
|
121 |
|
122 |
unmaskBilling: function() {
|
123 |
-
$( '#billing_phone, #billing_cellphone, #billing_birthdate, #billing_postcode' ).unmask();
|
124 |
},
|
125 |
|
126 |
maskShipping: function() {
|
127 |
-
$( '#shipping_postcode' ).mask( '
|
128 |
},
|
129 |
|
130 |
unmaskShipping: function() {
|
131 |
-
$( '#shipping_postcode' ).unmask();
|
132 |
},
|
133 |
|
134 |
maskGeneral: function() {
|
135 |
-
$( '#billing_cpf, #credit-card-cpf' ).mask( '
|
136 |
-
$( '#billing_cnpj' ).mask( '
|
137 |
-
|
138 |
-
.focusout( wc_ecfb_frontend.maskPhone )
|
139 |
-
.trigger( 'focusout' );
|
140 |
},
|
141 |
|
142 |
-
maskPhone: function() {
|
143 |
-
var
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
|
|
|
|
|
|
|
|
147 |
|
148 |
-
|
149 |
-
element.mask( '(99) 99999-999?9' );
|
150 |
-
} else {
|
151 |
-
element.mask( '(99) 9999-9999?9' );
|
152 |
-
}
|
153 |
},
|
154 |
|
155 |
emailCheck: function() {
|
11 |
* Initialize frontend actions
|
12 |
*/
|
13 |
init: function() {
|
14 |
+
if ( '0' === wcbcf_public_params.sort_state_country ) {
|
15 |
+
$( document.body ).on( 'country_to_state_changing', this.country_to_state_changing );
|
16 |
+
}
|
17 |
|
18 |
if ( '0' !== wcbcf_public_params.person_type ) {
|
19 |
this.person_type_fields();
|
114 |
},
|
115 |
|
116 |
maskBilling: function() {
|
117 |
+
wc_ecfb_frontend.maskPhone( '#billing_phone, #billing_cellphone' );
|
118 |
+
$( '#billing_birthdate' ).mask( '00/00/0000' );
|
119 |
+
$( '#billing_postcode' ).mask( '00000-000' );
|
120 |
+
$( '#billing_phone, #billing_cellphone, #billing_birthdate, #billing_postcode' ).attr( 'type', 'tel' );
|
|
|
121 |
},
|
122 |
|
123 |
unmaskBilling: function() {
|
124 |
+
$( '#billing_phone, #billing_cellphone, #billing_birthdate, #billing_postcode' ).unmask().attr( 'type', 'text' );
|
125 |
},
|
126 |
|
127 |
maskShipping: function() {
|
128 |
+
$( '#shipping_postcode' ).mask( '00000-000' ).attr( 'type', 'tel' );
|
129 |
},
|
130 |
|
131 |
unmaskShipping: function() {
|
132 |
+
$( '#shipping_postcode' ).unmask().attr( 'type', 'text' );
|
133 |
},
|
134 |
|
135 |
maskGeneral: function() {
|
136 |
+
$( '#billing_cpf, #credit-card-cpf' ).mask( '000.000.000-00' );
|
137 |
+
$( '#billing_cnpj' ).mask( '00.000.000/0000-00' );
|
138 |
+
wc_ecfb_frontend.maskPhone( '#credit-card-phone' );
|
|
|
|
|
139 |
},
|
140 |
|
141 |
+
maskPhone: function(selector) {
|
142 |
+
var $element = $(selector),
|
143 |
+
MaskBehavior = function(val) {
|
144 |
+
return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009';
|
145 |
+
},
|
146 |
+
maskOptions = {
|
147 |
+
onKeyPress: function(val, e, field, options) {
|
148 |
+
field.mask(MaskBehavior.apply({}, arguments), options);
|
149 |
+
}
|
150 |
+
};
|
151 |
|
152 |
+
$element.mask(MaskBehavior, maskOptions);
|
|
|
|
|
|
|
|
|
153 |
},
|
154 |
|
155 |
emailCheck: function() {
|
assets/js/frontend/frontend.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(function(a){var b={init:function(){a(document.body).on("country_to_state_changing",this.country_to_state_changing),"0"!==wcbcf_public_params.person_type&&this.person_type_fields(),"yes"===wcbcf_public_params.maskedinput&&(a(document.body).on("change","#billing_country",function(){"BR"===a(this).val()?b.maskBilling():b.unmaskBilling()}),a(document.body).on("change","#shipping_country",function(){"BR"===a(this).val()?b.maskShipping():b.unmaskShipping()}),this.maskGeneral()),"yes"===wcbcf_public_params.mailcheck&&this.emailCheck(),"yes"===wcbcf_public_params.addresscomplete&&(this.addressAutoComplete("billing"),this.addressAutoCompleteOnChange("billing"),this.addressAutoComplete("shipping"),this.addressAutoCompleteOnChange("shipping"))},country_to_state_changing:function(){a("#billing_state_field label").html(wcbcf_public_params.state+' <abbr class="required" title="'+wcbcf_public_params.required+'">*</abbr>'),a("#billing_postcode_field").insertAfter("#billing_country_field"),a("#shipping_state_field").length&&(a("#shipping_state_field label").html(wcbcf_public_params.state+' <abbr class="required" title="'+wcbcf_public_params.required+'">*</abbr>'),a("#shipping_postcode_field").insertAfter("#shipping_country_field"))},person_type_fields:function(){"no"===wcbcf_public_params.only_brazil?(a(".person-type-field").addClass("validate-required"),a(".person-type-field label").append(' <abbr class="required" title="'+wcbcf_public_params.required+'">*</abbr>')):a("#billing_country").on("change",function(){
|
1 |
+
jQuery(function(a){var b={init:function(){"0"===wcbcf_public_params.sort_state_country&&a(document.body).on("country_to_state_changing",this.country_to_state_changing),"0"!==wcbcf_public_params.person_type&&this.person_type_fields(),"yes"===wcbcf_public_params.maskedinput&&(a(document.body).on("change","#billing_country",function(){"BR"===a(this).val()?b.maskBilling():b.unmaskBilling()}),a(document.body).on("change","#shipping_country",function(){"BR"===a(this).val()?b.maskShipping():b.unmaskShipping()}),this.maskGeneral()),"yes"===wcbcf_public_params.mailcheck&&this.emailCheck(),"yes"===wcbcf_public_params.addresscomplete&&(this.addressAutoComplete("billing"),this.addressAutoCompleteOnChange("billing"),this.addressAutoComplete("shipping"),this.addressAutoCompleteOnChange("shipping"))},country_to_state_changing:function(){a("#billing_state_field label").html(wcbcf_public_params.state+' <abbr class="required" title="'+wcbcf_public_params.required+'">*</abbr>'),a("#billing_postcode_field").insertAfter("#billing_country_field"),a("#shipping_state_field").length&&(a("#shipping_state_field label").html(wcbcf_public_params.state+' <abbr class="required" title="'+wcbcf_public_params.required+'">*</abbr>'),a("#shipping_postcode_field").insertAfter("#shipping_country_field"))},person_type_fields:function(){"no"===wcbcf_public_params.only_brazil?(a(".person-type-field").addClass("validate-required"),a(".person-type-field label").append(' <abbr class="required" title="'+wcbcf_public_params.required+'">*</abbr>')):a("#billing_country").on("change",function(){"BR"===a(this).val()?(a(".person-type-field").addClass("validate-required"),a(".person-type-field label").append(' <abbr class="required" title="'+wcbcf_public_params.required+'">*</abbr>')):(a(".person-type-field").removeClass("validate-required"),a(".person-type-field label abbr").remove())}).change(),"1"===wcbcf_public_params.person_type&&a("#billing_persontype").on("change",function(){var b=a(this).val();a("#billing_cpf_field").hide(),a("#billing_rg_field").hide(),a("#billing_company_field").hide(),a("#billing_cnpj_field").hide(),a("#billing_ie_field").hide(),"1"===b&&(a("#billing_cpf_field").show(),a("#billing_rg_field").show()),"2"===b&&(a("#billing_company_field").show(),a("#billing_cnpj_field").show(),a("#billing_ie_field").show())}).change()},maskBilling:function(){b.maskPhone("#billing_phone, #billing_cellphone"),a("#billing_birthdate").mask("00/00/0000"),a("#billing_postcode").mask("00000-000"),a("#billing_phone, #billing_cellphone, #billing_birthdate, #billing_postcode").attr("type","tel")},unmaskBilling:function(){a("#billing_phone, #billing_cellphone, #billing_birthdate, #billing_postcode").unmask().attr("type","text")},maskShipping:function(){a("#shipping_postcode").mask("00000-000").attr("type","tel")},unmaskShipping:function(){a("#shipping_postcode").unmask().attr("type","text")},maskGeneral:function(){a("#billing_cpf, #credit-card-cpf").mask("000.000.000-00"),a("#billing_cnpj").mask("00.000.000/0000-00"),b.maskPhone("#credit-card-phone")},maskPhone:function(b){var c=a(b),d=function(a){return 11===a.replace(/\D/g,"").length?"(00) 00000-0000":"(00) 0000-00009"},e={onKeyPress:function(a,b,c,e){c.mask(d.apply({},arguments),e)}};c.mask(d,e)},emailCheck:function(){a("#wcbcf-mailsuggest").length<1&&a("#billing_email").after('<div id="wcbcf-mailsuggest"></div>'),a("#billing_email").on("blur",function(){a("#wcbcf-mailsuggest").html(""),a(this).mailcheck({suggested:function(b,c){a("#wcbcf-mailsuggest").html("Você quis dizer: "+c.full+"?")}})}),a("#wcbcf-mailsuggest").css({color:"#c00",fontSize:"small"})},addressAutoComplete:function(b){if(a("#"+b+"_postcode").length){var c=a("#"+b+"_postcode").val().replace(".","").replace("-",""),d=a("#"+b+"_country").val(),e=a("#"+b+"_address_1").val();""!==c&&8===c.length&&"BR"===d&&0===e.length&&a.ajax({type:"GET",url:"//correiosapi.apphb.com/cep/"+c,dataType:"jsonp",crossDomain:!0,contentType:"application/json",success:function(c){""!==c.tipoDeLogradouro?a("#"+b+"_address_1").val(c.tipoDeLogradouro+" "+c.logradouro).change():a("#"+b+"_address_1").val(c.logradouro).change(),a("#"+b+"_neighborhood").val(c.bairro).change(),a("#"+b+"_city").val(c.cidade).change(),a("#"+b+"_state option:selected").attr("selected",!1).change(),a("#"+b+'_state option[value="'+c.estado+'"]').attr("selected","selected").change(),a("#"+b+"_state").trigger("liszt:updated").trigger("chosen:updated")}})}},addressAutoCompleteOnChange:function(c){a(document.body).on("blur","#"+c+"_postcode",function(){b.addressAutoComplete(c)})}};b.init()});
|
assets/js/jquery-maskedinput/jquery.maskedinput.js
DELETED
@@ -1,182 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
jQuery Masked Input Plugin
|
3 |
-
Copyright (c) 2007 - 2015 Josh Bush (digitalbush.com)
|
4 |
-
Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
|
5 |
-
Version: 1.4.1
|
6 |
-
*/
|
7 |
-
!function(factory) {
|
8 |
-
"function" == typeof define && define.amd ? define([ "jquery" ], factory) : factory("object" == typeof exports ? require("jquery") : jQuery);
|
9 |
-
}(function($) {
|
10 |
-
var caretTimeoutId, ua = navigator.userAgent, iPhone = /iphone/i.test(ua), chrome = /chrome/i.test(ua), android = /android/i.test(ua);
|
11 |
-
$.mask = {
|
12 |
-
definitions: {
|
13 |
-
"9": "[0-9]",
|
14 |
-
a: "[A-Za-z]",
|
15 |
-
"*": "[A-Za-z0-9]"
|
16 |
-
},
|
17 |
-
autoclear: !0,
|
18 |
-
dataName: "rawMaskFn",
|
19 |
-
placeholder: "_"
|
20 |
-
}, $.fn.extend({
|
21 |
-
caret: function(begin, end) {
|
22 |
-
var range;
|
23 |
-
if (0 !== this.length && !this.is(":hidden")) return "number" == typeof begin ? (end = "number" == typeof end ? end : begin,
|
24 |
-
this.each(function() {
|
25 |
-
this.setSelectionRange ? this.setSelectionRange(begin, end) : this.createTextRange && (range = this.createTextRange(),
|
26 |
-
range.collapse(!0), range.moveEnd("character", end), range.moveStart("character", begin),
|
27 |
-
range.select());
|
28 |
-
})) : (this[0].setSelectionRange ? (begin = this[0].selectionStart, end = this[0].selectionEnd) : document.selection && document.selection.createRange && (range = document.selection.createRange(),
|
29 |
-
begin = 0 - range.duplicate().moveStart("character", -1e5), end = begin + range.text.length),
|
30 |
-
{
|
31 |
-
begin: begin,
|
32 |
-
end: end
|
33 |
-
});
|
34 |
-
},
|
35 |
-
unmask: function() {
|
36 |
-
return this.trigger("unmask");
|
37 |
-
},
|
38 |
-
mask: function(mask, settings) {
|
39 |
-
var input, defs, tests, partialPosition, firstNonMaskPos, lastRequiredNonMaskPos, len, oldVal;
|
40 |
-
if (!mask && this.length > 0) {
|
41 |
-
input = $(this[0]);
|
42 |
-
var fn = input.data($.mask.dataName);
|
43 |
-
return fn ? fn() : void 0;
|
44 |
-
}
|
45 |
-
return settings = $.extend({
|
46 |
-
autoclear: $.mask.autoclear,
|
47 |
-
placeholder: $.mask.placeholder,
|
48 |
-
completed: null
|
49 |
-
}, settings), defs = $.mask.definitions, tests = [], partialPosition = len = mask.length,
|
50 |
-
firstNonMaskPos = null, $.each(mask.split(""), function(i, c) {
|
51 |
-
"?" == c ? (len--, partialPosition = i) : defs[c] ? (tests.push(new RegExp(defs[c])),
|
52 |
-
null === firstNonMaskPos && (firstNonMaskPos = tests.length - 1), partialPosition > i && (lastRequiredNonMaskPos = tests.length - 1)) : tests.push(null);
|
53 |
-
}), this.trigger("unmask").each(function() {
|
54 |
-
function tryFireCompleted() {
|
55 |
-
if (settings.completed) {
|
56 |
-
for (var i = firstNonMaskPos; lastRequiredNonMaskPos >= i; i++) if (tests[i] && buffer[i] === getPlaceholder(i)) return;
|
57 |
-
settings.completed.call(input);
|
58 |
-
}
|
59 |
-
}
|
60 |
-
function getPlaceholder(i) {
|
61 |
-
return settings.placeholder.charAt(i < settings.placeholder.length ? i : 0);
|
62 |
-
}
|
63 |
-
function seekNext(pos) {
|
64 |
-
for (;++pos < len && !tests[pos]; ) ;
|
65 |
-
return pos;
|
66 |
-
}
|
67 |
-
function seekPrev(pos) {
|
68 |
-
for (;--pos >= 0 && !tests[pos]; ) ;
|
69 |
-
return pos;
|
70 |
-
}
|
71 |
-
function shiftL(begin, end) {
|
72 |
-
var i, j;
|
73 |
-
if (!(0 > begin)) {
|
74 |
-
for (i = begin, j = seekNext(end); len > i; i++) if (tests[i]) {
|
75 |
-
if (!(len > j && tests[i].test(buffer[j]))) break;
|
76 |
-
buffer[i] = buffer[j], buffer[j] = getPlaceholder(j), j = seekNext(j);
|
77 |
-
}
|
78 |
-
writeBuffer(), input.caret(Math.max(firstNonMaskPos, begin));
|
79 |
-
}
|
80 |
-
}
|
81 |
-
function shiftR(pos) {
|
82 |
-
var i, c, j, t;
|
83 |
-
for (i = pos, c = getPlaceholder(pos); len > i; i++) if (tests[i]) {
|
84 |
-
if (j = seekNext(i), t = buffer[i], buffer[i] = c, !(len > j && tests[j].test(t))) break;
|
85 |
-
c = t;
|
86 |
-
}
|
87 |
-
}
|
88 |
-
function androidInputEvent() {
|
89 |
-
var curVal = input.val(), pos = input.caret();
|
90 |
-
if (oldVal && oldVal.length && oldVal.length > curVal.length) {
|
91 |
-
for (checkVal(!0); pos.begin > 0 && !tests[pos.begin - 1]; ) pos.begin--;
|
92 |
-
if (0 === pos.begin) for (;pos.begin < firstNonMaskPos && !tests[pos.begin]; ) pos.begin++;
|
93 |
-
input.caret(pos.begin, pos.begin);
|
94 |
-
} else {
|
95 |
-
for (checkVal(!0); pos.begin < len && !tests[pos.begin]; ) pos.begin++;
|
96 |
-
input.caret(pos.begin, pos.begin);
|
97 |
-
}
|
98 |
-
tryFireCompleted();
|
99 |
-
}
|
100 |
-
function blurEvent() {
|
101 |
-
checkVal(), input.val() != focusText && input.change();
|
102 |
-
}
|
103 |
-
function keydownEvent(e) {
|
104 |
-
if (!input.prop("readonly")) {
|
105 |
-
var pos, begin, end, k = e.which || e.keyCode;
|
106 |
-
oldVal = input.val(), 8 === k || 46 === k || iPhone && 127 === k ? (pos = input.caret(),
|
107 |
-
begin = pos.begin, end = pos.end, end - begin === 0 && (begin = 46 !== k ? seekPrev(begin) : end = seekNext(begin - 1),
|
108 |
-
end = 46 === k ? seekNext(end) : end), clearBuffer(begin, end), shiftL(begin, end - 1),
|
109 |
-
e.preventDefault()) : 13 === k ? blurEvent.call(this, e) : 27 === k && (input.val(focusText),
|
110 |
-
input.caret(0, checkVal()), e.preventDefault());
|
111 |
-
}
|
112 |
-
}
|
113 |
-
function keypressEvent(e) {
|
114 |
-
if (!input.prop("readonly")) {
|
115 |
-
var p, c, next, k = e.which || e.keyCode, pos = input.caret();
|
116 |
-
if (!(e.ctrlKey || e.altKey || e.metaKey || 32 > k) && k && 13 !== k) {
|
117 |
-
if (pos.end - pos.begin !== 0 && (clearBuffer(pos.begin, pos.end), shiftL(pos.begin, pos.end - 1)),
|
118 |
-
p = seekNext(pos.begin - 1), len > p && (c = String.fromCharCode(k), tests[p].test(c))) {
|
119 |
-
if (shiftR(p), buffer[p] = c, writeBuffer(), next = seekNext(p), android) {
|
120 |
-
var proxy = function() {
|
121 |
-
$.proxy($.fn.caret, input, next)();
|
122 |
-
};
|
123 |
-
setTimeout(proxy, 0);
|
124 |
-
} else input.caret(next);
|
125 |
-
pos.begin <= lastRequiredNonMaskPos && tryFireCompleted();
|
126 |
-
}
|
127 |
-
e.preventDefault();
|
128 |
-
}
|
129 |
-
}
|
130 |
-
}
|
131 |
-
function clearBuffer(start, end) {
|
132 |
-
var i;
|
133 |
-
for (i = start; end > i && len > i; i++) tests[i] && (buffer[i] = getPlaceholder(i));
|
134 |
-
}
|
135 |
-
function writeBuffer() {
|
136 |
-
input.val(buffer.join(""));
|
137 |
-
}
|
138 |
-
function checkVal(allow) {
|
139 |
-
var i, c, pos, test = input.val(), lastMatch = -1;
|
140 |
-
for (i = 0, pos = 0; len > i; i++) if (tests[i]) {
|
141 |
-
for (buffer[i] = getPlaceholder(i); pos++ < test.length; ) if (c = test.charAt(pos - 1),
|
142 |
-
tests[i].test(c)) {
|
143 |
-
buffer[i] = c, lastMatch = i;
|
144 |
-
break;
|
145 |
-
}
|
146 |
-
if (pos > test.length) {
|
147 |
-
clearBuffer(i + 1, len);
|
148 |
-
break;
|
149 |
-
}
|
150 |
-
} else buffer[i] === test.charAt(pos) && pos++, partialPosition > i && (lastMatch = i);
|
151 |
-
return allow ? writeBuffer() : partialPosition > lastMatch + 1 ? settings.autoclear || buffer.join("") === defaultBuffer ? (input.val() && input.val(""),
|
152 |
-
clearBuffer(0, len)) : writeBuffer() : (writeBuffer(), input.val(input.val().substring(0, lastMatch + 1))),
|
153 |
-
partialPosition ? i : firstNonMaskPos;
|
154 |
-
}
|
155 |
-
var input = $(this), buffer = $.map(mask.split(""), function(c, i) {
|
156 |
-
return "?" != c ? defs[c] ? getPlaceholder(i) : c : void 0;
|
157 |
-
}), defaultBuffer = buffer.join(""), focusText = input.val();
|
158 |
-
input.data($.mask.dataName, function() {
|
159 |
-
return $.map(buffer, function(c, i) {
|
160 |
-
return tests[i] && c != getPlaceholder(i) ? c : null;
|
161 |
-
}).join("");
|
162 |
-
}), input.one("unmask", function() {
|
163 |
-
input.off(".mask").removeData($.mask.dataName);
|
164 |
-
}).on("focus.mask", function() {
|
165 |
-
if (!input.prop("readonly")) {
|
166 |
-
clearTimeout(caretTimeoutId);
|
167 |
-
var pos;
|
168 |
-
focusText = input.val(), pos = checkVal(), caretTimeoutId = setTimeout(function() {
|
169 |
-
input.get(0) === document.activeElement && (writeBuffer(), pos == mask.replace("?", "").length ? input.caret(0, pos) : input.caret(pos));
|
170 |
-
}, 10);
|
171 |
-
}
|
172 |
-
}).on("blur.mask", blurEvent).on("keydown.mask", keydownEvent).on("keypress.mask", keypressEvent).on("input.mask paste.mask", function() {
|
173 |
-
input.prop("readonly") || setTimeout(function() {
|
174 |
-
var pos = checkVal(!0);
|
175 |
-
input.caret(pos), tryFireCompleted();
|
176 |
-
}, 0);
|
177 |
-
}), chrome && android && input.off("input.mask").on("input.mask", androidInputEvent),
|
178 |
-
checkVal();
|
179 |
-
});
|
180 |
-
}
|
181 |
-
});
|
182 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/jquery-maskedinput/jquery.maskedinput.min.js
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
jQuery Masked Input Plugin
|
3 |
-
Copyright (c) 2007 - 2015 Josh Bush (digitalbush.com)
|
4 |
-
Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
|
5 |
-
Version: 1.4.1
|
6 |
-
*/
|
7 |
-
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;if(0!==this.length&&!this.is(":hidden"))return"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a<g.placeholder.length?a:0)}function q(a){for(;++a<n&&!j[a];);return a}function r(a){for(;--a>=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(o&&o.length&&o.length>a.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.begin<l&&!j[b.begin];)b.begin++;B.caret(b.begin,b.begin)}else{for(A(!0);b.begin<n&&!j[b.begin];)b.begin++;B.caret(b.begin,b.begin)}h()}function v(){A(),B.val()!=E&&B.change()}function w(a){if(!B.prop("readonly")){var b,c,e,f=a.which||a.keyCode;o=B.val(),8===f||46===f||d&&127===f?(b=B.caret(),c=b.begin,e=b.end,e-c===0&&(c=46!==f?r(c):e=q(c-1),e=46===f?q(e):e),y(c,e),s(c,e-1),a.preventDefault()):13===f?v.call(this,a):27===f&&(B.val(E),B.caret(0,A()),a.preventDefault())}}function x(b){if(!B.prop("readonly")){var c,d,e,g=b.which||b.keyCode,i=B.caret();if(!(b.ctrlKey||b.altKey||b.metaKey||32>g)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++<e.length;)if(c=e.charAt(d-1),j[b].test(c)){C[b]=c,f=b;break}if(d>e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){B.get(0)===document.activeElement&&(z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a))},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/jquery.mask/jquery.mask.js
ADDED
@@ -0,0 +1,540 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* jquery.mask.js
|
3 |
+
* @version: v1.14.10
|
4 |
+
* @author: Igor Escobar
|
5 |
+
*
|
6 |
+
* Created by Igor Escobar on 2012-03-10. Please report any bug at http://blog.igorescobar.com
|
7 |
+
*
|
8 |
+
* Copyright (c) 2012 Igor Escobar http://blog.igorescobar.com
|
9 |
+
*
|
10 |
+
* The MIT License (http://www.opensource.org/licenses/mit-license.php)
|
11 |
+
*
|
12 |
+
* Permission is hereby granted, free of charge, to any person
|
13 |
+
* obtaining a copy of this software and associated documentation
|
14 |
+
* files (the "Software"), to deal in the Software without
|
15 |
+
* restriction, including without limitation the rights to use,
|
16 |
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
17 |
+
* copies of the Software, and to permit persons to whom the
|
18 |
+
* Software is furnished to do so, subject to the following
|
19 |
+
* conditions:
|
20 |
+
*
|
21 |
+
* The above copyright notice and this permission notice shall be
|
22 |
+
* included in all copies or substantial portions of the Software.
|
23 |
+
*
|
24 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
25 |
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
26 |
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
27 |
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
28 |
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
29 |
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
30 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
31 |
+
* OTHER DEALINGS IN THE SOFTWARE.
|
32 |
+
*/
|
33 |
+
|
34 |
+
/* jshint laxbreak: true */
|
35 |
+
/* jshint maxcomplexity:17 */
|
36 |
+
/* global define */
|
37 |
+
|
38 |
+
'use strict';
|
39 |
+
|
40 |
+
// UMD (Universal Module Definition) patterns for JavaScript modules that work everywhere.
|
41 |
+
// https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js
|
42 |
+
(function (factory, jQuery, Zepto) {
|
43 |
+
|
44 |
+
if (typeof define === 'function' && define.amd) {
|
45 |
+
define(['jquery'], factory);
|
46 |
+
} else if (typeof exports === 'object') {
|
47 |
+
module.exports = factory(require('jquery'));
|
48 |
+
} else {
|
49 |
+
factory(jQuery || Zepto);
|
50 |
+
}
|
51 |
+
|
52 |
+
}(function ($) {
|
53 |
+
|
54 |
+
var Mask = function (el, mask, options) {
|
55 |
+
|
56 |
+
var p = {
|
57 |
+
invalid: [],
|
58 |
+
getCaret: function () {
|
59 |
+
try {
|
60 |
+
var sel,
|
61 |
+
pos = 0,
|
62 |
+
ctrl = el.get(0),
|
63 |
+
dSel = document.selection,
|
64 |
+
cSelStart = ctrl.selectionStart;
|
65 |
+
|
66 |
+
// IE Support
|
67 |
+
if (dSel && navigator.appVersion.indexOf('MSIE 10') === -1) {
|
68 |
+
sel = dSel.createRange();
|
69 |
+
sel.moveStart('character', -p.val().length);
|
70 |
+
pos = sel.text.length;
|
71 |
+
}
|
72 |
+
// Firefox support
|
73 |
+
else if (cSelStart || cSelStart === '0') {
|
74 |
+
pos = cSelStart;
|
75 |
+
}
|
76 |
+
|
77 |
+
return pos;
|
78 |
+
} catch (e) {}
|
79 |
+
},
|
80 |
+
setCaret: function(pos) {
|
81 |
+
try {
|
82 |
+
if (el.is(':focus')) {
|
83 |
+
var range, ctrl = el.get(0);
|
84 |
+
|
85 |
+
// Firefox, WebKit, etc..
|
86 |
+
if (ctrl.setSelectionRange) {
|
87 |
+
ctrl.setSelectionRange(pos, pos);
|
88 |
+
} else { // IE
|
89 |
+
range = ctrl.createTextRange();
|
90 |
+
range.collapse(true);
|
91 |
+
range.moveEnd('character', pos);
|
92 |
+
range.moveStart('character', pos);
|
93 |
+
range.select();
|
94 |
+
}
|
95 |
+
}
|
96 |
+
} catch (e) {}
|
97 |
+
},
|
98 |
+
events: function() {
|
99 |
+
el
|
100 |
+
.on('keydown.mask', function(e) {
|
101 |
+
el.data('mask-keycode', e.keyCode || e.which);
|
102 |
+
el.data('mask-previus-value', el.val());
|
103 |
+
})
|
104 |
+
.on($.jMaskGlobals.useInput ? 'input.mask' : 'keyup.mask', p.behaviour)
|
105 |
+
.on('paste.mask drop.mask', function() {
|
106 |
+
setTimeout(function() {
|
107 |
+
el.keydown().keyup();
|
108 |
+
}, 100);
|
109 |
+
})
|
110 |
+
.on('change.mask', function(){
|
111 |
+
el.data('changed', true);
|
112 |
+
})
|
113 |
+
.on('blur.mask', function(){
|
114 |
+
if (oldValue !== p.val() && !el.data('changed')) {
|
115 |
+
el.trigger('change');
|
116 |
+
}
|
117 |
+
el.data('changed', false);
|
118 |
+
})
|
119 |
+
// it's very important that this callback remains in this position
|
120 |
+
// otherwhise oldValue it's going to work buggy
|
121 |
+
.on('blur.mask', function() {
|
122 |
+
oldValue = p.val();
|
123 |
+
})
|
124 |
+
// select all text on focus
|
125 |
+
.on('focus.mask', function (e) {
|
126 |
+
if (options.selectOnFocus === true) {
|
127 |
+
$(e.target).select();
|
128 |
+
}
|
129 |
+
})
|
130 |
+
// clear the value if it not complete the mask
|
131 |
+
.on('focusout.mask', function() {
|
132 |
+
if (options.clearIfNotMatch && !regexMask.test(p.val())) {
|
133 |
+
p.val('');
|
134 |
+
}
|
135 |
+
});
|
136 |
+
},
|
137 |
+
getRegexMask: function() {
|
138 |
+
var maskChunks = [], translation, pattern, optional, recursive, oRecursive, r;
|
139 |
+
|
140 |
+
for (var i = 0; i < mask.length; i++) {
|
141 |
+
translation = jMask.translation[mask.charAt(i)];
|
142 |
+
|
143 |
+
if (translation) {
|
144 |
+
|
145 |
+
pattern = translation.pattern.toString().replace(/.{1}$|^.{1}/g, '');
|
146 |
+
optional = translation.optional;
|
147 |
+
recursive = translation.recursive;
|
148 |
+
|
149 |
+
if (recursive) {
|
150 |
+
maskChunks.push(mask.charAt(i));
|
151 |
+
oRecursive = {digit: mask.charAt(i), pattern: pattern};
|
152 |
+
} else {
|
153 |
+
maskChunks.push(!optional && !recursive ? pattern : (pattern + '?'));
|
154 |
+
}
|
155 |
+
|
156 |
+
} else {
|
157 |
+
maskChunks.push(mask.charAt(i).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
r = maskChunks.join('');
|
162 |
+
|
163 |
+
if (oRecursive) {
|
164 |
+
r = r.replace(new RegExp('(' + oRecursive.digit + '(.*' + oRecursive.digit + ')?)'), '($1)?')
|
165 |
+
.replace(new RegExp(oRecursive.digit, 'g'), oRecursive.pattern);
|
166 |
+
}
|
167 |
+
|
168 |
+
return new RegExp(r);
|
169 |
+
},
|
170 |
+
destroyEvents: function() {
|
171 |
+
el.off(['input', 'keydown', 'keyup', 'paste', 'drop', 'blur', 'focusout', ''].join('.mask '));
|
172 |
+
},
|
173 |
+
val: function(v) {
|
174 |
+
var isInput = el.is('input'),
|
175 |
+
method = isInput ? 'val' : 'text',
|
176 |
+
r;
|
177 |
+
|
178 |
+
if (arguments.length > 0) {
|
179 |
+
if (el[method]() !== v) {
|
180 |
+
el[method](v);
|
181 |
+
}
|
182 |
+
r = el;
|
183 |
+
} else {
|
184 |
+
r = el[method]();
|
185 |
+
}
|
186 |
+
|
187 |
+
return r;
|
188 |
+
},
|
189 |
+
calculateCaretPosition: function(caretPos, newVal) {
|
190 |
+
var newValL = newVal.length,
|
191 |
+
oValue = el.data('mask-previus-value') || '',
|
192 |
+
oValueL = oValue.length;
|
193 |
+
|
194 |
+
// edge cases when erasing digits
|
195 |
+
if (el.data('mask-keycode') === 8 && oValue !== newVal) {
|
196 |
+
caretPos = caretPos - (newVal.slice(0, caretPos).length - oValue.slice(0, caretPos).length);
|
197 |
+
|
198 |
+
// edge cases when typing new digits
|
199 |
+
} else if (oValue !== newVal) {
|
200 |
+
// if the cursor is at the end keep it there
|
201 |
+
if (caretPos >= oValueL) {
|
202 |
+
caretPos = newValL;
|
203 |
+
} else {
|
204 |
+
caretPos = caretPos + (newVal.slice(0, caretPos).length - oValue.slice(0, caretPos).length);
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
return caretPos;
|
209 |
+
},
|
210 |
+
behaviour: function(e) {
|
211 |
+
e = e || window.event;
|
212 |
+
p.invalid = [];
|
213 |
+
|
214 |
+
var keyCode = el.data('mask-keycode');
|
215 |
+
|
216 |
+
if ($.inArray(keyCode, jMask.byPassKeys) === -1) {
|
217 |
+
var newVal = p.getMasked(),
|
218 |
+
caretPos = p.getCaret();
|
219 |
+
|
220 |
+
setTimeout(function(caretPos, newVal) {
|
221 |
+
p.setCaret(p.calculateCaretPosition(caretPos, newVal));
|
222 |
+
}, 10, caretPos, newVal);
|
223 |
+
|
224 |
+
p.val(newVal);
|
225 |
+
p.setCaret(caretPos);
|
226 |
+
return p.callbacks(e);
|
227 |
+
}
|
228 |
+
},
|
229 |
+
getMasked: function(skipMaskChars, val) {
|
230 |
+
var buf = [],
|
231 |
+
value = val === undefined ? p.val() : val + '',
|
232 |
+
m = 0, maskLen = mask.length,
|
233 |
+
v = 0, valLen = value.length,
|
234 |
+
offset = 1, addMethod = 'push',
|
235 |
+
resetPos = -1,
|
236 |
+
lastMaskChar,
|
237 |
+
check;
|
238 |
+
|
239 |
+
if (options.reverse) {
|
240 |
+
addMethod = 'unshift';
|
241 |
+
offset = -1;
|
242 |
+
lastMaskChar = 0;
|
243 |
+
m = maskLen - 1;
|
244 |
+
v = valLen - 1;
|
245 |
+
check = function () {
|
246 |
+
return m > -1 && v > -1;
|
247 |
+
};
|
248 |
+
} else {
|
249 |
+
lastMaskChar = maskLen - 1;
|
250 |
+
check = function () {
|
251 |
+
return m < maskLen && v < valLen;
|
252 |
+
};
|
253 |
+
}
|
254 |
+
|
255 |
+
var lastUntranslatedMaskChar;
|
256 |
+
while (check()) {
|
257 |
+
var maskDigit = mask.charAt(m),
|
258 |
+
valDigit = value.charAt(v),
|
259 |
+
translation = jMask.translation[maskDigit];
|
260 |
+
|
261 |
+
if (translation) {
|
262 |
+
if (valDigit.match(translation.pattern)) {
|
263 |
+
buf[addMethod](valDigit);
|
264 |
+
if (translation.recursive) {
|
265 |
+
if (resetPos === -1) {
|
266 |
+
resetPos = m;
|
267 |
+
} else if (m === lastMaskChar) {
|
268 |
+
m = resetPos - offset;
|
269 |
+
}
|
270 |
+
|
271 |
+
if (lastMaskChar === resetPos) {
|
272 |
+
m -= offset;
|
273 |
+
}
|
274 |
+
}
|
275 |
+
m += offset;
|
276 |
+
} else if (valDigit === lastUntranslatedMaskChar) {
|
277 |
+
// matched the last untranslated (raw) mask character that we encountered
|
278 |
+
// likely an insert offset the mask character from the last entry; fall
|
279 |
+
// through and only increment v
|
280 |
+
lastUntranslatedMaskChar = undefined;
|
281 |
+
} else if (translation.optional) {
|
282 |
+
m += offset;
|
283 |
+
v -= offset;
|
284 |
+
} else if (translation.fallback) {
|
285 |
+
buf[addMethod](translation.fallback);
|
286 |
+
m += offset;
|
287 |
+
v -= offset;
|
288 |
+
} else {
|
289 |
+
p.invalid.push({p: v, v: valDigit, e: translation.pattern});
|
290 |
+
}
|
291 |
+
v += offset;
|
292 |
+
} else {
|
293 |
+
if (!skipMaskChars) {
|
294 |
+
buf[addMethod](maskDigit);
|
295 |
+
}
|
296 |
+
|
297 |
+
if (valDigit === maskDigit) {
|
298 |
+
v += offset;
|
299 |
+
} else {
|
300 |
+
lastUntranslatedMaskChar = maskDigit;
|
301 |
+
}
|
302 |
+
|
303 |
+
m += offset;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
var lastMaskCharDigit = mask.charAt(lastMaskChar);
|
308 |
+
if (maskLen === valLen + 1 && !jMask.translation[lastMaskCharDigit]) {
|
309 |
+
buf.push(lastMaskCharDigit);
|
310 |
+
}
|
311 |
+
|
312 |
+
return buf.join('');
|
313 |
+
},
|
314 |
+
callbacks: function (e) {
|
315 |
+
var val = p.val(),
|
316 |
+
changed = val !== oldValue,
|
317 |
+
defaultArgs = [val, e, el, options],
|
318 |
+
callback = function(name, criteria, args) {
|
319 |
+
if (typeof options[name] === 'function' && criteria) {
|
320 |
+
options[name].apply(this, args);
|
321 |
+
}
|
322 |
+
};
|
323 |
+
|
324 |
+
callback('onChange', changed === true, defaultArgs);
|
325 |
+
callback('onKeyPress', changed === true, defaultArgs);
|
326 |
+
callback('onComplete', val.length === mask.length, defaultArgs);
|
327 |
+
callback('onInvalid', p.invalid.length > 0, [val, e, el, p.invalid, options]);
|
328 |
+
}
|
329 |
+
};
|
330 |
+
|
331 |
+
el = $(el);
|
332 |
+
var jMask = this, oldValue = p.val(), regexMask;
|
333 |
+
|
334 |
+
mask = typeof mask === 'function' ? mask(p.val(), undefined, el, options) : mask;
|
335 |
+
|
336 |
+
// public methods
|
337 |
+
jMask.mask = mask;
|
338 |
+
jMask.options = options;
|
339 |
+
jMask.remove = function() {
|
340 |
+
var caret = p.getCaret();
|
341 |
+
p.destroyEvents();
|
342 |
+
p.val(jMask.getCleanVal());
|
343 |
+
p.setCaret(caret);
|
344 |
+
return el;
|
345 |
+
};
|
346 |
+
|
347 |
+
// get value without mask
|
348 |
+
jMask.getCleanVal = function() {
|
349 |
+
return p.getMasked(true);
|
350 |
+
};
|
351 |
+
|
352 |
+
// get masked value without the value being in the input or element
|
353 |
+
jMask.getMaskedVal = function(val) {
|
354 |
+
return p.getMasked(false, val);
|
355 |
+
};
|
356 |
+
|
357 |
+
jMask.init = function(onlyMask) {
|
358 |
+
onlyMask = onlyMask || false;
|
359 |
+
options = options || {};
|
360 |
+
|
361 |
+
jMask.clearIfNotMatch = $.jMaskGlobals.clearIfNotMatch;
|
362 |
+
jMask.byPassKeys = $.jMaskGlobals.byPassKeys;
|
363 |
+
jMask.translation = $.extend({}, $.jMaskGlobals.translation, options.translation);
|
364 |
+
|
365 |
+
jMask = $.extend(true, {}, jMask, options);
|
366 |
+
|
367 |
+
regexMask = p.getRegexMask();
|
368 |
+
|
369 |
+
if (onlyMask) {
|
370 |
+
p.events();
|
371 |
+
p.val(p.getMasked());
|
372 |
+
} else {
|
373 |
+
if (options.placeholder) {
|
374 |
+
el.attr('placeholder' , options.placeholder);
|
375 |
+
}
|
376 |
+
|
377 |
+
// this is necessary, otherwise if the user submit the form
|
378 |
+
// and then press the "back" button, the autocomplete will erase
|
379 |
+
// the data. Works fine on IE9+, FF, Opera, Safari.
|
380 |
+
if (el.data('mask')) {
|
381 |
+
el.attr('autocomplete', 'off');
|
382 |
+
}
|
383 |
+
|
384 |
+
// detect if is necessary let the user type freely.
|
385 |
+
// for is a lot faster than forEach.
|
386 |
+
for (var i = 0, maxlength = true; i < mask.length; i++) {
|
387 |
+
var translation = jMask.translation[mask.charAt(i)];
|
388 |
+
if (translation && translation.recursive) {
|
389 |
+
maxlength = false;
|
390 |
+
break;
|
391 |
+
}
|
392 |
+
}
|
393 |
+
|
394 |
+
if (maxlength) {
|
395 |
+
el.attr('maxlength', mask.length);
|
396 |
+
}
|
397 |
+
|
398 |
+
p.destroyEvents();
|
399 |
+
p.events();
|
400 |
+
|
401 |
+
var caret = p.getCaret();
|
402 |
+
p.val(p.getMasked());
|
403 |
+
p.setCaret(caret);
|
404 |
+
}
|
405 |
+
};
|
406 |
+
|
407 |
+
jMask.init(!el.is('input'));
|
408 |
+
};
|
409 |
+
|
410 |
+
$.maskWatchers = {};
|
411 |
+
var HTMLAttributes = function () {
|
412 |
+
var input = $(this),
|
413 |
+
options = {},
|
414 |
+
prefix = 'data-mask-',
|
415 |
+
mask = input.attr('data-mask');
|
416 |
+
|
417 |
+
if (input.attr(prefix + 'reverse')) {
|
418 |
+
options.reverse = true;
|
419 |
+
}
|
420 |
+
|
421 |
+
if (input.attr(prefix + 'clearifnotmatch')) {
|
422 |
+
options.clearIfNotMatch = true;
|
423 |
+
}
|
424 |
+
|
425 |
+
if (input.attr(prefix + 'selectonfocus') === 'true') {
|
426 |
+
options.selectOnFocus = true;
|
427 |
+
}
|
428 |
+
|
429 |
+
if (notSameMaskObject(input, mask, options)) {
|
430 |
+
return input.data('mask', new Mask(this, mask, options));
|
431 |
+
}
|
432 |
+
},
|
433 |
+
notSameMaskObject = function(field, mask, options) {
|
434 |
+
options = options || {};
|
435 |
+
var maskObject = $(field).data('mask'),
|
436 |
+
stringify = JSON.stringify,
|
437 |
+
value = $(field).val() || $(field).text();
|
438 |
+
try {
|
439 |
+
if (typeof mask === 'function') {
|
440 |
+
mask = mask(value);
|
441 |
+
}
|
442 |
+
return typeof maskObject !== 'object' || stringify(maskObject.options) !== stringify(options) || maskObject.mask !== mask;
|
443 |
+
} catch (e) {}
|
444 |
+
},
|
445 |
+
eventSupported = function(eventName) {
|
446 |
+
var el = document.createElement('div'), isSupported;
|
447 |
+
|
448 |
+
eventName = 'on' + eventName;
|
449 |
+
isSupported = (eventName in el);
|
450 |
+
|
451 |
+
if ( !isSupported ) {
|
452 |
+
el.setAttribute(eventName, 'return;');
|
453 |
+
isSupported = typeof el[eventName] === 'function';
|
454 |
+
}
|
455 |
+
el = null;
|
456 |
+
|
457 |
+
return isSupported;
|
458 |
+
};
|
459 |
+
|
460 |
+
$.fn.mask = function(mask, options) {
|
461 |
+
options = options || {};
|
462 |
+
var selector = this.selector,
|
463 |
+
globals = $.jMaskGlobals,
|
464 |
+
interval = globals.watchInterval,
|
465 |
+
watchInputs = options.watchInputs || globals.watchInputs,
|
466 |
+
maskFunction = function() {
|
467 |
+
if (notSameMaskObject(this, mask, options)) {
|
468 |
+
return $(this).data('mask', new Mask(this, mask, options));
|
469 |
+
}
|
470 |
+
};
|
471 |
+
|
472 |
+
$(this).each(maskFunction);
|
473 |
+
|
474 |
+
if (selector && selector !== '' && watchInputs) {
|
475 |
+
clearInterval($.maskWatchers[selector]);
|
476 |
+
$.maskWatchers[selector] = setInterval(function(){
|
477 |
+
$(document).find(selector).each(maskFunction);
|
478 |
+
}, interval);
|
479 |
+
}
|
480 |
+
return this;
|
481 |
+
};
|
482 |
+
|
483 |
+
$.fn.masked = function(val) {
|
484 |
+
return this.data('mask').getMaskedVal(val);
|
485 |
+
};
|
486 |
+
|
487 |
+
$.fn.unmask = function() {
|
488 |
+
clearInterval($.maskWatchers[this.selector]);
|
489 |
+
delete $.maskWatchers[this.selector];
|
490 |
+
return this.each(function() {
|
491 |
+
var dataMask = $(this).data('mask');
|
492 |
+
if (dataMask) {
|
493 |
+
dataMask.remove().removeData('mask');
|
494 |
+
}
|
495 |
+
});
|
496 |
+
};
|
497 |
+
|
498 |
+
$.fn.cleanVal = function() {
|
499 |
+
return this.data('mask').getCleanVal();
|
500 |
+
};
|
501 |
+
|
502 |
+
$.applyDataMask = function(selector) {
|
503 |
+
selector = selector || $.jMaskGlobals.maskElements;
|
504 |
+
var $selector = (selector instanceof $) ? selector : $(selector);
|
505 |
+
$selector.filter($.jMaskGlobals.dataMaskAttr).each(HTMLAttributes);
|
506 |
+
};
|
507 |
+
|
508 |
+
var globals = {
|
509 |
+
maskElements: 'input,td,span,div',
|
510 |
+
dataMaskAttr: '*[data-mask]',
|
511 |
+
dataMask: true,
|
512 |
+
watchInterval: 300,
|
513 |
+
watchInputs: true,
|
514 |
+
// old versions of chrome dont work great with input event
|
515 |
+
useInput: !/Chrome\/[2-4][0-9]|SamsungBrowser/.test(window.navigator.userAgent) && eventSupported('input'),
|
516 |
+
watchDataMask: false,
|
517 |
+
byPassKeys: [9, 16, 17, 18, 36, 37, 38, 39, 40, 91],
|
518 |
+
translation: {
|
519 |
+
'0': {pattern: /\d/},
|
520 |
+
'9': {pattern: /\d/, optional: true},
|
521 |
+
'#': {pattern: /\d/, recursive: true},
|
522 |
+
'A': {pattern: /[a-zA-Z0-9]/},
|
523 |
+
'S': {pattern: /[a-zA-Z]/}
|
524 |
+
}
|
525 |
+
};
|
526 |
+
|
527 |
+
$.jMaskGlobals = $.jMaskGlobals || {};
|
528 |
+
globals = $.jMaskGlobals = $.extend(true, {}, globals, $.jMaskGlobals);
|
529 |
+
|
530 |
+
// looking for inputs with data-mask attribute
|
531 |
+
if (globals.dataMask) {
|
532 |
+
$.applyDataMask();
|
533 |
+
}
|
534 |
+
|
535 |
+
setInterval(function() {
|
536 |
+
if ($.jMaskGlobals.watchDataMask) {
|
537 |
+
$.applyDataMask();
|
538 |
+
}
|
539 |
+
}, globals.watchInterval);
|
540 |
+
}, window.jQuery, window.Zepto));
|
assets/js/jquery.mask/jquery.mask.min.js
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// jQuery Mask Plugin v1.14.10
|
2 |
+
// github.com/igorescobar/jQuery-Mask-Plugin
|
3 |
+
var $jscomp={scope:{},findInternal:function(a,f,c){a instanceof String&&(a=String(a));for(var l=a.length,g=0;g<l;g++){var b=a[g];if(f.call(c,b,g,a))return{i:g,v:b}}return{i:-1,v:void 0}}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,f,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[f]=c.value)};
|
4 |
+
$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(a,f,c,l){if(f){c=$jscomp.global;a=a.split(".");for(l=0;l<a.length-1;l++){var g=a[l];g in c||(c[g]={});c=c[g]}a=a[a.length-1];l=c[a];f=f(l);f!=l&&null!=f&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:f})}};
|
5 |
+
$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,c){return $jscomp.findInternal(this,a,c).v}},"es6-impl","es3");
|
6 |
+
(function(a,f,c){"function"===typeof define&&define.amd?define(["jquery"],a):"object"===typeof exports?module.exports=a(require("jquery")):a(f||c)})(function(a){var f=function(b,h,e){var d={invalid:[],getCaret:function(){try{var a,n=0,h=b.get(0),e=document.selection,k=h.selectionStart;if(e&&-1===navigator.appVersion.indexOf("MSIE 10"))a=e.createRange(),a.moveStart("character",-d.val().length),n=a.text.length;else if(k||"0"===k)n=k;return n}catch(A){}},setCaret:function(a){try{if(b.is(":focus")){var p,
|
7 |
+
d=b.get(0);d.setSelectionRange?d.setSelectionRange(a,a):(p=d.createTextRange(),p.collapse(!0),p.moveEnd("character",a),p.moveStart("character",a),p.select())}}catch(z){}},events:function(){b.on("keydown.mask",function(a){b.data("mask-keycode",a.keyCode||a.which);b.data("mask-previus-value",b.val())}).on(a.jMaskGlobals.useInput?"input.mask":"keyup.mask",d.behaviour).on("paste.mask drop.mask",function(){setTimeout(function(){b.keydown().keyup()},100)}).on("change.mask",function(){b.data("changed",!0)}).on("blur.mask",
|
8 |
+
function(){c===d.val()||b.data("changed")||b.trigger("change");b.data("changed",!1)}).on("blur.mask",function(){c=d.val()}).on("focus.mask",function(b){!0===e.selectOnFocus&&a(b.target).select()}).on("focusout.mask",function(){e.clearIfNotMatch&&!g.test(d.val())&&d.val("")})},getRegexMask:function(){for(var a=[],b,d,e,k,c=0;c<h.length;c++)(b=m.translation[h.charAt(c)])?(d=b.pattern.toString().replace(/.{1}$|^.{1}/g,""),e=b.optional,(b=b.recursive)?(a.push(h.charAt(c)),k={digit:h.charAt(c),pattern:d}):
|
9 |
+
a.push(e||b?d+"?":d)):a.push(h.charAt(c).replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"));a=a.join("");k&&(a=a.replace(new RegExp("("+k.digit+"(.*"+k.digit+")?)"),"($1)?").replace(new RegExp(k.digit,"g"),k.pattern));return new RegExp(a)},destroyEvents:function(){b.off("input keydown keyup paste drop blur focusout ".split(" ").join(".mask "))},val:function(a){var d=b.is("input")?"val":"text";if(0<arguments.length){if(b[d]()!==a)b[d](a);d=b}else d=b[d]();return d},calculateCaretPosition:function(a,d){var h=
|
10 |
+
d.length,e=b.data("mask-previus-value")||"",k=e.length;8===b.data("mask-keycode")&&e!==d?a-=d.slice(0,a).length-e.slice(0,a).length:e!==d&&(a=a>=k?h:a+(d.slice(0,a).length-e.slice(0,a).length));return a},behaviour:function(e){e=e||window.event;d.invalid=[];var h=b.data("mask-keycode");if(-1===a.inArray(h,m.byPassKeys)){var h=d.getMasked(),c=d.getCaret();setTimeout(function(a,b){d.setCaret(d.calculateCaretPosition(a,b))},10,c,h);d.val(h);d.setCaret(c);return d.callbacks(e)}},getMasked:function(a,b){var c=
|
11 |
+
[],p=void 0===b?d.val():b+"",k=0,g=h.length,f=0,l=p.length,n=1,v="push",w=-1,r,u;e.reverse?(v="unshift",n=-1,r=0,k=g-1,f=l-1,u=function(){return-1<k&&-1<f}):(r=g-1,u=function(){return k<g&&f<l});for(var y;u();){var x=h.charAt(k),t=p.charAt(f),q=m.translation[x];if(q)t.match(q.pattern)?(c[v](t),q.recursive&&(-1===w?w=k:k===r&&(k=w-n),r===w&&(k-=n)),k+=n):t===y?y=void 0:q.optional?(k+=n,f-=n):q.fallback?(c[v](q.fallback),k+=n,f-=n):d.invalid.push({p:f,v:t,e:q.pattern}),f+=n;else{if(!a)c[v](x);t===x?
|
12 |
+
f+=n:y=x;k+=n}}p=h.charAt(r);g!==l+1||m.translation[p]||c.push(p);return c.join("")},callbacks:function(a){var f=d.val(),p=f!==c,g=[f,a,b,e],k=function(a,b,d){"function"===typeof e[a]&&b&&e[a].apply(this,d)};k("onChange",!0===p,g);k("onKeyPress",!0===p,g);k("onComplete",f.length===h.length,g);k("onInvalid",0<d.invalid.length,[f,a,b,d.invalid,e])}};b=a(b);var m=this,c=d.val(),g;h="function"===typeof h?h(d.val(),void 0,b,e):h;m.mask=h;m.options=e;m.remove=function(){var a=d.getCaret();d.destroyEvents();
|
13 |
+
d.val(m.getCleanVal());d.setCaret(a);return b};m.getCleanVal=function(){return d.getMasked(!0)};m.getMaskedVal=function(a){return d.getMasked(!1,a)};m.init=function(c){c=c||!1;e=e||{};m.clearIfNotMatch=a.jMaskGlobals.clearIfNotMatch;m.byPassKeys=a.jMaskGlobals.byPassKeys;m.translation=a.extend({},a.jMaskGlobals.translation,e.translation);m=a.extend(!0,{},m,e);g=d.getRegexMask();if(c)d.events(),d.val(d.getMasked());else{e.placeholder&&b.attr("placeholder",e.placeholder);b.data("mask")&&b.attr("autocomplete",
|
14 |
+
"off");c=0;for(var f=!0;c<h.length;c++){var l=m.translation[h.charAt(c)];if(l&&l.recursive){f=!1;break}}f&&b.attr("maxlength",h.length);d.destroyEvents();d.events();c=d.getCaret();d.val(d.getMasked());d.setCaret(c)}};m.init(!b.is("input"))};a.maskWatchers={};var c=function(){var b=a(this),c={},e=b.attr("data-mask");b.attr("data-mask-reverse")&&(c.reverse=!0);b.attr("data-mask-clearifnotmatch")&&(c.clearIfNotMatch=!0);"true"===b.attr("data-mask-selectonfocus")&&(c.selectOnFocus=!0);if(l(b,e,c))return b.data("mask",
|
15 |
+
new f(this,e,c))},l=function(b,c,e){e=e||{};var d=a(b).data("mask"),h=JSON.stringify;b=a(b).val()||a(b).text();try{return"function"===typeof c&&(c=c(b)),"object"!==typeof d||h(d.options)!==h(e)||d.mask!==c}catch(u){}},g=function(a){var b=document.createElement("div"),c;a="on"+a;c=a in b;c||(b.setAttribute(a,"return;"),c="function"===typeof b[a]);return c};a.fn.mask=function(b,c){c=c||{};var e=this.selector,d=a.jMaskGlobals,h=d.watchInterval,d=c.watchInputs||d.watchInputs,g=function(){if(l(this,b,
|
16 |
+
c))return a(this).data("mask",new f(this,b,c))};a(this).each(g);e&&""!==e&&d&&(clearInterval(a.maskWatchers[e]),a.maskWatchers[e]=setInterval(function(){a(document).find(e).each(g)},h));return this};a.fn.masked=function(a){return this.data("mask").getMaskedVal(a)};a.fn.unmask=function(){clearInterval(a.maskWatchers[this.selector]);delete a.maskWatchers[this.selector];return this.each(function(){var b=a(this).data("mask");b&&b.remove().removeData("mask")})};a.fn.cleanVal=function(){return this.data("mask").getCleanVal()};
|
17 |
+
a.applyDataMask=function(b){b=b||a.jMaskGlobals.maskElements;(b instanceof a?b:a(b)).filter(a.jMaskGlobals.dataMaskAttr).each(c)};g={maskElements:"input,td,span,div",dataMaskAttr:"*[data-mask]",dataMask:!0,watchInterval:300,watchInputs:!0,useInput:!/Chrome\/[2-4][0-9]|SamsungBrowser/.test(window.navigator.userAgent)&&g("input"),watchDataMask:!1,byPassKeys:[9,16,17,18,36,37,38,39,40,91],translation:{0:{pattern:/\d/},9:{pattern:/\d/,optional:!0},"#":{pattern:/\d/,recursive:!0},A:{pattern:/[a-zA-Z0-9]/},
|
18 |
+
S:{pattern:/[a-zA-Z]/}}};a.jMaskGlobals=a.jMaskGlobals||{};g=a.jMaskGlobals=a.extend(!0,{},g,a.jMaskGlobals);g.dataMask&&a.applyDataMask();setInterval(function(){a.jMaskGlobals.watchDataMask&&a.applyDataMask()},g.watchInterval)},window.jQuery,window.Zepto);
|
includes/admin/{class-wc-ecfb-admin.php → class-extra-checkout-fields-for-brazil-admin.php}
RENAMED
@@ -1,10 +1,16 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
exit; // Exit if accessed directly.
|
4 |
}
|
5 |
|
6 |
/**
|
7 |
-
*
|
8 |
*/
|
9 |
class Extra_Checkout_Fields_For_Brazil_Admin {
|
10 |
|
@@ -25,7 +31,7 @@ class Extra_Checkout_Fields_For_Brazil_Admin {
|
|
25 |
$screen = get_current_screen();
|
26 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
27 |
|
28 |
-
if ( 'shop_order'
|
29 |
// Get plugin settings.
|
30 |
$settings = get_option( 'wcbcf_settings' );
|
31 |
|
@@ -33,7 +39,7 @@ class Extra_Checkout_Fields_For_Brazil_Admin {
|
|
33 |
wp_enqueue_style( 'woocommerce-extra-checkout-fields-for-brazil-admin', Extra_Checkout_Fields_For_Brazil::get_assets_url() . 'css/admin/admin.css', array(), Extra_Checkout_Fields_For_Brazil::VERSION );
|
34 |
|
35 |
// Shop order.
|
36 |
-
wp_enqueue_script( 'woocommerce-extra-checkout-fields-for-brazil-shop-order', Extra_Checkout_Fields_For_Brazil::get_assets_url() . 'js/admin/shop-order' . $suffix .'.js', array( 'jquery' ), Extra_Checkout_Fields_For_Brazil::VERSION, true );
|
37 |
|
38 |
// Localize strings.
|
39 |
wp_localize_script(
|
@@ -42,13 +48,14 @@ class Extra_Checkout_Fields_For_Brazil_Admin {
|
|
42 |
array(
|
43 |
'load_message' => esc_js( __( 'Load the customer extras data?', 'woocommerce-extra-checkout-fields-for-brazil' ) ),
|
44 |
'copy_message' => esc_js( __( 'Also copy the data of number and neighborhood?', 'woocommerce-extra-checkout-fields-for-brazil' ) ),
|
45 |
-
'person_type' => absint( $settings['person_type'] )
|
46 |
)
|
47 |
);
|
48 |
}
|
49 |
|
50 |
-
if ( 'woocommerce_page_woocommerce-extra-checkout-fields-for-brazil'
|
51 |
-
|
|
|
52 |
}
|
53 |
}
|
54 |
|
@@ -56,7 +63,9 @@ class Extra_Checkout_Fields_For_Brazil_Admin {
|
|
56 |
* Maybe install.
|
57 |
*/
|
58 |
public function maybe_install() {
|
59 |
-
|
|
|
|
|
60 |
if ( version_compare( $version, Extra_Checkout_Fields_For_Brazil::VERSION, '<' ) ) {
|
61 |
$options = get_option( 'wcbcf_settings' );
|
62 |
|
@@ -75,16 +84,12 @@ class Extra_Checkout_Fields_For_Brazil_Admin {
|
|
75 |
} else {
|
76 |
$default = array(
|
77 |
'person_type' => 1,
|
78 |
-
// 'only_brazil' => 0,
|
79 |
-
// 'ie' => 0,
|
80 |
-
// 'rg' => 0,
|
81 |
-
// 'birthdate_sex' => 0,
|
82 |
'cell_phone' => 1,
|
83 |
'mailcheck' => 1,
|
84 |
'maskedinput' => 1,
|
85 |
'addresscomplete' => 1,
|
86 |
'validate_cpf' => 1,
|
87 |
-
'validate_cnpj' => 1
|
88 |
);
|
89 |
|
90 |
add_option( 'wcbcf_settings', $default );
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Extra checkout fields admin.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Admin
|
6 |
+
*/
|
7 |
+
|
8 |
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
exit; // Exit if accessed directly.
|
10 |
}
|
11 |
|
12 |
/**
|
13 |
+
* Extra_Checkout_Fields_For_Brazil_Admin class.
|
14 |
*/
|
15 |
class Extra_Checkout_Fields_For_Brazil_Admin {
|
16 |
|
31 |
$screen = get_current_screen();
|
32 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
33 |
|
34 |
+
if ( 'shop_order' === $screen->id ) {
|
35 |
// Get plugin settings.
|
36 |
$settings = get_option( 'wcbcf_settings' );
|
37 |
|
39 |
wp_enqueue_style( 'woocommerce-extra-checkout-fields-for-brazil-admin', Extra_Checkout_Fields_For_Brazil::get_assets_url() . 'css/admin/admin.css', array(), Extra_Checkout_Fields_For_Brazil::VERSION );
|
40 |
|
41 |
// Shop order.
|
42 |
+
wp_enqueue_script( 'woocommerce-extra-checkout-fields-for-brazil-shop-order', Extra_Checkout_Fields_For_Brazil::get_assets_url() . 'js/admin/shop-order' . $suffix . '.js', array( 'jquery' ), Extra_Checkout_Fields_For_Brazil::VERSION, true );
|
43 |
|
44 |
// Localize strings.
|
45 |
wp_localize_script(
|
48 |
array(
|
49 |
'load_message' => esc_js( __( 'Load the customer extras data?', 'woocommerce-extra-checkout-fields-for-brazil' ) ),
|
50 |
'copy_message' => esc_js( __( 'Also copy the data of number and neighborhood?', 'woocommerce-extra-checkout-fields-for-brazil' ) ),
|
51 |
+
'person_type' => absint( $settings['person_type'] ),
|
52 |
)
|
53 |
);
|
54 |
}
|
55 |
|
56 |
+
if ( 'woocommerce_page_woocommerce-extra-checkout-fields-for-brazil' === $screen->id ) {
|
57 |
+
wp_enqueue_style( 'woocommerce-extra-checkout-fields-for-brazil-settings', Extra_Checkout_Fields_For_Brazil::get_assets_url() . 'css/admin/settings.css', array(), Extra_Checkout_Fields_For_Brazil::VERSION );
|
58 |
+
wp_enqueue_script( 'woocommerce-extra-checkout-fields-for-brazil-admin', Extra_Checkout_Fields_For_Brazil::get_assets_url() . 'js/admin/admin' . $suffix . '.js', array( 'jquery' ), Extra_Checkout_Fields_For_Brazil::VERSION );
|
59 |
}
|
60 |
}
|
61 |
|
63 |
* Maybe install.
|
64 |
*/
|
65 |
public function maybe_install() {
|
66 |
+
$version = get_option( 'wcbcf_version' );
|
67 |
+
|
68 |
+
if ( $version ) {
|
69 |
if ( version_compare( $version, Extra_Checkout_Fields_For_Brazil::VERSION, '<' ) ) {
|
70 |
$options = get_option( 'wcbcf_settings' );
|
71 |
|
84 |
} else {
|
85 |
$default = array(
|
86 |
'person_type' => 1,
|
|
|
|
|
|
|
|
|
87 |
'cell_phone' => 1,
|
88 |
'mailcheck' => 1,
|
89 |
'maskedinput' => 1,
|
90 |
'addresscomplete' => 1,
|
91 |
'validate_cpf' => 1,
|
92 |
+
'validate_cnpj' => 1,
|
93 |
);
|
94 |
|
95 |
add_option( 'wcbcf_settings', $default );
|
includes/admin/{class-wc-ecfb-customer.php → class-extra-checkout-fields-for-brazil-customer.php}
RENAMED
@@ -1,10 +1,16 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
exit; // Exit if accessed directly.
|
4 |
}
|
5 |
|
6 |
/**
|
7 |
-
*
|
8 |
*/
|
9 |
class Extra_Checkout_Fields_For_Brazil_Customer {
|
10 |
|
@@ -26,40 +32,41 @@ class Extra_Checkout_Fields_For_Brazil_Customer {
|
|
26 |
*/
|
27 |
public function customer_meta_fields( $fields ) {
|
28 |
// Get plugin settings.
|
29 |
-
$settings
|
|
|
30 |
|
31 |
// Billing fields.
|
32 |
$new_fields['billing']['title'] = __( 'Customer Billing Address', 'woocommerce-extra-checkout-fields-for-brazil' );
|
33 |
$new_fields['billing']['fields']['billing_first_name'] = $fields['billing']['fields']['billing_first_name'];
|
34 |
$new_fields['billing']['fields']['billing_last_name'] = $fields['billing']['fields']['billing_last_name'];
|
35 |
|
36 |
-
if ( 0
|
37 |
|
38 |
-
if ( 1
|
39 |
$new_fields['billing']['fields']['billing_cpf'] = array(
|
40 |
-
'label'
|
41 |
-
'description' => ''
|
42 |
);
|
43 |
|
44 |
if ( isset( $settings['rg'] ) ) {
|
45 |
$new_fields['billing']['fields']['billing_rg'] = array(
|
46 |
-
'label'
|
47 |
-
'description' => ''
|
48 |
);
|
49 |
}
|
50 |
}
|
51 |
|
52 |
-
if ( 1
|
53 |
$new_fields['billing']['fields']['billing_company'] = $fields['billing']['fields']['billing_company'];
|
54 |
$new_fields['billing']['fields']['billing_cnpj'] = array(
|
55 |
-
'label'
|
56 |
-
'description' => ''
|
57 |
);
|
58 |
|
59 |
if ( isset( $settings['ie'] ) ) {
|
60 |
$new_fields['billing']['fields']['billing_ie'] = array(
|
61 |
-
'label'
|
62 |
-
'description' => ''
|
63 |
);
|
64 |
}
|
65 |
}
|
@@ -69,24 +76,24 @@ class Extra_Checkout_Fields_For_Brazil_Customer {
|
|
69 |
|
70 |
if ( isset( $settings['birthdate_sex'] ) ) {
|
71 |
$new_fields['billing']['fields']['billing_birthdate'] = array(
|
72 |
-
'label'
|
73 |
-
'description' => ''
|
74 |
);
|
75 |
$new_fields['billing']['fields']['billing_sex'] = array(
|
76 |
-
'label'
|
77 |
-
'description' => ''
|
78 |
);
|
79 |
}
|
80 |
|
81 |
$new_fields['billing']['fields']['billing_address_1'] = $fields['billing']['fields']['billing_address_1'];
|
82 |
$new_fields['billing']['fields']['billing_number'] = array(
|
83 |
-
'label'
|
84 |
-
'description' => ''
|
85 |
);
|
86 |
$new_fields['billing']['fields']['billing_address_2'] = $fields['billing']['fields']['billing_address_2'];
|
87 |
$new_fields['billing']['fields']['billing_neighborhood'] = array(
|
88 |
-
'label'
|
89 |
-
'description' => ''
|
90 |
);
|
91 |
$new_fields['billing']['fields']['billing_city'] = $fields['billing']['fields']['billing_city'];
|
92 |
$new_fields['billing']['fields']['billing_postcode'] = $fields['billing']['fields']['billing_postcode'];
|
@@ -96,8 +103,8 @@ class Extra_Checkout_Fields_For_Brazil_Customer {
|
|
96 |
|
97 |
if ( isset( $settings['cell_phone'] ) ) {
|
98 |
$new_fields['billing']['fields']['billing_cellphone'] = array(
|
99 |
-
'label'
|
100 |
-
'description' => ''
|
101 |
);
|
102 |
}
|
103 |
|
@@ -110,13 +117,13 @@ class Extra_Checkout_Fields_For_Brazil_Customer {
|
|
110 |
$new_fields['shipping']['fields']['shipping_company'] = $fields['shipping']['fields']['shipping_company'];
|
111 |
$new_fields['shipping']['fields']['shipping_address_1'] = $fields['shipping']['fields']['shipping_address_1'];
|
112 |
$new_fields['shipping']['fields']['shipping_number'] = array(
|
113 |
-
'label'
|
114 |
-
'description' => ''
|
115 |
);
|
116 |
$new_fields['shipping']['fields']['shipping_address_2'] = $fields['shipping']['fields']['shipping_address_2'];
|
117 |
$new_fields['shipping']['fields']['shipping_neighborhood'] = array(
|
118 |
-
'label'
|
119 |
-
'description' => ''
|
120 |
);
|
121 |
$new_fields['shipping']['fields']['shipping_city'] = $fields['shipping']['fields']['shipping_city'];
|
122 |
$new_fields['shipping']['fields']['shipping_postcode'] = $fields['shipping']['fields']['shipping_postcode'];
|
@@ -132,7 +139,7 @@ class Extra_Checkout_Fields_For_Brazil_Customer {
|
|
132 |
* Custom user column billing address information.
|
133 |
*
|
134 |
* @param array $address Default address.
|
135 |
-
* @param int
|
136 |
*
|
137 |
* @return array New address format.
|
138 |
*/
|
@@ -147,7 +154,7 @@ class Extra_Checkout_Fields_For_Brazil_Customer {
|
|
147 |
* Custom user column shipping address information.
|
148 |
*
|
149 |
* @param array $address Default address.
|
150 |
-
* @param int
|
151 |
*
|
152 |
* @return array New address format.
|
153 |
*/
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Extra checkout fields customer admin.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Admin/Customer
|
6 |
+
*/
|
7 |
+
|
8 |
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
exit; // Exit if accessed directly.
|
10 |
}
|
11 |
|
12 |
/**
|
13 |
+
* Extra_Checkout_Fields_For_Brazil_Customer class.
|
14 |
*/
|
15 |
class Extra_Checkout_Fields_For_Brazil_Customer {
|
16 |
|
32 |
*/
|
33 |
public function customer_meta_fields( $fields ) {
|
34 |
// Get plugin settings.
|
35 |
+
$settings = get_option( 'wcbcf_settings' );
|
36 |
+
$person_type = intval( $settings['person_type'] );
|
37 |
|
38 |
// Billing fields.
|
39 |
$new_fields['billing']['title'] = __( 'Customer Billing Address', 'woocommerce-extra-checkout-fields-for-brazil' );
|
40 |
$new_fields['billing']['fields']['billing_first_name'] = $fields['billing']['fields']['billing_first_name'];
|
41 |
$new_fields['billing']['fields']['billing_last_name'] = $fields['billing']['fields']['billing_last_name'];
|
42 |
|
43 |
+
if ( 0 !== $person_type ) {
|
44 |
|
45 |
+
if ( 1 === $person_type || 2 === $person_type ) {
|
46 |
$new_fields['billing']['fields']['billing_cpf'] = array(
|
47 |
+
'label' => __( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
48 |
+
'description' => '',
|
49 |
);
|
50 |
|
51 |
if ( isset( $settings['rg'] ) ) {
|
52 |
$new_fields['billing']['fields']['billing_rg'] = array(
|
53 |
+
'label' => __( 'RG', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
54 |
+
'description' => '',
|
55 |
);
|
56 |
}
|
57 |
}
|
58 |
|
59 |
+
if ( 1 === $person_type || 3 === $person_type ) {
|
60 |
$new_fields['billing']['fields']['billing_company'] = $fields['billing']['fields']['billing_company'];
|
61 |
$new_fields['billing']['fields']['billing_cnpj'] = array(
|
62 |
+
'label' => __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
63 |
+
'description' => '',
|
64 |
);
|
65 |
|
66 |
if ( isset( $settings['ie'] ) ) {
|
67 |
$new_fields['billing']['fields']['billing_ie'] = array(
|
68 |
+
'label' => __( 'State Registration', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
69 |
+
'description' => '',
|
70 |
);
|
71 |
}
|
72 |
}
|
76 |
|
77 |
if ( isset( $settings['birthdate_sex'] ) ) {
|
78 |
$new_fields['billing']['fields']['billing_birthdate'] = array(
|
79 |
+
'label' => __( 'Birthdate', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
80 |
+
'description' => '',
|
81 |
);
|
82 |
$new_fields['billing']['fields']['billing_sex'] = array(
|
83 |
+
'label' => __( 'Sex', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
84 |
+
'description' => '',
|
85 |
);
|
86 |
}
|
87 |
|
88 |
$new_fields['billing']['fields']['billing_address_1'] = $fields['billing']['fields']['billing_address_1'];
|
89 |
$new_fields['billing']['fields']['billing_number'] = array(
|
90 |
+
'label' => __( 'Number', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
91 |
+
'description' => '',
|
92 |
);
|
93 |
$new_fields['billing']['fields']['billing_address_2'] = $fields['billing']['fields']['billing_address_2'];
|
94 |
$new_fields['billing']['fields']['billing_neighborhood'] = array(
|
95 |
+
'label' => __( 'Neighborhood', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
96 |
+
'description' => '',
|
97 |
);
|
98 |
$new_fields['billing']['fields']['billing_city'] = $fields['billing']['fields']['billing_city'];
|
99 |
$new_fields['billing']['fields']['billing_postcode'] = $fields['billing']['fields']['billing_postcode'];
|
103 |
|
104 |
if ( isset( $settings['cell_phone'] ) ) {
|
105 |
$new_fields['billing']['fields']['billing_cellphone'] = array(
|
106 |
+
'label' => __( 'Cell Phone', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
107 |
+
'description' => '',
|
108 |
);
|
109 |
}
|
110 |
|
117 |
$new_fields['shipping']['fields']['shipping_company'] = $fields['shipping']['fields']['shipping_company'];
|
118 |
$new_fields['shipping']['fields']['shipping_address_1'] = $fields['shipping']['fields']['shipping_address_1'];
|
119 |
$new_fields['shipping']['fields']['shipping_number'] = array(
|
120 |
+
'label' => __( 'Number', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
121 |
+
'description' => '',
|
122 |
);
|
123 |
$new_fields['shipping']['fields']['shipping_address_2'] = $fields['shipping']['fields']['shipping_address_2'];
|
124 |
$new_fields['shipping']['fields']['shipping_neighborhood'] = array(
|
125 |
+
'label' => __( 'Neighborhood', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
126 |
+
'description' => '',
|
127 |
);
|
128 |
$new_fields['shipping']['fields']['shipping_city'] = $fields['shipping']['fields']['shipping_city'];
|
129 |
$new_fields['shipping']['fields']['shipping_postcode'] = $fields['shipping']['fields']['shipping_postcode'];
|
139 |
* Custom user column billing address information.
|
140 |
*
|
141 |
* @param array $address Default address.
|
142 |
+
* @param int $user_id User id.
|
143 |
*
|
144 |
* @return array New address format.
|
145 |
*/
|
154 |
* Custom user column shipping address information.
|
155 |
*
|
156 |
* @param array $address Default address.
|
157 |
+
* @param int $user_id User id.
|
158 |
*
|
159 |
* @return array New address format.
|
160 |
*/
|
includes/admin/class-extra-checkout-fields-for-brazil-order.php
ADDED
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Extra checkout fields order admin.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Admin/Order
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly.
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Extra_Checkout_Fields_For_Brazil_Order class.
|
14 |
+
*/
|
15 |
+
class Extra_Checkout_Fields_For_Brazil_Order {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Initialize the order actions.
|
19 |
+
*/
|
20 |
+
public function __construct() {
|
21 |
+
add_filter( 'woocommerce_admin_billing_fields', array( $this, 'shop_order_billing_fields' ) );
|
22 |
+
add_filter( 'woocommerce_admin_shipping_fields', array( $this, 'shop_order_shipping_fields' ) );
|
23 |
+
|
24 |
+
// Before WooCommerce 3.0.
|
25 |
+
if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
|
26 |
+
add_filter( 'woocommerce_found_customer_details', array( $this, 'customer_details_ajax' ) );
|
27 |
+
} else {
|
28 |
+
add_filter( 'woocommerce_ajax_get_customer_details', array( $this, 'ajax_get_customer_details' ), 10, 2 );
|
29 |
+
}
|
30 |
+
|
31 |
+
add_action( 'woocommerce_admin_order_data_after_billing_address', array( $this, 'order_data_after_billing_address' ) );
|
32 |
+
add_action( 'woocommerce_process_shop_order_meta', array( $this, 'save_custom_shop_data' ) );
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Custom shop order billing fields.
|
37 |
+
*
|
38 |
+
* @param array $data Default order billing fields.
|
39 |
+
*
|
40 |
+
* @return array Custom order billing fields.
|
41 |
+
*/
|
42 |
+
public function shop_order_billing_fields( $data ) {
|
43 |
+
// Get plugin settings.
|
44 |
+
$settings = get_option( 'wcbcf_settings' );
|
45 |
+
$person_type = intval( $settings['person_type'] );
|
46 |
+
|
47 |
+
$billing_data['first_name'] = $data['first_name'];
|
48 |
+
$billing_data['last_name'] = $data['last_name'];
|
49 |
+
|
50 |
+
if ( 0 !== $person_type ) {
|
51 |
+
if ( 1 === $person_type ) {
|
52 |
+
$billing_data['persontype'] = array(
|
53 |
+
'type' => 'select',
|
54 |
+
'label' => __( 'Person type', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
55 |
+
'show' => false,
|
56 |
+
'options' => array(
|
57 |
+
'0' => __( 'Select', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
58 |
+
'1' => __( 'Individuals', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
59 |
+
'2' => __( 'Legal Person', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
60 |
+
),
|
61 |
+
);
|
62 |
+
}
|
63 |
+
|
64 |
+
if ( 1 === $person_type || 2 === $person_type ) {
|
65 |
+
$billing_data['cpf'] = array(
|
66 |
+
'label' => __( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
67 |
+
'show' => false,
|
68 |
+
);
|
69 |
+
if ( isset( $settings['rg'] ) ) {
|
70 |
+
$billing_data['rg'] = array(
|
71 |
+
'label' => __( 'RG', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
72 |
+
'show' => false,
|
73 |
+
);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
if ( 1 === $person_type || 3 === $person_type ) {
|
78 |
+
$billing_data['company'] = array(
|
79 |
+
'label' => __( 'Company Name', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
80 |
+
'show' => false,
|
81 |
+
);
|
82 |
+
$billing_data['cnpj'] = array(
|
83 |
+
'label' => __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
84 |
+
'show' => false,
|
85 |
+
);
|
86 |
+
if ( isset( $settings['ie'] ) ) {
|
87 |
+
$billing_data['ie'] = array(
|
88 |
+
'label' => __( 'State Registration', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
89 |
+
'show' => false,
|
90 |
+
);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
} else {
|
94 |
+
$billing_data['company'] = array(
|
95 |
+
'label' => __( 'Company', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
96 |
+
'show' => false,
|
97 |
+
);
|
98 |
+
} // End if().
|
99 |
+
|
100 |
+
if ( isset( $settings['birthdate_sex'] ) ) {
|
101 |
+
$billing_data['birthdate'] = array(
|
102 |
+
'label' => __( 'Birthdate', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
103 |
+
'show' => false,
|
104 |
+
);
|
105 |
+
$billing_data['sex'] = array(
|
106 |
+
'label' => __( 'Sex', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
107 |
+
'show' => false,
|
108 |
+
);
|
109 |
+
}
|
110 |
+
|
111 |
+
$billing_data['address_1'] = $data['address_1'];
|
112 |
+
$billing_data['number'] = array(
|
113 |
+
'label' => __( 'Number', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
114 |
+
'show' => false,
|
115 |
+
);
|
116 |
+
$billing_data['address_2'] = $data['address_2'];
|
117 |
+
$billing_data['neighborhood'] = array(
|
118 |
+
'label' => __( 'Neighborhood', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
119 |
+
'show' => false,
|
120 |
+
);
|
121 |
+
$billing_data['city'] = $data['city'];
|
122 |
+
$billing_data['state'] = $data['state'];
|
123 |
+
$billing_data['country'] = $data['country'];
|
124 |
+
$billing_data['postcode'] = $data['postcode'];
|
125 |
+
$billing_data['phone'] = $data['phone'];
|
126 |
+
$billing_data['phone']['show'] = false;
|
127 |
+
|
128 |
+
if ( isset( $settings['cell_phone'] ) ) {
|
129 |
+
$billing_data['cellphone'] = array(
|
130 |
+
'label' => __( 'Cell Phone', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
131 |
+
'show' => false,
|
132 |
+
);
|
133 |
+
}
|
134 |
+
|
135 |
+
$billing_data['email'] = $data['email'];
|
136 |
+
$billing_data['email']['show'] = false;
|
137 |
+
|
138 |
+
return apply_filters( 'wcbcf_admin_billing_fields', $billing_data );
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Custom shop order shipping fields.
|
143 |
+
*
|
144 |
+
* @param array $data Default order shipping fields.
|
145 |
+
*
|
146 |
+
* @return array Custom order shipping fields.
|
147 |
+
*/
|
148 |
+
public function shop_order_shipping_fields( $data ) {
|
149 |
+
$shipping_data['first_name'] = $data['first_name'];
|
150 |
+
$shipping_data['last_name'] = $data['last_name'];
|
151 |
+
$shipping_data['company'] = $data['company'];
|
152 |
+
$shipping_data['address_1'] = $data['address_1'];
|
153 |
+
$shipping_data['number'] = array(
|
154 |
+
'label' => __( 'Number', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
155 |
+
'show' => false,
|
156 |
+
);
|
157 |
+
$shipping_data['address_2'] = $data['address_2'];
|
158 |
+
$shipping_data['neighborhood'] = array(
|
159 |
+
'label' => __( 'Neighborhood', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
160 |
+
'show' => false,
|
161 |
+
);
|
162 |
+
$shipping_data['city'] = $data['city'];
|
163 |
+
$shipping_data['state'] = $data['state'];
|
164 |
+
$shipping_data['country'] = $data['country'];
|
165 |
+
$shipping_data['postcode'] = $data['postcode'];
|
166 |
+
|
167 |
+
return apply_filters( 'wcbcf_admin_shipping_fields', $shipping_data );
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Add custom fields in customer details ajax.
|
172 |
+
*
|
173 |
+
* @param array $data Customer data.
|
174 |
+
* @return array
|
175 |
+
*/
|
176 |
+
public function customer_details_ajax( $data ) {
|
177 |
+
$user_id = absint( wp_unslash( $_POST['user_id'] ) );
|
178 |
+
$type_to_load = sanitize_text_field( wp_unslash( $_POST['type_to_load'] ) );
|
179 |
+
|
180 |
+
$custom_data = array(
|
181 |
+
$type_to_load . '_number' => get_user_meta( $user_id, $type_to_load . '_number', true ),
|
182 |
+
$type_to_load . '_neighborhood' => get_user_meta( $user_id, $type_to_load . '_neighborhood', true ),
|
183 |
+
$type_to_load . '_persontype' => get_user_meta( $user_id, $type_to_load . '_persontype', true ),
|
184 |
+
$type_to_load . '_cpf' => get_user_meta( $user_id, $type_to_load . '_cpf', true ),
|
185 |
+
$type_to_load . '_rg' => get_user_meta( $user_id, $type_to_load . '_rg', true ),
|
186 |
+
$type_to_load . '_cnpj' => get_user_meta( $user_id, $type_to_load . '_cnpj', true ),
|
187 |
+
$type_to_load . '_ie' => get_user_meta( $user_id, $type_to_load . '_ie', true ),
|
188 |
+
$type_to_load . '_birthdate' => get_user_meta( $user_id, $type_to_load . '_birthdate', true ),
|
189 |
+
$type_to_load . '_sex' => get_user_meta( $user_id, $type_to_load . '_sex', true ),
|
190 |
+
$type_to_load . '_cellphone' => get_user_meta( $user_id, $type_to_load . '_cellphone', true ),
|
191 |
+
);
|
192 |
+
|
193 |
+
return array_merge( $data, $custom_data );
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Get customer details.
|
198 |
+
*
|
199 |
+
* @param array $data Customer data.
|
200 |
+
* @param WC_Customer $customer Customer instance.
|
201 |
+
*
|
202 |
+
* @return array
|
203 |
+
*/
|
204 |
+
public function ajax_get_customer_details( $data, $customer ) {
|
205 |
+
$data['billing_number'] = $customer->get_meta( 'billing_number' );
|
206 |
+
$data['billing_neighborhood'] = $customer->get_meta( 'billing_neighborhood' );
|
207 |
+
$data['billing_persontype'] = $customer->get_meta( 'billing_persontype' );
|
208 |
+
$data['billing_cpf'] = $customer->get_meta( 'billing_cpf' );
|
209 |
+
$data['billing_rg'] = $customer->get_meta( 'billing_rg' );
|
210 |
+
$data['billing_cnpj'] = $customer->get_meta( 'billing_cnpj' );
|
211 |
+
$data['billing_ie'] = $customer->get_meta( 'billing_ie' );
|
212 |
+
$data['billing_birthdate'] = $customer->get_meta( 'billing_birthdate' );
|
213 |
+
$data['billing_sex'] = $customer->get_meta( 'billing_sex' );
|
214 |
+
$data['billing_cellphone'] = $customer->get_meta( 'billing_cellphone' );
|
215 |
+
$data['shipping_number'] = $customer->get_meta( 'shipping_number' );
|
216 |
+
$data['shipping_neighborhood'] = $customer->get_meta( 'shipping_neighborhood' );
|
217 |
+
|
218 |
+
return $data;
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Custom billing admin fields.
|
223 |
+
*
|
224 |
+
* @param object $order Order data.
|
225 |
+
*/
|
226 |
+
public function order_data_after_billing_address( $order ) {
|
227 |
+
// Get plugin settings.
|
228 |
+
$settings = get_option( 'wcbcf_settings' );
|
229 |
+
$person_type = intval( $settings['person_type'] );
|
230 |
+
|
231 |
+
// Before WooCommerce 3.0.
|
232 |
+
if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
|
233 |
+
include dirname( __FILE__ ) . '/views/html-legacy-order-billing-data.php';
|
234 |
+
} else {
|
235 |
+
include dirname( __FILE__ ) . '/views/html-order-billing-data.php';
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Save custom shop data fields.
|
241 |
+
*
|
242 |
+
* @param int $post_id Post ID.
|
243 |
+
*/
|
244 |
+
public function save_custom_shop_data( $post_id ) {
|
245 |
+
// Get plugin settings.
|
246 |
+
$settings = get_option( 'wcbcf_settings' );
|
247 |
+
$person_type = intval( $settings['person_type'] );
|
248 |
+
$order = wc_get_order( $post_id );
|
249 |
+
|
250 |
+
// WooCommerce 3.0 or later.
|
251 |
+
if ( method_exists( $order, 'update_meta_data' ) ) {
|
252 |
+
$order->update_meta_data( '_billing_number', sanitize_text_field( wp_unslash( $_POST['_billing_number'] ) ) );
|
253 |
+
$order->update_meta_data( '_billing_neighborhood', sanitize_text_field( wp_unslash( $_POST['_billing_neighborhood'] ) ) );
|
254 |
+
$order->update_meta_data( '_shipping_number', sanitize_text_field( wp_unslash( $_POST['_shipping_number'] ) ) );
|
255 |
+
$order->update_meta_data( '_shipping_neighborhood', sanitize_text_field( wp_unslash( $_POST['_shipping_neighborhood'] ) ) );
|
256 |
+
|
257 |
+
if ( 0 !== $person_type ) {
|
258 |
+
if ( 1 === $person_type ) {
|
259 |
+
$order->update_meta_data( '_billing_persontype', sanitize_text_field( wp_unslash( $_POST['_billing_persontype'] ) ) );
|
260 |
+
}
|
261 |
+
|
262 |
+
if ( 1 === $person_type || 2 === $person_type ) {
|
263 |
+
$order->update_meta_data( '_billing_cpf', sanitize_text_field( wp_unslash( $_POST['_billing_cpf'] ) ) );
|
264 |
+
|
265 |
+
if ( isset( $settings['rg'] ) ) {
|
266 |
+
$order->update_meta_data( '_billing_rg', sanitize_text_field( wp_unslash( $_POST['_billing_rg'] ) ) );
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
if ( 1 === $person_type || 3 === $person_type ) {
|
271 |
+
$order->update_meta_data( '_billing_cnpj', sanitize_text_field( wp_unslash( $_POST['_billing_cnpj'] ) ) );
|
272 |
+
|
273 |
+
if ( isset( $settings['ie'] ) ) {
|
274 |
+
$order->update_meta_data( '_billing_ie', sanitize_text_field( wp_unslash( $_POST['_billing_ie'] ) ) );
|
275 |
+
}
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
if ( isset( $settings['birthdate_sex'] ) ) {
|
280 |
+
$order->update_meta_data( '_billing_birthdate', sanitize_text_field( wp_unslash( $_POST['_billing_birthdate'] ) ) );
|
281 |
+
$order->update_meta_data( '_billing_sex', sanitize_text_field( wp_unslash( $_POST['_billing_sex'] ) ) );
|
282 |
+
}
|
283 |
+
|
284 |
+
if ( isset( $settings['cell_phone'] ) ) {
|
285 |
+
$order->update_meta_data( '_billing_cellphone', sanitize_text_field( wp_unslash( $_POST['_billing_cellphone'] ) ) );
|
286 |
+
}
|
287 |
+
} else {
|
288 |
+
update_post_meta( $post_id, '_billing_number', sanitize_text_field( wp_unslash( $_POST['_billing_number'] ) ) );
|
289 |
+
update_post_meta( $post_id, '_billing_neighborhood', sanitize_text_field( wp_unslash( $_POST['_billing_neighborhood'] ) ) );
|
290 |
+
update_post_meta( $post_id, '_shipping_number', sanitize_text_field( wp_unslash( $_POST['_shipping_number'] ) ) );
|
291 |
+
update_post_meta( $post_id, '_shipping_neighborhood', sanitize_text_field( wp_unslash( $_POST['_shipping_neighborhood'] ) ) );
|
292 |
+
|
293 |
+
if ( 0 !== $person_type ) {
|
294 |
+
if ( 1 === $person_type ) {
|
295 |
+
update_post_meta( $post_id, '_billing_persontype', sanitize_text_field( wp_unslash( $_POST['_billing_persontype'] ) ) );
|
296 |
+
}
|
297 |
+
|
298 |
+
if ( 1 === $person_type || 2 === $person_type ) {
|
299 |
+
update_post_meta( $post_id, '_billing_cpf', sanitize_text_field( wp_unslash( $_POST['_billing_cpf'] ) ) );
|
300 |
+
|
301 |
+
if ( isset( $settings['rg'] ) ) {
|
302 |
+
update_post_meta( $post_id, '_billing_rg', sanitize_text_field( wp_unslash( $_POST['_billing_rg'] ) ) );
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
if ( 1 === $person_type || 3 === $person_type ) {
|
307 |
+
update_post_meta( $post_id, '_billing_cnpj', sanitize_text_field( wp_unslash( $_POST['_billing_cnpj'] ) ) );
|
308 |
+
|
309 |
+
if ( isset( $settings['ie'] ) ) {
|
310 |
+
update_post_meta( $post_id, '_billing_ie', sanitize_text_field( wp_unslash( $_POST['_billing_ie'] ) ) );
|
311 |
+
}
|
312 |
+
}
|
313 |
+
}
|
314 |
+
|
315 |
+
if ( isset( $settings['birthdate_sex'] ) ) {
|
316 |
+
update_post_meta( $post_id, '_billing_birthdate', sanitize_text_field( wp_unslash( $_POST['_billing_birthdate'] ) ) );
|
317 |
+
update_post_meta( $post_id, '_billing_sex', sanitize_text_field( wp_unslash( $_POST['_billing_sex'] ) ) );
|
318 |
+
}
|
319 |
+
|
320 |
+
if ( isset( $settings['cell_phone'] ) ) {
|
321 |
+
update_post_meta( $post_id, '_billing_cellphone', sanitize_text_field( wp_unslash( $_POST['_billing_cellphone'] ) ) );
|
322 |
+
}
|
323 |
+
} // End if().
|
324 |
+
}
|
325 |
+
}
|
326 |
+
|
327 |
+
new Extra_Checkout_Fields_For_Brazil_Order();
|
includes/admin/{class-wc-ecfb-settings.php → class-extra-checkout-fields-for-brazil-settings.php}
RENAMED
@@ -1,10 +1,16 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
exit; // Exit if accessed directly.
|
4 |
}
|
5 |
|
6 |
/**
|
7 |
-
*
|
8 |
*/
|
9 |
class Extra_Checkout_Fields_For_Brazil_Settings {
|
10 |
|
@@ -18,7 +24,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
18 |
|
19 |
/**
|
20 |
* Add the settings page.
|
21 |
-
|
22 |
public function settings_menu() {
|
23 |
add_submenu_page(
|
24 |
'woocommerce',
|
@@ -32,9 +38,9 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
32 |
|
33 |
/**
|
34 |
* Render the settings page for this plugin.
|
35 |
-
|
36 |
public function html_settings_page() {
|
37 |
-
|
38 |
}
|
39 |
|
40 |
/**
|
@@ -67,7 +73,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
67 |
1 => __( 'Individuals and Legal Person', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
68 |
2 => __( 'Individuals only', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
69 |
3 => __( 'Legal Person only', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
70 |
-
)
|
71 |
)
|
72 |
);
|
73 |
|
@@ -81,7 +87,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
81 |
array(
|
82 |
'menu' => $option,
|
83 |
'id' => 'only_brazil',
|
84 |
-
'label' => __( 'If checked the Individuals and Legal Person options will be mandatory only in Brazil.', 'woocommerce-extra-checkout-fields-for-brazil' )
|
85 |
)
|
86 |
);
|
87 |
|
@@ -95,7 +101,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
95 |
array(
|
96 |
'menu' => $option,
|
97 |
'id' => 'rg',
|
98 |
-
'label' => __( 'If checked show the RG field in billing options.', 'woocommerce-extra-checkout-fields-for-brazil' )
|
99 |
)
|
100 |
);
|
101 |
|
@@ -109,7 +115,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
109 |
array(
|
110 |
'menu' => $option,
|
111 |
'id' => 'ie',
|
112 |
-
'label' => __( 'If checked show the State Registration field in billing options.', 'woocommerce-extra-checkout-fields-for-brazil' )
|
113 |
)
|
114 |
);
|
115 |
|
@@ -123,7 +129,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
123 |
array(
|
124 |
'menu' => $option,
|
125 |
'id' => 'birthdate_sex',
|
126 |
-
'label' => __( 'If checked show the Birthdate and Sex field in billing options.', 'woocommerce-extra-checkout-fields-for-brazil' )
|
127 |
)
|
128 |
);
|
129 |
|
@@ -137,7 +143,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
137 |
array(
|
138 |
'menu' => $option,
|
139 |
'id' => 'cell_phone',
|
140 |
-
'label' => __( 'If checked show the Cell Phone field in billing options.', 'woocommerce-extra-checkout-fields-for-brazil' )
|
141 |
)
|
142 |
);
|
143 |
|
@@ -159,7 +165,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
159 |
array(
|
160 |
'menu' => $option,
|
161 |
'id' => 'mailcheck',
|
162 |
-
'label' => __( 'If checked informs typos in email to users.', 'woocommerce-extra-checkout-fields-for-brazil' )
|
163 |
)
|
164 |
);
|
165 |
|
@@ -173,7 +179,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
173 |
array(
|
174 |
'menu' => $option,
|
175 |
'id' => 'maskedinput',
|
176 |
-
'label' => __( 'If checked create masks fill for in fields of CPF, CNPJ, Birthdate, Phone and Cell Phone.', 'woocommerce-extra-checkout-fields-for-brazil' )
|
177 |
)
|
178 |
);
|
179 |
|
@@ -211,7 +217,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
211 |
array(
|
212 |
'menu' => $option,
|
213 |
'id' => 'validate_cpf',
|
214 |
-
'label' => __( 'Checks if the CPF is valid.', 'woocommerce-extra-checkout-fields-for-brazil' )
|
215 |
)
|
216 |
);
|
217 |
|
@@ -225,7 +231,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
225 |
array(
|
226 |
'menu' => $option,
|
227 |
'id' => 'validate_cnpj',
|
228 |
-
'label' => __( 'Checks if the CNPJ is valid.', 'woocommerce-extra-checkout-fields-for-brazil' )
|
229 |
)
|
230 |
);
|
231 |
|
@@ -243,7 +249,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
243 |
/**
|
244 |
* Checkbox element fallback.
|
245 |
*
|
246 |
-
* @
|
247 |
*/
|
248 |
public function checkbox_element_callback( $args ) {
|
249 |
$menu = $args['menu'];
|
@@ -256,23 +262,13 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
256 |
$current = isset( $args['default'] ) ? $args['default'] : '0';
|
257 |
}
|
258 |
|
259 |
-
|
260 |
-
|
261 |
-
if ( isset( $args['label'] ) ) {
|
262 |
-
$html .= ' <label for="' . $id . '">' . $args['label'] . '</label>';
|
263 |
-
}
|
264 |
-
|
265 |
-
if ( isset( $args['description'] ) ) {
|
266 |
-
$html .= '<p class="description">' . $args['description'] . '</p>';
|
267 |
-
}
|
268 |
-
|
269 |
-
echo $html;
|
270 |
}
|
271 |
|
272 |
/**
|
273 |
* Select element fallback.
|
274 |
*
|
275 |
-
* @
|
276 |
*/
|
277 |
public function select_element_callback( $args ) {
|
278 |
$menu = $args['menu'];
|
@@ -285,17 +281,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
|
|
285 |
$current = isset( $args['default'] ) ? $args['default'] : 0;
|
286 |
}
|
287 |
|
288 |
-
|
289 |
-
foreach ( $args['options'] as $key => $value ) {
|
290 |
-
$html .= sprintf( '<option value="%s" %s>%s</option>', $key, selected( $current, $key, false ), $value );
|
291 |
-
}
|
292 |
-
$html .= '</select>';
|
293 |
-
|
294 |
-
if ( isset( $args['description'] ) ) {
|
295 |
-
$html .= '<p class="description">' . $args['description'] . '</p>';
|
296 |
-
}
|
297 |
-
|
298 |
-
echo $html;
|
299 |
}
|
300 |
|
301 |
/**
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Extra checkout fields admin settings.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Admin/Settings
|
6 |
+
*/
|
7 |
+
|
8 |
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
exit; // Exit if accessed directly.
|
10 |
}
|
11 |
|
12 |
/**
|
13 |
+
* Extra_Checkout_Fields_For_Brazil_Settings class.
|
14 |
*/
|
15 |
class Extra_Checkout_Fields_For_Brazil_Settings {
|
16 |
|
24 |
|
25 |
/**
|
26 |
* Add the settings page.
|
27 |
+
*/
|
28 |
public function settings_menu() {
|
29 |
add_submenu_page(
|
30 |
'woocommerce',
|
38 |
|
39 |
/**
|
40 |
* Render the settings page for this plugin.
|
41 |
+
*/
|
42 |
public function html_settings_page() {
|
43 |
+
include dirname( __FILE__ ) . '/views/html-settings-page.php';
|
44 |
}
|
45 |
|
46 |
/**
|
73 |
1 => __( 'Individuals and Legal Person', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
74 |
2 => __( 'Individuals only', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
75 |
3 => __( 'Legal Person only', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
76 |
+
),
|
77 |
)
|
78 |
);
|
79 |
|
87 |
array(
|
88 |
'menu' => $option,
|
89 |
'id' => 'only_brazil',
|
90 |
+
'label' => __( 'If checked the Individuals and Legal Person options will be mandatory only in Brazil.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
91 |
)
|
92 |
);
|
93 |
|
101 |
array(
|
102 |
'menu' => $option,
|
103 |
'id' => 'rg',
|
104 |
+
'label' => __( 'If checked show the RG field in billing options.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
105 |
)
|
106 |
);
|
107 |
|
115 |
array(
|
116 |
'menu' => $option,
|
117 |
'id' => 'ie',
|
118 |
+
'label' => __( 'If checked show the State Registration field in billing options.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
119 |
)
|
120 |
);
|
121 |
|
129 |
array(
|
130 |
'menu' => $option,
|
131 |
'id' => 'birthdate_sex',
|
132 |
+
'label' => __( 'If checked show the Birthdate and Sex field in billing options.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
133 |
)
|
134 |
);
|
135 |
|
143 |
array(
|
144 |
'menu' => $option,
|
145 |
'id' => 'cell_phone',
|
146 |
+
'label' => __( 'If checked show the Cell Phone field in billing options.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
147 |
)
|
148 |
);
|
149 |
|
165 |
array(
|
166 |
'menu' => $option,
|
167 |
'id' => 'mailcheck',
|
168 |
+
'label' => __( 'If checked informs typos in email to users.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
169 |
)
|
170 |
);
|
171 |
|
179 |
array(
|
180 |
'menu' => $option,
|
181 |
'id' => 'maskedinput',
|
182 |
+
'label' => __( 'If checked create masks fill for in fields of CPF, CNPJ, Birthdate, Phone and Cell Phone.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
183 |
)
|
184 |
);
|
185 |
|
217 |
array(
|
218 |
'menu' => $option,
|
219 |
'id' => 'validate_cpf',
|
220 |
+
'label' => __( 'Checks if the CPF is valid.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
221 |
)
|
222 |
);
|
223 |
|
231 |
array(
|
232 |
'menu' => $option,
|
233 |
'id' => 'validate_cnpj',
|
234 |
+
'label' => __( 'Checks if the CNPJ is valid.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
235 |
)
|
236 |
);
|
237 |
|
249 |
/**
|
250 |
* Checkbox element fallback.
|
251 |
*
|
252 |
+
* @param array $args Callback arguments.
|
253 |
*/
|
254 |
public function checkbox_element_callback( $args ) {
|
255 |
$menu = $args['menu'];
|
262 |
$current = isset( $args['default'] ) ? $args['default'] : '0';
|
263 |
}
|
264 |
|
265 |
+
include dirname( __FILE__ ) . '/views/html-checkbox-field.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
}
|
267 |
|
268 |
/**
|
269 |
* Select element fallback.
|
270 |
*
|
271 |
+
* @param array $args Callback arguments.
|
272 |
*/
|
273 |
public function select_element_callback( $args ) {
|
274 |
$menu = $args['menu'];
|
281 |
$current = isset( $args['default'] ) ? $args['default'] : 0;
|
282 |
}
|
283 |
|
284 |
+
include dirname( __FILE__ ) . '/views/html-select-field.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
}
|
286 |
|
287 |
/**
|
includes/admin/class-wc-ecfb-order.php
DELETED
@@ -1,394 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit; // Exit if accessed directly.
|
4 |
-
}
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Shop order class.
|
8 |
-
*/
|
9 |
-
class Extra_Checkout_Fields_For_Brazil_Order {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Initialize the order actions.
|
13 |
-
*/
|
14 |
-
public function __construct() {
|
15 |
-
add_filter( 'woocommerce_admin_billing_fields', array( $this, 'shop_order_billing_fields' ) );
|
16 |
-
add_filter( 'woocommerce_admin_shipping_fields', array( $this, 'shop_order_shipping_fields' ) );
|
17 |
-
add_filter( 'woocommerce_found_customer_details', array( $this, 'customer_details_ajax' ) );
|
18 |
-
add_action( 'woocommerce_admin_order_data_after_billing_address', array( $this, 'order_data_after_billing_address' ) );
|
19 |
-
add_action( 'woocommerce_admin_order_data_after_shipping_address', array( $this, 'order_data_after_shipping_address' ) );
|
20 |
-
add_action( 'woocommerce_process_shop_order_meta', array( $this, 'save_custom_shop_data' ) );
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Custom shop order billing fields.
|
25 |
-
*
|
26 |
-
* @param array $data Default order billing fields.
|
27 |
-
*
|
28 |
-
* @return array Custom order billing fields.
|
29 |
-
*/
|
30 |
-
public function shop_order_billing_fields( $data ) {
|
31 |
-
// Get plugin settings.
|
32 |
-
$settings = get_option( 'wcbcf_settings' );
|
33 |
-
|
34 |
-
$billing_data['first_name'] = array(
|
35 |
-
'label' => __( 'First Name', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
36 |
-
'show' => false
|
37 |
-
);
|
38 |
-
$billing_data['last_name'] = array(
|
39 |
-
'label' => __( 'Last Name', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
40 |
-
'show' => false
|
41 |
-
);
|
42 |
-
|
43 |
-
if ( 0 != $settings['person_type'] ) {
|
44 |
-
if ( 1 == $settings['person_type'] ) {
|
45 |
-
$billing_data['persontype'] = array(
|
46 |
-
'type' => 'select',
|
47 |
-
'label' => __( 'Person type', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
48 |
-
'options' => array(
|
49 |
-
'0' => __( 'Select', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
50 |
-
'1' => __( 'Individuals', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
51 |
-
'2' => __( 'Legal Person', 'woocommerce-extra-checkout-fields-for-brazil' )
|
52 |
-
)
|
53 |
-
);
|
54 |
-
}
|
55 |
-
|
56 |
-
if ( 1 == $settings['person_type'] || 2 == $settings['person_type'] ) {
|
57 |
-
$billing_data['cpf'] = array(
|
58 |
-
'label' => __( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
59 |
-
);
|
60 |
-
if ( isset( $settings['rg'] ) ) {
|
61 |
-
$billing_data['rg'] = array(
|
62 |
-
'label' => __( 'RG', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
63 |
-
);
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
if ( 1 == $settings['person_type'] || 3 == $settings['person_type'] ) {
|
68 |
-
$billing_data['company'] = array(
|
69 |
-
'label' => __( 'Company Name', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
70 |
-
);
|
71 |
-
$billing_data['cnpj'] = array(
|
72 |
-
'label' => __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
73 |
-
);
|
74 |
-
if ( isset( $settings['ie'] ) ) {
|
75 |
-
$billing_data['ie'] = array(
|
76 |
-
'label' => __( 'State Registration', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
77 |
-
);
|
78 |
-
}
|
79 |
-
}
|
80 |
-
|
81 |
-
} else {
|
82 |
-
$billing_data['company'] = array(
|
83 |
-
'label' => __( 'Company', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
84 |
-
'show' => false
|
85 |
-
);
|
86 |
-
}
|
87 |
-
|
88 |
-
if ( isset( $settings['birthdate_sex'] ) ) {
|
89 |
-
$billing_data['birthdate'] = array(
|
90 |
-
'label' => __( 'Birthdate', 'woocommerce-extra-checkout-fields-for-brazil' )
|
91 |
-
);
|
92 |
-
$billing_data['sex'] = array(
|
93 |
-
'label' => __( 'Sex', 'woocommerce-extra-checkout-fields-for-brazil' )
|
94 |
-
);
|
95 |
-
}
|
96 |
-
|
97 |
-
$billing_data['address_1'] = array(
|
98 |
-
'label' => __( 'Address 1', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
99 |
-
'show' => false
|
100 |
-
);
|
101 |
-
$billing_data['number'] = array(
|
102 |
-
'label' => __( 'Number', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
103 |
-
'show' => false
|
104 |
-
);
|
105 |
-
$billing_data['address_2'] = array(
|
106 |
-
'label' => __( 'Address 2', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
107 |
-
'show' => false
|
108 |
-
);
|
109 |
-
$billing_data['neighborhood'] = array(
|
110 |
-
'label' => __( 'Neighborhood', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
111 |
-
'show' => false
|
112 |
-
);
|
113 |
-
$billing_data['city'] = array(
|
114 |
-
'label' => __( 'City', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
115 |
-
'show' => false
|
116 |
-
);
|
117 |
-
$billing_data['state'] = array(
|
118 |
-
'label' => __( 'State', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
119 |
-
'show' => false
|
120 |
-
);
|
121 |
-
$billing_data['country'] = array(
|
122 |
-
'label' => __( 'Country', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
123 |
-
'show' => false,
|
124 |
-
'type' => 'select',
|
125 |
-
'options' => array(
|
126 |
-
'' => __( 'Select a country…', 'woocommerce-extra-checkout-fields-for-brazil' )
|
127 |
-
) + WC()->countries->get_allowed_countries()
|
128 |
-
);
|
129 |
-
$billing_data['postcode'] = array(
|
130 |
-
'label' => __( 'Postcode', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
131 |
-
'show' => false
|
132 |
-
);
|
133 |
-
|
134 |
-
$billing_data['phone'] = array(
|
135 |
-
'label' => __( 'Phone', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
136 |
-
);
|
137 |
-
|
138 |
-
if ( isset( $settings['cell_phone'] ) ) {
|
139 |
-
$billing_data['cellphone'] = array(
|
140 |
-
'label' => __( 'Cell Phone', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
141 |
-
);
|
142 |
-
}
|
143 |
-
|
144 |
-
$billing_data['email'] = array(
|
145 |
-
'label' => __( 'Email', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
146 |
-
);
|
147 |
-
|
148 |
-
|
149 |
-
return apply_filters( 'wcbcf_admin_billing_fields', $billing_data );
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Custom shop order shipping fields.
|
154 |
-
*
|
155 |
-
* @param array $data Default order shipping fields.
|
156 |
-
*
|
157 |
-
* @return array Custom order shipping fields.
|
158 |
-
*/
|
159 |
-
public function shop_order_shipping_fields( $data ) {
|
160 |
-
$shipping_data['first_name'] = array(
|
161 |
-
'label' => __( 'First Name', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
162 |
-
'show' => false
|
163 |
-
);
|
164 |
-
$shipping_data['last_name'] = array(
|
165 |
-
'label' => __( 'Last Name', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
166 |
-
'show' => false
|
167 |
-
);
|
168 |
-
$shipping_data['company'] = array(
|
169 |
-
'label' => __( 'Company', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
170 |
-
'show' => false
|
171 |
-
);
|
172 |
-
$shipping_data['address_1'] = array(
|
173 |
-
'label' => __( 'Address 1', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
174 |
-
'show' => false
|
175 |
-
);
|
176 |
-
$shipping_data['number'] = array(
|
177 |
-
'label' => __( 'Number', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
178 |
-
'show' => false
|
179 |
-
);
|
180 |
-
$shipping_data['address_2'] = array(
|
181 |
-
'label' => __( 'Address 2', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
182 |
-
'show' => false
|
183 |
-
);
|
184 |
-
$shipping_data['neighborhood'] = array(
|
185 |
-
'label' => __( 'Neighborhood', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
186 |
-
'show' => false
|
187 |
-
);
|
188 |
-
$shipping_data['city'] = array(
|
189 |
-
'label' => __( 'City', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
190 |
-
'show' => false
|
191 |
-
);
|
192 |
-
$shipping_data['state'] = array(
|
193 |
-
'label' => __( 'State', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
194 |
-
'show' => false
|
195 |
-
);
|
196 |
-
$shipping_data['country'] = array(
|
197 |
-
'label' => __( 'Country', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
198 |
-
'show' => false,
|
199 |
-
'type' => 'select',
|
200 |
-
'options' => array(
|
201 |
-
'' => __( 'Select a country…', 'woocommerce-extra-checkout-fields-for-brazil' )
|
202 |
-
) + WC()->countries->get_allowed_countries()
|
203 |
-
);
|
204 |
-
$shipping_data['postcode'] = array(
|
205 |
-
'label' => __( 'Postcode', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
206 |
-
'show' => false
|
207 |
-
);
|
208 |
-
|
209 |
-
return apply_filters( 'wcbcf_admin_shipping_fields', $shipping_data );
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* Add custom fields in customer details ajax.
|
214 |
-
*/
|
215 |
-
public function customer_details_ajax( $customer_data ) {
|
216 |
-
$user_id = (int) trim( stripslashes( $_POST['user_id'] ) );
|
217 |
-
$type_to_load = esc_attr( trim( stripslashes( $_POST['type_to_load'] ) ) );
|
218 |
-
|
219 |
-
$custom_data = array(
|
220 |
-
$type_to_load . '_number' => get_user_meta( $user_id, $type_to_load . '_number', true ),
|
221 |
-
$type_to_load . '_neighborhood' => get_user_meta( $user_id, $type_to_load . '_neighborhood', true ),
|
222 |
-
$type_to_load . '_persontype' => get_user_meta( $user_id, $type_to_load . '_persontype', true ),
|
223 |
-
$type_to_load . '_cpf' => get_user_meta( $user_id, $type_to_load . '_cpf', true ),
|
224 |
-
$type_to_load . '_rg' => get_user_meta( $user_id, $type_to_load . '_rg', true ),
|
225 |
-
$type_to_load . '_cnpj' => get_user_meta( $user_id, $type_to_load . '_cnpj', true ),
|
226 |
-
$type_to_load . '_ie' => get_user_meta( $user_id, $type_to_load . '_ie', true ),
|
227 |
-
$type_to_load . '_birthdate' => get_user_meta( $user_id, $type_to_load . '_birthdate', true ),
|
228 |
-
$type_to_load . '_sex' => get_user_meta( $user_id, $type_to_load . '_sex', true ),
|
229 |
-
$type_to_load . '_cellphone' => get_user_meta( $user_id, $type_to_load . '_cellphone', true )
|
230 |
-
);
|
231 |
-
|
232 |
-
return array_merge( $customer_data, $custom_data );
|
233 |
-
}
|
234 |
-
|
235 |
-
/**
|
236 |
-
* Custom billing admin fields.
|
237 |
-
*
|
238 |
-
* @param object $order Order data.
|
239 |
-
*
|
240 |
-
* @return string Custom information.
|
241 |
-
*/
|
242 |
-
public function order_data_after_billing_address( $order ) {
|
243 |
-
// Get plugin settings.
|
244 |
-
$settings = get_option( 'wcbcf_settings' );
|
245 |
-
|
246 |
-
$html = '<div class="clear"></div>';
|
247 |
-
$html .= '<div class="wcbcf-address">';
|
248 |
-
|
249 |
-
if ( ! $order->get_formatted_billing_address() ) {
|
250 |
-
$html .= '<p class="none_set"><strong>' . __( 'Address', 'woocommerce-extra-checkout-fields-for-brazil' ) . ':</strong> ' . __( 'No billing address set.', 'woocommerce-extra-checkout-fields-for-brazil' ) . '</p>';
|
251 |
-
} else {
|
252 |
-
|
253 |
-
$html .= '<p><strong>' . __( 'Address', 'woocommerce-extra-checkout-fields-for-brazil' ) . ':</strong><br />';
|
254 |
-
$html .= $order->get_formatted_billing_address();
|
255 |
-
$html .= '</p>';
|
256 |
-
}
|
257 |
-
|
258 |
-
$html .= '<h4>' . __( 'Customer data', 'woocommerce-extra-checkout-fields-for-brazil' ) . '</h4>';
|
259 |
-
|
260 |
-
$html .= '<p>';
|
261 |
-
|
262 |
-
if ( 0 != $settings['person_type'] ) {
|
263 |
-
|
264 |
-
// Person type information.
|
265 |
-
if ( ( 1 == $order->billing_persontype && 1 == $settings['person_type'] ) || 2 == $settings['person_type'] ) {
|
266 |
-
$html .= '<strong>' . __( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ) . ': </strong>' . esc_html( $order->billing_cpf ) . '<br />';
|
267 |
-
|
268 |
-
if ( isset( $settings['rg'] ) ) {
|
269 |
-
$html .= '<strong>' . __( 'RG', 'woocommerce-extra-checkout-fields-for-brazil' ) . ': </strong>' . esc_html( $order->billing_rg ) . '<br />';
|
270 |
-
}
|
271 |
-
}
|
272 |
-
|
273 |
-
if ( ( 2 == $order->billing_persontype && 1 == $settings['person_type'] ) || 3 == $settings['person_type'] ) {
|
274 |
-
$html .= '<strong>' . __( 'Company Name', 'woocommerce-extra-checkout-fields-for-brazil' ) . ': </strong>' . esc_html( $order->billing_company ) . '<br />';
|
275 |
-
$html .= '<strong>' . __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ) . ': </strong>' . esc_html( $order->billing_cnpj ) . '<br />';
|
276 |
-
|
277 |
-
if ( isset( $settings['ie'] ) ) {
|
278 |
-
$html .= '<strong>' . __( 'State Registration', 'woocommerce-extra-checkout-fields-for-brazil' ) . ': </strong>' . esc_html( $order->billing_ie ) . '<br />';
|
279 |
-
}
|
280 |
-
}
|
281 |
-
} else {
|
282 |
-
$html .= '<strong>' . __( 'Company', 'woocommerce-extra-checkout-fields-for-brazil' ) . ': </strong>' . esc_html( $order->billing_company ) . '<br />';
|
283 |
-
}
|
284 |
-
|
285 |
-
if ( isset( $settings['birthdate_sex'] ) ) {
|
286 |
-
|
287 |
-
// Birthdate information.
|
288 |
-
$html .= '<strong>' . __( 'Birthdate', 'woocommerce-extra-checkout-fields-for-brazil' ) . ': </strong>' . esc_html( $order->billing_birthdate ) . '<br />';
|
289 |
-
|
290 |
-
// Sex Information.
|
291 |
-
$html .= '<strong>' . __( 'Sex', 'woocommerce-extra-checkout-fields-for-brazil' ) . ': </strong>' . esc_html( $order->billing_sex ) . '<br />';
|
292 |
-
}
|
293 |
-
|
294 |
-
$html .= '<strong>' . __( 'Phone', 'woocommerce-extra-checkout-fields-for-brazil' ) . ': </strong>' . esc_html( $order->billing_phone ) . '<br />';
|
295 |
-
|
296 |
-
// Cell Phone Information.
|
297 |
-
if ( ! empty( $order->billing_cellphone ) ) {
|
298 |
-
$html .= '<strong>' . __( 'Cell Phone', 'woocommerce-extra-checkout-fields-for-brazil' ) . ': </strong>' . esc_html( $order->billing_cellphone ) . '<br />';
|
299 |
-
}
|
300 |
-
|
301 |
-
$html .= '<strong>' . __( 'Email', 'woocommerce-extra-checkout-fields-for-brazil' ) . ': </strong>' . make_clickable( esc_html( $order->billing_email ) ) . '<br />';
|
302 |
-
|
303 |
-
$html .= '</p>';
|
304 |
-
|
305 |
-
$html .= '</div>';
|
306 |
-
|
307 |
-
echo $html;
|
308 |
-
}
|
309 |
-
|
310 |
-
/**
|
311 |
-
* Custom billing admin fields.
|
312 |
-
*
|
313 |
-
* @param object $order Order data.
|
314 |
-
*
|
315 |
-
* @return string Custom information.
|
316 |
-
*/
|
317 |
-
public function order_data_after_shipping_address( $order ) {
|
318 |
-
global $post;
|
319 |
-
|
320 |
-
// Get plugin settings.
|
321 |
-
$settings = get_option( 'wcbcf_settings' );
|
322 |
-
|
323 |
-
$html = '<div class="clear"></div>';
|
324 |
-
$html .= '<div class="wcbcf-address">';
|
325 |
-
|
326 |
-
if ( ! $order->get_formatted_shipping_address() ) {
|
327 |
-
$html .= '<p class="none_set"><strong>' . __( 'Address', 'woocommerce-extra-checkout-fields-for-brazil' ) . ':</strong> ' . __( 'No shipping address set.', 'woocommerce-extra-checkout-fields-for-brazil' ) . '</p>';
|
328 |
-
} else {
|
329 |
-
|
330 |
-
$html .= '<p><strong>' . __( 'Address', 'woocommerce-extra-checkout-fields-for-brazil' ) . ':</strong><br />';
|
331 |
-
$html .= $order->get_formatted_shipping_address();
|
332 |
-
$html .= '</p>';
|
333 |
-
}
|
334 |
-
|
335 |
-
if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' == get_option( 'woocommerce_enable_order_comments', 'yes' ) ) && $post->post_excerpt ) {
|
336 |
-
$html .= '<p><strong>' . __( 'Customer Note', 'woocommerce-extra-checkout-fields-for-brazil' ) . ':</strong><br />' . nl2br( esc_html( $post->post_excerpt ) ) . '</p>';
|
337 |
-
}
|
338 |
-
|
339 |
-
$html .= '</div>';
|
340 |
-
|
341 |
-
echo $html;
|
342 |
-
}
|
343 |
-
|
344 |
-
/**
|
345 |
-
* Save custom shop data fields.
|
346 |
-
*
|
347 |
-
* @param int $post_id Post ID.
|
348 |
-
*
|
349 |
-
* @return mixed
|
350 |
-
*/
|
351 |
-
public function save_custom_shop_data( $post_id ) {
|
352 |
-
// Get plugin settings.
|
353 |
-
$settings = get_option( 'wcbcf_settings' );
|
354 |
-
|
355 |
-
// Update options.
|
356 |
-
update_post_meta( $post_id, '_billing_number', woocommerce_clean( $_POST['_billing_number'] ) );
|
357 |
-
update_post_meta( $post_id, '_billing_neighborhood', woocommerce_clean( $_POST['_billing_neighborhood'] ) );
|
358 |
-
update_post_meta( $post_id, '_shipping_number', woocommerce_clean( $_POST['_shipping_number'] ) );
|
359 |
-
update_post_meta( $post_id, '_shipping_neighborhood', woocommerce_clean( $_POST['_shipping_neighborhood'] ) );
|
360 |
-
|
361 |
-
if ( 0 != $settings['person_type'] ) {
|
362 |
-
if ( 1 == $settings['person_type'] ) {
|
363 |
-
update_post_meta( $post_id, '_billing_persontype', woocommerce_clean( $_POST['_billing_persontype'] ) );
|
364 |
-
}
|
365 |
-
|
366 |
-
if ( 1 == $settings['person_type'] || 2 == $settings['person_type'] ) {
|
367 |
-
update_post_meta( $post_id, '_billing_cpf', woocommerce_clean( $_POST['_billing_cpf'] ) );
|
368 |
-
|
369 |
-
if ( isset( $settings['rg'] ) ) {
|
370 |
-
update_post_meta( $post_id, '_billing_rg', woocommerce_clean( $_POST['_billing_rg'] ) );
|
371 |
-
}
|
372 |
-
}
|
373 |
-
|
374 |
-
if ( 1 == $settings['person_type'] || 3 == $settings['person_type'] ) {
|
375 |
-
update_post_meta( $post_id, '_billing_cnpj', woocommerce_clean( $_POST['_billing_cnpj'] ) );
|
376 |
-
|
377 |
-
if ( isset( $settings['ie'] ) ) {
|
378 |
-
update_post_meta( $post_id, '_billing_ie', woocommerce_clean( $_POST['_billing_ie'] ) );
|
379 |
-
}
|
380 |
-
}
|
381 |
-
}
|
382 |
-
|
383 |
-
if ( isset( $settings['birthdate_sex'] ) ) {
|
384 |
-
update_post_meta( $post_id, '_billing_birthdate', woocommerce_clean( $_POST['_billing_birthdate'] ) );
|
385 |
-
update_post_meta( $post_id, '_billing_sex', woocommerce_clean( $_POST['_billing_sex'] ) );
|
386 |
-
}
|
387 |
-
|
388 |
-
if ( isset( $settings['cell_phone'] ) ) {
|
389 |
-
update_post_meta( $post_id, '_billing_cellphone', woocommerce_clean( $_POST['_billing_cellphone'] ) );
|
390 |
-
}
|
391 |
-
}
|
392 |
-
}
|
393 |
-
|
394 |
-
new Extra_Checkout_Fields_For_Brazil_Order();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/admin/views/html-admin-help-message.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin help message view.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Admin/Settings
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
|
12 |
+
if ( apply_filters( 'wcbcf_help_message', true ) ) : ?>
|
13 |
+
<div class="updated woocommerce-message inline">
|
14 |
+
<p><?php echo esc_html( sprintf( __( 'Help us keep the %s plugin free making a donation or rate ★★★★★ on WordPress.org. Thank you in advance!', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'WooCommerce Correios', 'woocommerce-extra-checkout-fields-for-brazil' ) ) ); ?></p>
|
15 |
+
<p><a href="https://claudiosanches.com/doacoes/" target="_blank" class="button button-primary"><?php esc_html_e( 'Make a donation', 'woocommerce-extra-checkout-fields-for-brazil' ); ?></a> <a href="https://wordpress.org/support/plugin/woocommerce-extra-checkout-fields-for-brazil/reviews/?filter=5#new-post" target="_blank" class="button button-secondary"><?php esc_html_e( 'Make a review', 'woocommerce-extra-checkout-fields-for-brazil' ); ?></a></p>
|
16 |
+
</div>
|
17 |
+
<?php endif;
|
includes/admin/views/html-checkbox-field.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Checkbox field view.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Admin/View
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
?>
|
12 |
+
<input type="checkbox" id="<?php echo esc_attr( $id ); ?>" name="<?php echo esc_attr( $menu ) ?>[<?php echo esc_attr( $id ); ?>]" value="1" <?php checked( 1, $current, true ) ?> />
|
13 |
+
<?php if ( isset( $args['label'] ) ) : ?>
|
14 |
+
<label for="<?php echo esc_attr( $id ); ?>"><?php echo esc_html( $args['label'] ); ?></label>
|
15 |
+
<?php endif; ?>
|
16 |
+
<?php if ( isset( $args['description'] ) ) : ?>
|
17 |
+
<p class="description"><?php echo esc_html( $args['description'] ); ?></p>
|
18 |
+
<?php endif;
|
includes/admin/views/html-legacy-order-billing-data.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Billing data view.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Admin/View
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
?>
|
12 |
+
|
13 |
+
<div class="clear"></div>
|
14 |
+
|
15 |
+
<div class="wcbcf-address">
|
16 |
+
|
17 |
+
<h4><?php esc_html_e( 'Customer data', 'woocommerce-extra-checkout-fields-for-brazil' ); ?></h4>
|
18 |
+
|
19 |
+
<p>
|
20 |
+
<?php if ( 0 !== $person_type ) : ?>
|
21 |
+
<?php if ( ( 1 === intval( $order->billing_persontype ) && 1 === $person_type ) || 2 === $person_type ) : ?>
|
22 |
+
<strong><?php esc_html_e( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->billing_cpf ); ?><br />
|
23 |
+
<?php if ( isset( $settings['rg'] ) ) : ?>
|
24 |
+
<strong><?php esc_html_e( 'RG', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->billing_rg ); ?><br />
|
25 |
+
<?php endif; ?>
|
26 |
+
<?php endif; ?>
|
27 |
+
|
28 |
+
<?php if ( ( 2 === intval( $order->billing_persontype ) && 1 === $person_type ) || 3 === $person_type ) : ?>
|
29 |
+
<strong><?php esc_html_e( 'Company Name', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->billing_company ); ?><br />
|
30 |
+
<strong><?php esc_html_e( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->billing_cnpj ); ?><br />
|
31 |
+
|
32 |
+
<?php if ( isset( $settings['ie'] ) ) : ?>
|
33 |
+
<strong><?php esc_html_e( 'State Registration', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->billing_ie ); ?><br />
|
34 |
+
<?php endif; ?>
|
35 |
+
<?php endif; ?>
|
36 |
+
<?php else : ?>
|
37 |
+
<strong><?php esc_html_e( 'Company', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->billing_company ); ?><br />
|
38 |
+
<?php endif; ?>
|
39 |
+
|
40 |
+
<?php if ( isset( $settings['birthdate_sex'] ) ) : ?>
|
41 |
+
<strong><?php esc_html_e( 'Birthdate', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->billing_birthdate ); ?><br />
|
42 |
+
<strong><?php esc_html_e( 'Sex', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->billing_sex ); ?><br />
|
43 |
+
<?php endif; ?>
|
44 |
+
|
45 |
+
<strong><?php esc_html_e( 'Phone', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->billing_phone ); ?><br />
|
46 |
+
|
47 |
+
<?php if ( ! empty( $order->billing_cellphone ) ) : ?>
|
48 |
+
<strong><?php esc_html_e( 'Cell Phone', 'woocommerce-extra-checkout-fields-for-brazil' ) ?>: </strong><?php echo esc_html( $order->billing_cellphone ); ?><br />
|
49 |
+
<?php endif; ?>
|
50 |
+
|
51 |
+
<strong><?php esc_html_e( 'Email', 'woocommerce-extra-checkout-fields-for-brazil' ) ?>: </strong><?php echo wp_kses_post( make_clickable( $order->billing_email ) ); ?><br />
|
52 |
+
</p>
|
53 |
+
|
54 |
+
</div>
|
55 |
+
<?php
|
includes/admin/views/html-order-billing-data.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Billing data view.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Admin/View
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
?>
|
12 |
+
|
13 |
+
<div class="clear"></div>
|
14 |
+
|
15 |
+
<div class="wcbcf-address">
|
16 |
+
|
17 |
+
<h4><?php esc_html_e( 'Customer data', 'woocommerce-extra-checkout-fields-for-brazil' ); ?></h4>
|
18 |
+
|
19 |
+
<p>
|
20 |
+
<?php if ( 0 !== $person_type ) : ?>
|
21 |
+
<?php if ( ( 1 === intval( $order->get_meta( '_billing_persontype' ) ) && 1 === $person_type ) || 2 === $person_type ) : ?>
|
22 |
+
<strong><?php esc_html_e( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->get_meta( '_billing_cpf' ) ); ?><br />
|
23 |
+
<?php if ( isset( $settings['rg'] ) ) : ?>
|
24 |
+
<strong><?php esc_html_e( 'RG', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->get_meta( '_billing_rg' ) ); ?><br />
|
25 |
+
<?php endif; ?>
|
26 |
+
<?php endif; ?>
|
27 |
+
|
28 |
+
<?php if ( ( 2 === intval( $order->get_meta( '_billing_persontype' ) ) && 1 === $person_type ) || 3 === $person_type ) : ?>
|
29 |
+
<strong><?php esc_html_e( 'Company Name', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->get_billing_company() ); ?><br />
|
30 |
+
<strong><?php esc_html_e( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->get_meta( '_billing_cnpj' ) ); ?><br />
|
31 |
+
|
32 |
+
<?php if ( isset( $settings['ie'] ) ) : ?>
|
33 |
+
<strong><?php esc_html_e( 'State Registration', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->get_meta( '_billing_ie' ) ); ?><br />
|
34 |
+
<?php endif; ?>
|
35 |
+
<?php endif; ?>
|
36 |
+
<?php else : ?>
|
37 |
+
<strong><?php esc_html_e( 'Company', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->get_billing_company() ); ?><br />
|
38 |
+
<?php endif; ?>
|
39 |
+
|
40 |
+
<?php if ( isset( $settings['birthdate_sex'] ) ) : ?>
|
41 |
+
<strong><?php esc_html_e( 'Birthdate', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->get_meta( '_billing_birthdate' ) ); ?><br />
|
42 |
+
<strong><?php esc_html_e( 'Sex', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->get_meta( '_billing_sex' ) ); ?><br />
|
43 |
+
<?php endif; ?>
|
44 |
+
|
45 |
+
<strong><?php esc_html_e( 'Phone', 'woocommerce-extra-checkout-fields-for-brazil' ); ?>: </strong><?php echo esc_html( $order->get_billing_phone() ); ?><br />
|
46 |
+
|
47 |
+
<?php if ( '' !== $order->get_meta( 'billing_cellphone' ) ) : ?>
|
48 |
+
<strong><?php esc_html_e( 'Cell Phone', 'woocommerce-extra-checkout-fields-for-brazil' ) ?>: </strong><?php echo esc_html( $order->get_meta( 'billing_cellphone' ) ); ?><br />
|
49 |
+
<?php endif; ?>
|
50 |
+
|
51 |
+
<strong><?php esc_html_e( 'Email', 'woocommerce-extra-checkout-fields-for-brazil' ) ?>: </strong><?php echo wp_kses_post( make_clickable( $order->get_billing_email() ) ); ?><br />
|
52 |
+
</p>
|
53 |
+
|
54 |
+
</div>
|
55 |
+
<?php
|
includes/admin/views/html-select-field.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Select field view.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Admin/View
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
?>
|
12 |
+
<select id="<?php echo esc_attr( $id ); ?>" name="<?php echo esc_attr( $menu ); ?>[<?php echo esc_attr( $id ); ?>]">
|
13 |
+
<?php foreach ( $args['options'] as $key => $value ) : ?>
|
14 |
+
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $current, $key, true ) ?>><?php echo esc_html( $value ); ?></option>
|
15 |
+
<?php endforeach; ?>
|
16 |
+
</select>
|
17 |
+
<?php if ( isset( $args['description'] ) ) : ?>
|
18 |
+
<p class="description"><?php echo esc_html( $args['description'] ); ?></p>
|
19 |
+
<?php endif;
|
includes/admin/views/html-settings-page.php
CHANGED
@@ -1,24 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
exit;
|
5 |
}
|
6 |
?>
|
7 |
|
8 |
<div class="wrap">
|
9 |
-
|
10 |
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
|
11 |
|
12 |
<?php settings_errors(); ?>
|
13 |
-
<form method="post" action="options.php">
|
14 |
|
|
|
|
|
15 |
<?php
|
16 |
settings_fields( 'wcbcf_settings' );
|
17 |
do_settings_sections( 'wcbcf_settings' );
|
18 |
-
|
19 |
submit_button();
|
20 |
?>
|
21 |
-
|
22 |
</form>
|
23 |
-
|
24 |
</div>
|
|
|
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Settings page view.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Admin/View
|
6 |
+
*/
|
7 |
+
|
8 |
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
exit;
|
10 |
}
|
11 |
?>
|
12 |
|
13 |
<div class="wrap">
|
|
|
14 |
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
|
15 |
|
16 |
<?php settings_errors(); ?>
|
|
|
17 |
|
18 |
+
<?php include dirname( __FILE__ ) . '/html-admin-help-message.php'; ?>
|
19 |
+
<form method="post" action="options.php">
|
20 |
<?php
|
21 |
settings_fields( 'wcbcf_settings' );
|
22 |
do_settings_sections( 'wcbcf_settings' );
|
|
|
23 |
submit_button();
|
24 |
?>
|
|
|
25 |
</form>
|
|
|
26 |
</div>
|
27 |
+
|
28 |
+
<?php
|
includes/class-extra-checkout-fields-for-brazil-api.php
ADDED
@@ -0,0 +1,437 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Extra checkout fields REST API integration.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/REST_API
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly.
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Extra_Checkout_Fields_For_Brazil_API class.
|
14 |
+
*/
|
15 |
+
class Extra_Checkout_Fields_For_Brazil_API {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Initialize integrations.
|
19 |
+
*/
|
20 |
+
public function __construct() {
|
21 |
+
// Legacy REST API.
|
22 |
+
add_filter( 'woocommerce_api_order_response', array( $this, 'legacy_orders_response' ), 100, 4 );
|
23 |
+
add_filter( 'woocommerce_api_customer_response', array( $this, 'legacy_customers_response' ), 100, 4 );
|
24 |
+
|
25 |
+
// WP REST API.
|
26 |
+
add_filter( 'woocommerce_rest_prepare_customer', array( $this, 'customers_response' ), 100, 2 );
|
27 |
+
add_filter( 'woocommerce_rest_prepare_shop_order', array( $this, 'orders_v1_response' ), 100, 2 );
|
28 |
+
add_filter( 'woocommerce_rest_prepare_shop_order_object', array( $this, 'orders_response' ), 100, 2 );
|
29 |
+
add_filter( 'woocommerce_rest_customer_schema', array( $this, 'addresses_schema' ), 100 );
|
30 |
+
add_filter( 'woocommerce_rest_shop_order_schema', array( $this, 'addresses_schema' ), 100 );
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Format number.
|
35 |
+
*
|
36 |
+
* @param string $string Number to format.
|
37 |
+
*
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
protected function format_number( $string ) {
|
41 |
+
return str_replace( array( '.', '-', '/' ), '', $string );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Get formatted birthdate legacy.
|
46 |
+
*
|
47 |
+
* @param string $date Date to format.
|
48 |
+
* @param WC_API_Server $server Server instance.
|
49 |
+
*
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
protected function get_formatted_birthdate_legacy( $date, $server ) {
|
53 |
+
$birthdate = explode( '/', $date );
|
54 |
+
|
55 |
+
if ( isset( $birthdate[1] ) && ! empty( $birthdate[1] ) ) {
|
56 |
+
return $server->format_datetime( $birthdate[1] . '/' . $birthdate[0] . '/' . $birthdate[2] );
|
57 |
+
}
|
58 |
+
|
59 |
+
return '';
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Get formatted birthdate.
|
64 |
+
*
|
65 |
+
* @param string $date Date for format.
|
66 |
+
*
|
67 |
+
* @return string
|
68 |
+
*/
|
69 |
+
protected function get_formatted_birthdate( $date ) {
|
70 |
+
$birthdate = explode( '/', $date );
|
71 |
+
|
72 |
+
if ( isset( $birthdate[1] ) && ! empty( $birthdate[1] ) ) {
|
73 |
+
return sprintf( '%s-%s-%sT00:00:00', $birthdate[1], $birthdate[0], $birthdate[2] );
|
74 |
+
}
|
75 |
+
|
76 |
+
return '';
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Get person type.
|
81 |
+
*
|
82 |
+
* @param int $type Type.
|
83 |
+
*
|
84 |
+
* @return string
|
85 |
+
*/
|
86 |
+
protected function get_person_type( $type ) {
|
87 |
+
$settings = get_option( 'wcbcf_settings' );
|
88 |
+
|
89 |
+
switch ( intval( $settings['person_type'] ) ) {
|
90 |
+
case 1 :
|
91 |
+
$persontype = intval( $type ) === 2 ? 'J' : 'F';
|
92 |
+
break;
|
93 |
+
case 2 :
|
94 |
+
$persontype = 'F';
|
95 |
+
break;
|
96 |
+
case 3 :
|
97 |
+
$persontype = 'J';
|
98 |
+
break;
|
99 |
+
|
100 |
+
default :
|
101 |
+
$persontype = '';
|
102 |
+
break;
|
103 |
+
}
|
104 |
+
|
105 |
+
return $persontype;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Add extra fields in legacy order response.
|
110 |
+
*
|
111 |
+
* @param array $order_data Order response data..
|
112 |
+
* @param WC_Order $order Order object.
|
113 |
+
* @param array $fields Fields filter.
|
114 |
+
* @param WC_API_Server $server Server instance.
|
115 |
+
*
|
116 |
+
* @return array
|
117 |
+
*/
|
118 |
+
public function legacy_orders_response( $order_data, $order, $fields, $server ) {
|
119 |
+
// WooCommerce 3.0 or later.
|
120 |
+
if ( method_exists( $order, 'get_meta' ) ) {
|
121 |
+
// Billing fields.
|
122 |
+
$order_data['billing_address']['persontype'] = $this->get_person_type( $order->get_meta( '_billing_persontype' ) );
|
123 |
+
$order_data['billing_address']['cpf'] = $this->format_number( $order->get_meta( '_billing_cpf' ) );
|
124 |
+
$order_data['billing_address']['rg'] = $this->format_number( $order->get_meta( '_billing_rg' ) );
|
125 |
+
$order_data['billing_address']['cnpj'] = $this->format_number( $order->get_meta( '_billing_cnpj' ) );
|
126 |
+
$order_data['billing_address']['ie'] = $this->format_number( $order->get_meta( '_billing_ie' ) );
|
127 |
+
$order_data['billing_address']['birthdate'] = $this->get_formatted_birthdate_legacy( $order->get_meta( '_billing_birthdate' ), $server );
|
128 |
+
$order_data['billing_address']['sex'] = substr( $order->get_meta( '_billing_sex' ), 0, 1 );
|
129 |
+
$order_data['billing_address']['number'] = $order->get_meta( '_billing_number' );
|
130 |
+
$order_data['billing_address']['neighborhood'] = $order->get_meta( '_billing_neighborhood' );
|
131 |
+
$order_data['billing_address']['cellphone'] = $order->get_meta( '_billing_cellphone' );
|
132 |
+
|
133 |
+
// Shipping fields.
|
134 |
+
$order_data['shipping_address']['number'] = $order->get_meta( '_shipping_number' );
|
135 |
+
$order_data['shipping_address']['neighborhood'] = $order->get_meta( '_shipping_neighborhood' );
|
136 |
+
|
137 |
+
// Customer fields.
|
138 |
+
if ( 0 === intval( $order->customer_user ) && isset( $order_data['customer'] ) ) {
|
139 |
+
// Customer billing fields.
|
140 |
+
$order_data['customer']['billing_address']['persontype'] = $this->get_person_type( $order->get_meta( '_billing_persontype' ) );
|
141 |
+
$order_data['customer']['billing_address']['cpf'] = $this->format_number( $order->get_meta( '_billing_cpf' ) );
|
142 |
+
$order_data['customer']['billing_address']['rg'] = $this->format_number( $order->get_meta( '_billing_rg' ) );
|
143 |
+
$order_data['customer']['billing_address']['cnpj'] = $this->format_number( $order->get_meta( '_billing_cnpj' ) );
|
144 |
+
$order_data['customer']['billing_address']['ie'] = $this->format_number( $order->get_meta( '_billing_ie' ) );
|
145 |
+
$order_data['customer']['billing_address']['birthdate'] = $this->get_formatted_birthdate_legacy( $order->get_meta( '_billing_birthdate' ), $server );
|
146 |
+
$order_data['customer']['billing_address']['sex'] = substr( $order->get_meta( '_billing_sex' ), 0, 1 );
|
147 |
+
$order_data['customer']['billing_address']['number'] = $order->get_meta( '_billing_number' );
|
148 |
+
$order_data['customer']['billing_address']['neighborhood'] = $order->get_meta( '_billing_neighborhood' );
|
149 |
+
$order_data['customer']['billing_address']['cellphone'] = $order->get_meta( '_billing_cellphone' );
|
150 |
+
|
151 |
+
// Customer shipping fields.
|
152 |
+
$order_data['customer']['shipping_address']['number'] = $order->get_meta( '_shipping_number' );
|
153 |
+
$order_data['customer']['shipping_address']['neighborhood'] = $order->get_meta( '_shipping_neighborhood' );
|
154 |
+
}
|
155 |
+
} else {
|
156 |
+
// Billing fields.
|
157 |
+
$order_data['billing_address']['persontype'] = $this->get_person_type( $order->billing_persontype );
|
158 |
+
$order_data['billing_address']['cpf'] = $this->format_number( $order->billing_cpf );
|
159 |
+
$order_data['billing_address']['rg'] = $this->format_number( $order->billing_rg );
|
160 |
+
$order_data['billing_address']['cnpj'] = $this->format_number( $order->billing_cnpj );
|
161 |
+
$order_data['billing_address']['ie'] = $this->format_number( $order->billing_ie );
|
162 |
+
$order_data['billing_address']['birthdate'] = $this->get_formatted_birthdate_legacy( $order->billing_birthdate, $server );
|
163 |
+
$order_data['billing_address']['sex'] = substr( $order->billing_sex, 0, 1 );
|
164 |
+
$order_data['billing_address']['number'] = $order->billing_number;
|
165 |
+
$order_data['billing_address']['neighborhood'] = $order->billing_neighborhood;
|
166 |
+
$order_data['billing_address']['cellphone'] = $order->billing_cellphone;
|
167 |
+
|
168 |
+
// Shipping fields.
|
169 |
+
$order_data['shipping_address']['number'] = $order->shipping_number;
|
170 |
+
$order_data['shipping_address']['neighborhood'] = $order->shipping_neighborhood;
|
171 |
+
|
172 |
+
// Customer fields.
|
173 |
+
if ( 0 === intval( $order->customer_user ) && isset( $order_data['customer'] ) ) {
|
174 |
+
// Customer billing fields.
|
175 |
+
$order_data['customer']['billing_address']['persontype'] = $this->get_person_type( $order->billing_persontype );
|
176 |
+
$order_data['customer']['billing_address']['cpf'] = $this->format_number( $order->billing_cpf );
|
177 |
+
$order_data['customer']['billing_address']['rg'] = $this->format_number( $order->billing_rg );
|
178 |
+
$order_data['customer']['billing_address']['cnpj'] = $this->format_number( $order->billing_cnpj );
|
179 |
+
$order_data['customer']['billing_address']['ie'] = $this->format_number( $order->billing_ie );
|
180 |
+
$order_data['customer']['billing_address']['birthdate'] = $this->get_formatted_birthdate_legacy( $order->billing_birthdate, $server );
|
181 |
+
$order_data['customer']['billing_address']['sex'] = substr( $order->billing_sex, 0, 1 );
|
182 |
+
$order_data['customer']['billing_address']['number'] = $order->billing_number;
|
183 |
+
$order_data['customer']['billing_address']['neighborhood'] = $order->billing_neighborhood;
|
184 |
+
$order_data['customer']['billing_address']['cellphone'] = $order->billing_cellphone;
|
185 |
+
|
186 |
+
// Customer shipping fields.
|
187 |
+
$order_data['customer']['shipping_address']['number'] = $order->shipping_number;
|
188 |
+
$order_data['customer']['shipping_address']['neighborhood'] = $order->shipping_neighborhood;
|
189 |
+
}
|
190 |
+
} // End if().
|
191 |
+
|
192 |
+
if ( $fields ) {
|
193 |
+
$order_data = WC()->api->WC_API_Customers->filter_response_fields( $order_data, $order, $fields );
|
194 |
+
}
|
195 |
+
|
196 |
+
return $order_data;
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Add extra fields in legacy customers response.
|
201 |
+
*
|
202 |
+
* @param array $customer_data Customer response data..
|
203 |
+
* @param WC_Customer $customer Customer object.
|
204 |
+
* @param array $fields Fields filter.
|
205 |
+
* @param WC_API_Server $server Server instance.
|
206 |
+
*
|
207 |
+
* @return array
|
208 |
+
*/
|
209 |
+
public function legacy_customers_response( $customer_data, $customer, $fields, $server ) {
|
210 |
+
// WooCommerce 3.0 or later.
|
211 |
+
if ( method_exists( $customer, 'get_meta' ) ) {
|
212 |
+
// Billing fields.
|
213 |
+
$customer_data['billing_address']['persontype'] = $this->get_person_type( $customer->get_meta( 'billing_persontype' ) );
|
214 |
+
$customer_data['billing_address']['cpf'] = $this->format_number( $customer->get_meta( 'billing_cpf' ) );
|
215 |
+
$customer_data['billing_address']['rg'] = $this->format_number( $customer->get_meta( 'billing_rg' ) );
|
216 |
+
$customer_data['billing_address']['cnpj'] = $this->format_number( $customer->get_meta( 'billing_cnpj' ) );
|
217 |
+
$customer_data['billing_address']['ie'] = $this->format_number( $customer->get_meta( 'billing_ie' ) );
|
218 |
+
$customer_data['billing_address']['birthdate'] = $this->get_formatted_birthdate_legacy( $customer->get_meta( 'billing_birthdate' ), $server );
|
219 |
+
$customer_data['billing_address']['sex'] = substr( $customer->get_meta( 'billing_sex' ), 0, 1 );
|
220 |
+
$customer_data['billing_address']['number'] = $customer->get_meta( 'billing_number' );
|
221 |
+
$customer_data['billing_address']['neighborhood'] = $customer->get_meta( 'billing_neighborhood' );
|
222 |
+
$customer_data['billing_address']['cellphone'] = $customer->get_meta( 'billing_cellphone' );
|
223 |
+
|
224 |
+
// Shipping fields.
|
225 |
+
$customer_data['shipping_address']['number'] = $customer->get_meta( 'shipping_number' );
|
226 |
+
$customer_data['shipping_address']['neighborhood'] = $customer->get_meta( 'shipping_neighborhood' );
|
227 |
+
} else {
|
228 |
+
// Billing fields.
|
229 |
+
$customer_data['billing_address']['persontype'] = $this->get_person_type( $customer->billing_persontype );
|
230 |
+
$customer_data['billing_address']['cpf'] = $this->format_number( $customer->billing_cpf );
|
231 |
+
$customer_data['billing_address']['rg'] = $this->format_number( $customer->billing_rg );
|
232 |
+
$customer_data['billing_address']['cnpj'] = $this->format_number( $customer->billing_cnpj );
|
233 |
+
$customer_data['billing_address']['ie'] = $this->format_number( $customer->billing_ie );
|
234 |
+
$customer_data['billing_address']['birthdate'] = $this->get_formatted_birthdate_legacy( $customer->billing_birthdate, $server );
|
235 |
+
$customer_data['billing_address']['sex'] = substr( $customer->billing_sex, 0, 1 );
|
236 |
+
$customer_data['billing_address']['number'] = $customer->billing_number;
|
237 |
+
$customer_data['billing_address']['neighborhood'] = $customer->billing_neighborhood;
|
238 |
+
$customer_data['billing_address']['cellphone'] = $customer->billing_cellphone;
|
239 |
+
|
240 |
+
// Shipping fields.
|
241 |
+
$customer_data['shipping_address']['number'] = $customer->shipping_number;
|
242 |
+
$customer_data['shipping_address']['neighborhood'] = $customer->shipping_neighborhood;
|
243 |
+
}
|
244 |
+
|
245 |
+
if ( $fields ) {
|
246 |
+
$customer_data = WC()->api->WC_API_Customers->filter_response_fields( $customer_data, $customer, $fields );
|
247 |
+
}
|
248 |
+
|
249 |
+
return $customer_data;
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Add extra fields in customers response.
|
254 |
+
*
|
255 |
+
* @param WP_REST_Response $response The response object.
|
256 |
+
* @param WP_User $user User object used to create response.
|
257 |
+
*
|
258 |
+
* @return WP_REST_Response
|
259 |
+
*/
|
260 |
+
public function customers_response( $response, $user ) {
|
261 |
+
$customer = new WC_Customer( $user->ID );
|
262 |
+
|
263 |
+
// WooCommerce 3.0 or later.
|
264 |
+
if ( method_exists( $customer, 'get_meta' ) ) {
|
265 |
+
// Billing fields.
|
266 |
+
$response->data['billing']['number'] = $customer->get_meta( 'billing_number' );
|
267 |
+
$response->data['billing']['neighborhood'] = $customer->get_meta( 'billing_neighborhood' );
|
268 |
+
$response->data['billing']['persontype'] = $this->get_person_type( $customer->get_meta( 'billing_persontype' ) );
|
269 |
+
$response->data['billing']['cpf'] = $this->format_number( $customer->get_meta( 'billing_cpf' ) );
|
270 |
+
$response->data['billing']['rg'] = $this->format_number( $customer->get_meta( 'billing_rg' ) );
|
271 |
+
$response->data['billing']['cnpj'] = $this->format_number( $customer->get_meta( 'billing_cnpj' ) );
|
272 |
+
$response->data['billing']['ie'] = $this->format_number( $customer->get_meta( 'billing_ie' ) );
|
273 |
+
$response->data['billing']['birthdate'] = $this->get_formatted_birthdate( $customer->get_meta( 'billing_birthdate' ) );
|
274 |
+
$response->data['billing']['sex'] = substr( $customer->get_meta( 'billing_sex' ), 0, 1 );
|
275 |
+
$response->data['billing']['cellphone'] = $customer->get_meta( 'billing_cellphone' );
|
276 |
+
|
277 |
+
// Shipping fields.
|
278 |
+
$response->data['shipping']['number'] = $customer->get_meta( 'shipping_number' );
|
279 |
+
$response->data['shipping']['neighborhood'] = $customer->get_meta( 'shipping_neighborhood' );
|
280 |
+
} else {
|
281 |
+
// Billing fields.
|
282 |
+
$response->data['billing']['number'] = $customer->billing_number;
|
283 |
+
$response->data['billing']['neighborhood'] = $customer->billing_neighborhood;
|
284 |
+
$response->data['billing']['persontype'] = $this->get_person_type( $customer->billing_persontype );
|
285 |
+
$response->data['billing']['cpf'] = $this->format_number( $customer->billing_cpf );
|
286 |
+
$response->data['billing']['rg'] = $this->format_number( $customer->billing_rg );
|
287 |
+
$response->data['billing']['cnpj'] = $this->format_number( $customer->billing_cnpj );
|
288 |
+
$response->data['billing']['ie'] = $this->format_number( $customer->billing_ie );
|
289 |
+
$response->data['billing']['birthdate'] = $this->get_formatted_birthdate( $customer->billing_birthdate );
|
290 |
+
$response->data['billing']['sex'] = substr( $customer->billing_sex, 0, 1 );
|
291 |
+
$response->data['billing']['cellphone'] = $customer->billing_cellphone;
|
292 |
+
|
293 |
+
// Shipping fields.
|
294 |
+
$response->data['shipping']['number'] = $customer->shipping_number;
|
295 |
+
$response->data['shipping']['neighborhood'] = $customer->shipping_neighborhood;
|
296 |
+
}
|
297 |
+
|
298 |
+
return $response;
|
299 |
+
}
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Add extra fields in orders v1 response.
|
303 |
+
*
|
304 |
+
* @param WP_REST_Response $response The response object.
|
305 |
+
* @param WP_Post $post Post object.
|
306 |
+
*
|
307 |
+
* @return WP_REST_Response
|
308 |
+
*/
|
309 |
+
public function orders_v1_response( $response, $post ) {
|
310 |
+
$order = wc_get_order( $post->ID );
|
311 |
+
|
312 |
+
// WooCommerce 3.0 or later.
|
313 |
+
if ( method_exists( $order, 'get_meta' ) ) {
|
314 |
+
return $this->orders_response( $response, $order );
|
315 |
+
} else {
|
316 |
+
// Billing fields.
|
317 |
+
$response->data['billing']['number'] = $order->billing_number;
|
318 |
+
$response->data['billing']['neighborhood'] = $order->billing_neighborhood;
|
319 |
+
$response->data['billing']['persontype'] = $this->get_person_type( $order->billing_persontype );
|
320 |
+
$response->data['billing']['cpf'] = $this->format_number( $order->billing_cpf );
|
321 |
+
$response->data['billing']['rg'] = $this->format_number( $order->billing_rg );
|
322 |
+
$response->data['billing']['cnpj'] = $this->format_number( $order->billing_cnpj );
|
323 |
+
$response->data['billing']['ie'] = $this->format_number( $order->billing_ie );
|
324 |
+
$response->data['billing']['birthdate'] = $this->get_formatted_birthdate( $order->billing_birthdate );
|
325 |
+
$response->data['billing']['sex'] = substr( $order->billing_sex, 0, 1 );
|
326 |
+
$response->data['billing']['cellphone'] = $order->billing_cellphone;
|
327 |
+
|
328 |
+
// Shipping fields.
|
329 |
+
$response->data['shipping']['number'] = $order->shipping_number;
|
330 |
+
$response->data['shipping']['neighborhood'] = $order->shipping_neighborhood;
|
331 |
+
}
|
332 |
+
|
333 |
+
return $response;
|
334 |
+
}
|
335 |
+
|
336 |
+
/**
|
337 |
+
* Add extra fields in orders response.
|
338 |
+
*
|
339 |
+
* @param WP_REST_Response $response The response object.
|
340 |
+
* @param WC_Order $order Order object.
|
341 |
+
*
|
342 |
+
* @return WP_REST_Response
|
343 |
+
*/
|
344 |
+
public function orders_response( $response, $order ) {
|
345 |
+
// Billing fields.
|
346 |
+
$response->data['billing']['number'] = $order->get_meta( '_billing_number' );
|
347 |
+
$response->data['billing']['neighborhood'] = $order->get_meta( '_billing_neighborhood' );
|
348 |
+
$response->data['billing']['persontype'] = $this->get_person_type( $order->get_meta( '_billing_persontype' ) );
|
349 |
+
$response->data['billing']['cpf'] = $this->format_number( $order->get_meta( '_billing_cpf' ) );
|
350 |
+
$response->data['billing']['rg'] = $this->format_number( $order->get_meta( '_billing_rg' ) );
|
351 |
+
$response->data['billing']['cnpj'] = $this->format_number( $order->get_meta( '_billing_cnpj' ) );
|
352 |
+
$response->data['billing']['ie'] = $this->format_number( $order->get_meta( '_billing_ie' ) );
|
353 |
+
$response->data['billing']['birthdate'] = $this->get_formatted_birthdate( $order->get_meta( '_billing_birthdate' ) );
|
354 |
+
$response->data['billing']['sex'] = substr( $order->get_meta( '_billing_sex' ), 0, 1 );
|
355 |
+
$response->data['billing']['cellphone'] = $order->get_meta( '_billing_cellphone' );
|
356 |
+
|
357 |
+
// Shipping fields.
|
358 |
+
$response->data['shipping']['number'] = $order->get_meta( '_shipping_number' );
|
359 |
+
$response->data['shipping']['neighborhood'] = $order->get_meta( '_shipping_neighborhood' );
|
360 |
+
|
361 |
+
return $response;
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* Addresses schena.
|
366 |
+
*
|
367 |
+
* @param array $properties Default schema properties.
|
368 |
+
*
|
369 |
+
* @return array
|
370 |
+
*/
|
371 |
+
public function addresses_schema( $properties ) {
|
372 |
+
$properties['billing']['properties']['number'] = array(
|
373 |
+
'description' => __( 'Number.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
374 |
+
'type' => 'string',
|
375 |
+
'context' => array( 'view', 'edit' ),
|
376 |
+
);
|
377 |
+
$properties['billing']['properties']['neighborhood'] = array(
|
378 |
+
'description' => __( 'Neighborhood.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
379 |
+
'type' => 'string',
|
380 |
+
'context' => array( 'view', 'edit' ),
|
381 |
+
);
|
382 |
+
$properties['billing']['properties']['persontype'] = array(
|
383 |
+
'description' => __( 'Person type.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
384 |
+
'type' => 'string',
|
385 |
+
'context' => array( 'view', 'edit' ),
|
386 |
+
);
|
387 |
+
$properties['billing']['properties']['cpf'] = array(
|
388 |
+
'description' => __( 'CPF.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
389 |
+
'type' => 'string',
|
390 |
+
'context' => array( 'view', 'edit' ),
|
391 |
+
);
|
392 |
+
$properties['billing']['properties']['rg'] = array(
|
393 |
+
'description' => __( 'RG.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
394 |
+
'type' => 'string',
|
395 |
+
'context' => array( 'view', 'edit' ),
|
396 |
+
);
|
397 |
+
$properties['billing']['properties']['cnpj'] = array(
|
398 |
+
'description' => __( 'CNPJ.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
399 |
+
'type' => 'string',
|
400 |
+
'context' => array( 'view', 'edit' ),
|
401 |
+
);
|
402 |
+
$properties['billing']['properties']['ie'] = array(
|
403 |
+
'description' => __( 'IE.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
404 |
+
'type' => 'string',
|
405 |
+
'context' => array( 'view', 'edit' ),
|
406 |
+
);
|
407 |
+
$properties['billing']['properties']['birthdate'] = array(
|
408 |
+
'description' => __( 'Birthdate.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
409 |
+
'type' => 'string',
|
410 |
+
'context' => array( 'view', 'edit' ),
|
411 |
+
);
|
412 |
+
$properties['billing']['properties']['sex'] = array(
|
413 |
+
'description' => __( 'Gender.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
414 |
+
'type' => 'string',
|
415 |
+
'context' => array( 'view', 'edit' ),
|
416 |
+
);
|
417 |
+
$properties['billing']['properties']['cellphone'] = array(
|
418 |
+
'description' => __( 'Cell Phone.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
419 |
+
'type' => 'string',
|
420 |
+
'context' => array( 'view', 'edit' ),
|
421 |
+
);
|
422 |
+
$properties['shipping']['properties']['number'] = array(
|
423 |
+
'description' => __( 'Number.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
424 |
+
'type' => 'string',
|
425 |
+
'context' => array( 'view', 'edit' ),
|
426 |
+
);
|
427 |
+
$properties['shipping']['properties']['neighborhood'] = array(
|
428 |
+
'description' => __( 'Neighborhood.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
429 |
+
'type' => 'string',
|
430 |
+
'context' => array( 'view', 'edit' ),
|
431 |
+
);
|
432 |
+
|
433 |
+
return $properties;
|
434 |
+
}
|
435 |
+
}
|
436 |
+
|
437 |
+
new Extra_Checkout_Fields_For_Brazil_API();
|
includes/{class-wc-ecfb-formatting.php → class-extra-checkout-fields-for-brazil-formatting.php}
RENAMED
@@ -1,24 +1,30 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
exit; // Exit if accessed directly.
|
4 |
}
|
5 |
|
6 |
/**
|
7 |
-
*
|
8 |
*/
|
9 |
class Extra_Checkout_Fields_For_Brazil_Formatting {
|
10 |
|
11 |
/**
|
12 |
* Checks if the CPF is valid.
|
13 |
*
|
14 |
-
* @param string $cpf
|
15 |
*
|
16 |
* @return bool
|
17 |
*/
|
18 |
public static function is_cpf( $cpf ) {
|
19 |
$cpf = preg_replace( '/[^0-9]/', '', $cpf );
|
20 |
|
21 |
-
if ( 11
|
22 |
return false;
|
23 |
}
|
24 |
|
@@ -27,28 +33,28 @@ class Extra_Checkout_Fields_For_Brazil_Formatting {
|
|
27 |
for ( $j = 10; $j <= 11; $j++ ) {
|
28 |
$sum = 0;
|
29 |
|
30 |
-
for( $i = 0; $i< $j-1; $i++ ) {
|
31 |
-
$sum += ( $j - $i ) * (
|
32 |
}
|
33 |
|
34 |
$summod11 = $sum % 11;
|
35 |
$digit[ $j - 1 ] = $summod11 < 2 ? 0 : 11 - $summod11;
|
36 |
}
|
37 |
|
38 |
-
return $digit[9]
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
* Checks if the CNPJ is valid.
|
43 |
*
|
44 |
-
* @param string $cnpj
|
45 |
*
|
46 |
* @return bool
|
47 |
*/
|
48 |
public static function is_cnpj( $cnpj ) {
|
49 |
$cnpj = sprintf( '%014s', preg_replace( '{\D}', '', $cnpj ) );
|
50 |
|
51 |
-
if ( 14
|
52 |
return false;
|
53 |
}
|
54 |
|
@@ -57,7 +63,7 @@ class Extra_Checkout_Fields_For_Brazil_Formatting {
|
|
57 |
$d += $cnpj[ $c ] * $p;
|
58 |
}
|
59 |
|
60 |
-
if ( $cnpj[ ++$t ]
|
61 |
return false;
|
62 |
}
|
63 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Extra checkout fields formatting methods.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Formatting
|
6 |
+
*/
|
7 |
+
|
8 |
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
exit; // Exit if accessed directly.
|
10 |
}
|
11 |
|
12 |
/**
|
13 |
+
* Extra_Checkout_Fields_For_Brazil_Formatting class.
|
14 |
*/
|
15 |
class Extra_Checkout_Fields_For_Brazil_Formatting {
|
16 |
|
17 |
/**
|
18 |
* Checks if the CPF is valid.
|
19 |
*
|
20 |
+
* @param string $cpf CPF to validate.
|
21 |
*
|
22 |
* @return bool
|
23 |
*/
|
24 |
public static function is_cpf( $cpf ) {
|
25 |
$cpf = preg_replace( '/[^0-9]/', '', $cpf );
|
26 |
|
27 |
+
if ( 11 !== strlen( $cpf ) || preg_match( '/^([0-9])\1+$/', $cpf ) ) {
|
28 |
return false;
|
29 |
}
|
30 |
|
33 |
for ( $j = 10; $j <= 11; $j++ ) {
|
34 |
$sum = 0;
|
35 |
|
36 |
+
for ( $i = 0; $i < $j - 1; $i++ ) {
|
37 |
+
$sum += ( $j - $i ) * intval( $digit[ $i ] );
|
38 |
}
|
39 |
|
40 |
$summod11 = $sum % 11;
|
41 |
$digit[ $j - 1 ] = $summod11 < 2 ? 0 : 11 - $summod11;
|
42 |
}
|
43 |
|
44 |
+
return intval( $digit[9] ) === intval( $cpf[9] ) && intval( $digit[10] ) === intval( $cpf[10] );
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
* Checks if the CNPJ is valid.
|
49 |
*
|
50 |
+
* @param string $cnpj CNPJ to validate.
|
51 |
*
|
52 |
* @return bool
|
53 |
*/
|
54 |
public static function is_cnpj( $cnpj ) {
|
55 |
$cnpj = sprintf( '%014s', preg_replace( '{\D}', '', $cnpj ) );
|
56 |
|
57 |
+
if ( 14 !== strlen( $cnpj ) || 0 === intval( substr( $cnpj, -4 ) ) ) {
|
58 |
return false;
|
59 |
}
|
60 |
|
63 |
$d += $cnpj[ $c ] * $p;
|
64 |
}
|
65 |
|
66 |
+
if ( $cnpj[ ++$t ] !== ( $d = ( ( 10 * $d ) % 11 ) % 10 ) ) {
|
67 |
return false;
|
68 |
}
|
69 |
}
|
includes/{class-wc-ecfb-front-end.php → class-extra-checkout-fields-for-brazil-front-end.php}
RENAMED
@@ -1,10 +1,16 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
exit; // Exit if accessed directly.
|
4 |
}
|
5 |
|
6 |
/**
|
7 |
-
*
|
8 |
*/
|
9 |
class Extra_Checkout_Fields_For_Brazil_Front_End {
|
10 |
|
@@ -12,9 +18,6 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
12 |
* Initialize the front-end actions.
|
13 |
*/
|
14 |
public function __construct() {
|
15 |
-
// Load custom order data.
|
16 |
-
add_filter( 'woocommerce_load_order_data', array( $this, 'load_order_data' ) );
|
17 |
-
|
18 |
// Load public-facing scripts.
|
19 |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
20 |
add_action( 'woocommerce_after_edit_account_address_form', array( $this, 'load_scripts' ) );
|
@@ -38,45 +41,17 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
38 |
add_filter( 'woocommerce_get_order_address', array( $this, 'order_address' ), 10, 3 );
|
39 |
}
|
40 |
|
41 |
-
/**
|
42 |
-
* Load order custom data.
|
43 |
-
*
|
44 |
-
* @param array $data Default WC_Order data.
|
45 |
-
*
|
46 |
-
* @return array Custom WC_Order data.
|
47 |
-
*/
|
48 |
-
public function load_order_data( $data ) {
|
49 |
-
|
50 |
-
// Billing
|
51 |
-
$data['billing_persontype'] = '';
|
52 |
-
$data['billing_cpf'] = '';
|
53 |
-
$data['billing_rg'] = '';
|
54 |
-
$data['billing_cnpj'] = '';
|
55 |
-
$data['billing_ie'] = '';
|
56 |
-
$data['billing_birthdate'] = '';
|
57 |
-
$data['billing_sex'] = '';
|
58 |
-
$data['billing_number'] = '';
|
59 |
-
$data['billing_neighborhood'] = '';
|
60 |
-
$data['billing_cellphone'] = '';
|
61 |
-
|
62 |
-
// Shipping
|
63 |
-
$data['shipping_number'] = '';
|
64 |
-
$data['shipping_neighborhood'] = '';
|
65 |
-
|
66 |
-
return $data;
|
67 |
-
}
|
68 |
-
|
69 |
/**
|
70 |
* Register scripts.
|
71 |
*/
|
72 |
public function enqueue_scripts() {
|
73 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
74 |
|
75 |
-
wp_register_script( 'jquery-
|
76 |
|
77 |
wp_register_script( 'mailcheck', plugins_url( 'assets/js/mailcheck/mailcheck' . $suffix . '.js', plugin_dir_path( __FILE__ ) ), array( 'jquery' ), '1.1.1', true );
|
78 |
|
79 |
-
wp_register_script( 'woocommerce-extra-checkout-fields-for-brazil-front', plugins_url( 'assets/js/frontend/frontend' . $suffix . '.js', plugin_dir_path( __FILE__ ) ), array( 'jquery', 'jquery-
|
80 |
|
81 |
$settings = get_option( 'wcbcf_settings' );
|
82 |
$autofill = isset( $settings['addresscomplete'] ) ? 'yes' : 'no';
|
@@ -84,13 +59,14 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
84 |
'woocommerce-extra-checkout-fields-for-brazil-front',
|
85 |
'wcbcf_public_params',
|
86 |
array(
|
87 |
-
'state'
|
88 |
-
'required'
|
89 |
-
'mailcheck'
|
90 |
-
'maskedinput'
|
91 |
-
'addresscomplete'
|
92 |
-
'person_type'
|
93 |
-
'only_brazil'
|
|
|
94 |
)
|
95 |
);
|
96 |
}
|
@@ -113,7 +89,8 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
113 |
$new_fields = array();
|
114 |
|
115 |
// Get plugin settings.
|
116 |
-
$settings
|
|
|
117 |
|
118 |
if ( isset( $fields['billing_first_name'] ) ) {
|
119 |
$new_fields['billing_first_name'] = $fields['billing_first_name'];
|
@@ -125,8 +102,8 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
125 |
$new_fields['billing_last_name']['class'] = array( 'form-row-last' );
|
126 |
}
|
127 |
|
128 |
-
if ( 0
|
129 |
-
if ( 1
|
130 |
$new_fields['billing_persontype'] = array(
|
131 |
'type' => 'select',
|
132 |
'label' => __( 'Person type', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
@@ -135,42 +112,49 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
135 |
'options' => array(
|
136 |
'0' => __( 'Select', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
137 |
'1' => __( 'Individuals', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
138 |
-
'2' => __( 'Legal Person', 'woocommerce-extra-checkout-fields-for-brazil' )
|
139 |
-
)
|
|
|
140 |
);
|
141 |
}
|
142 |
|
143 |
-
if ( 1
|
144 |
if ( isset( $settings['rg'] ) ) {
|
145 |
$new_fields['billing_cpf'] = array(
|
146 |
'label' => __( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
147 |
'placeholder' => _x( 'CPF', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
148 |
'class' => array( 'form-row-first', 'person-type-field' ),
|
149 |
-
'required' => false
|
|
|
|
|
150 |
);
|
151 |
|
152 |
$new_fields['billing_rg'] = array(
|
153 |
'label' => __( 'RG', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
154 |
'placeholder' => _x( 'RG', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
155 |
'class' => array( 'form-row-last', 'person-type-field' ),
|
156 |
-
'required' => false
|
|
|
157 |
);
|
158 |
} else {
|
159 |
$new_fields['billing_cpf'] = array(
|
160 |
'label' => __( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
161 |
'placeholder' => _x( 'CPF', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
162 |
'class' => array( 'form-row-wide', 'person-type-field' ),
|
163 |
-
'required' => false
|
|
|
|
|
164 |
);
|
165 |
}
|
166 |
}
|
167 |
|
168 |
-
if ( 1
|
169 |
if ( isset( $fields['billing_company'] ) ) {
|
170 |
$new_fields['billing_company'] = $fields['billing_company'];
|
171 |
$new_fields['billing_company']['class'] = array( 'form-row-wide' );
|
172 |
$new_fields['billing_company']['clear'] = true;
|
173 |
$new_fields['billing_company']['required'] = false;
|
|
|
174 |
}
|
175 |
|
176 |
if ( isset( $settings['ie'] ) ) {
|
@@ -178,32 +162,36 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
178 |
'label' => __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
179 |
'placeholder' => _x( 'CNPJ', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
180 |
'class' => array( 'form-row-first', 'person-type-field' ),
|
181 |
-
'required' => false
|
|
|
|
|
182 |
);
|
183 |
|
184 |
$new_fields['billing_ie'] = array(
|
185 |
'label' => __( 'State Registration', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
186 |
'placeholder' => _x( 'State Registration', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
187 |
'class' => array( 'form-row-last', 'person-type-field' ),
|
188 |
-
'required' => false
|
|
|
189 |
);
|
190 |
} else {
|
191 |
$new_fields['billing_cnpj'] = array(
|
192 |
'label' => __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
193 |
'placeholder' => _x( 'CNPJ', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
194 |
'class' => array( 'form-row-wide', 'person-type-field' ),
|
195 |
-
'required' => false
|
|
|
|
|
196 |
);
|
197 |
}
|
198 |
}
|
199 |
-
|
200 |
} else {
|
201 |
if ( isset( $fields['billing_company'] ) ) {
|
202 |
$new_fields['billing_company'] = $fields['billing_company'];
|
203 |
$new_fields['billing_company']['class'] = array( 'form-row-wide' );
|
204 |
$new_fields['billing_company']['clear'] = true;
|
205 |
}
|
206 |
-
}
|
207 |
|
208 |
if ( isset( $settings['birthdate_sex'] ) ) {
|
209 |
$new_fields['billing_birthdate'] = array(
|
@@ -211,7 +199,8 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
211 |
'placeholder' => _x( 'Birthdate', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
212 |
'class' => array( 'form-row-first' ),
|
213 |
'clear' => false,
|
214 |
-
'required' => true
|
|
|
215 |
);
|
216 |
|
217 |
$new_fields['billing_sex'] = array(
|
@@ -223,8 +212,9 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
223 |
'options' => array(
|
224 |
'' => __( 'Select', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
225 |
__( 'Female', 'woocommerce-extra-checkout-fields-for-brazil' ) => __( 'Female', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
226 |
-
__( 'Male', 'woocommerce-extra-checkout-fields-for-brazil' ) => __( 'Male', 'woocommerce-extra-checkout-fields-for-brazil' )
|
227 |
-
)
|
|
|
228 |
);
|
229 |
}
|
230 |
|
@@ -236,6 +226,7 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
236 |
if ( isset( $fields['billing_postcode'] ) ) {
|
237 |
$new_fields['billing_postcode'] = $fields['billing_postcode'];
|
238 |
$new_fields['billing_postcode']['class'] = array( 'form-row-last', 'address-field' );
|
|
|
239 |
}
|
240 |
|
241 |
if ( isset( $fields['billing_address_1'] ) ) {
|
@@ -248,7 +239,8 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
248 |
'placeholder' => _x( 'Number', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
249 |
'class' => array( 'form-row-last', 'address-field' ),
|
250 |
'clear' => true,
|
251 |
-
'required' => true
|
|
|
252 |
);
|
253 |
|
254 |
if ( isset( $fields['billing_address_2'] ) ) {
|
@@ -263,6 +255,7 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
263 |
'placeholder' => _x( 'Neighborhood', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
264 |
'class' => array( 'form-row-last', 'address-field' ),
|
265 |
'clear' => true,
|
|
|
266 |
);
|
267 |
|
268 |
if ( isset( $fields['billing_city'] ) ) {
|
@@ -288,15 +281,16 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
288 |
'label' => __( 'Cell Phone', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
289 |
'placeholder' => _x( 'Cell Phone', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
290 |
'class' => array( 'form-row-last' ),
|
291 |
-
'clear' => true
|
|
|
292 |
);
|
293 |
|
294 |
if ( isset( $fields['billing_email'] ) ) {
|
295 |
$new_fields['billing_email'] = $fields['billing_email'];
|
296 |
$new_fields['billing_email']['class'] = array( 'form-row-wide' );
|
297 |
$new_fields['billing_email']['clear'] = true;
|
|
|
298 |
}
|
299 |
-
|
300 |
} else {
|
301 |
if ( isset( $fields['billing_phone'] ) ) {
|
302 |
$new_fields['billing_phone'] = $fields['billing_phone'];
|
@@ -308,8 +302,8 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
308 |
$new_fields['billing_email'] = $fields['billing_email'];
|
309 |
$new_fields['billing_email']['class'] = array( 'form-row-wide' );
|
310 |
$new_fields['billing_email']['clear'] = true;
|
|
|
311 |
}
|
312 |
-
|
313 |
}
|
314 |
|
315 |
return apply_filters( 'wcbcf_billing_fields', $new_fields );
|
@@ -349,6 +343,7 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
349 |
if ( isset( $fields['shipping_postcode'] ) ) {
|
350 |
$new_fields['shipping_postcode'] = $fields['shipping_postcode'];
|
351 |
$new_fields['shipping_postcode']['class'] = array( 'form-row-last', 'address-field' );
|
|
|
352 |
}
|
353 |
|
354 |
if ( isset( $fields['shipping_address_1'] ) ) {
|
@@ -361,7 +356,8 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
361 |
'placeholder' => _x( 'Number', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
362 |
'class' => array( 'form-row-last', 'address-field' ),
|
363 |
'clear' => true,
|
364 |
-
'required' => true
|
|
|
365 |
);
|
366 |
|
367 |
if ( isset( $fields['shipping_address_2'] ) ) {
|
@@ -404,19 +400,20 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
404 |
|
405 |
// Get plugin settings.
|
406 |
$settings = get_option( 'wcbcf_settings' );
|
|
|
407 |
$only_brazil = isset( $settings['only_brazil'] ) ? true : false;
|
408 |
-
$billing_persontype = isset( $_POST['billing_persontype'] ) ? $_POST['billing_persontype'] : 0;
|
409 |
|
410 |
-
if ( $only_brazil && 'BR'
|
411 |
return;
|
412 |
}
|
413 |
|
414 |
-
if ( 0
|
415 |
wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'Person type', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is a required field', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
|
416 |
} else {
|
417 |
|
418 |
// Check CPF.
|
419 |
-
if ( ( 1
|
420 |
if ( empty( $_POST['billing_cpf'] ) ) {
|
421 |
wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is a required field', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
|
422 |
}
|
@@ -431,7 +428,7 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
431 |
}
|
432 |
|
433 |
// Check Company and CPNJ.
|
434 |
-
if ( ( 1
|
435 |
if ( empty( $_POST['billing_company'] ) ) {
|
436 |
wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'Company', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is a required field', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
|
437 |
}
|
@@ -440,7 +437,7 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
440 |
wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is a required field', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
|
441 |
}
|
442 |
|
443 |
-
if ( isset( $settings['validate_cnpj'] ) && ! empty( $_POST['billing_cnpj'] ) && ! Extra_Checkout_Fields_For_Brazil_Formatting::is_cnpj( $_POST['billing_cnpj'] ) ) {
|
444 |
wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is not valid', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
|
445 |
}
|
446 |
|
@@ -448,7 +445,7 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
448 |
wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'State Registration', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is a required field', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
|
449 |
}
|
450 |
}
|
451 |
-
}
|
452 |
}
|
453 |
|
454 |
/**
|
@@ -473,10 +470,8 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
473 |
* @return array New replacements.
|
474 |
*/
|
475 |
public function formatted_address_replacements( $replacements, $args ) {
|
476 |
-
|
477 |
-
|
478 |
-
$replacements['{number}'] = $number;
|
479 |
-
$replacements['{neighborhood}'] = $neighborhood;
|
480 |
|
481 |
return $replacements;
|
482 |
}
|
@@ -484,14 +479,20 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
484 |
/**
|
485 |
* Custom order formatted billing address.
|
486 |
*
|
487 |
-
* @param array
|
488 |
-
* @param object $order
|
489 |
*
|
490 |
-
* @return array
|
491 |
*/
|
492 |
public function order_formatted_billing_address( $address, $order ) {
|
493 |
-
|
494 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
|
496 |
return $address;
|
497 |
}
|
@@ -499,14 +500,20 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
499 |
/**
|
500 |
* Custom order formatted shipping address.
|
501 |
*
|
502 |
-
* @param array
|
503 |
-
* @param object $order
|
504 |
*
|
505 |
-
* @return array
|
506 |
*/
|
507 |
public function order_formatted_shipping_address( $address, $order ) {
|
508 |
-
|
509 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
510 |
|
511 |
return $address;
|
512 |
}
|
@@ -514,11 +521,11 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
514 |
/**
|
515 |
* Custom my address formatted address.
|
516 |
*
|
517 |
-
* @param array
|
518 |
-
* @param int
|
519 |
-
* @param string $name
|
520 |
*
|
521 |
-
* @return array
|
522 |
*/
|
523 |
public function my_account_my_address_formatted_address( $address, $customer_id, $name ) {
|
524 |
$address['number'] = get_user_meta( $customer_id, $name . '_number', true );
|
@@ -530,17 +537,23 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
|
|
530 |
/**
|
531 |
* Order address.
|
532 |
*
|
533 |
-
* @param array
|
534 |
-
* @param string
|
535 |
-
* @param WC_Order $order
|
536 |
* @return array
|
537 |
*/
|
538 |
public function order_address( $address, $type, $order ) {
|
539 |
$number = $type . '_number';
|
540 |
$neighborhood = $type . '_neighborhood';
|
541 |
|
542 |
-
|
543 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
|
545 |
return $address;
|
546 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Extra checkout fields frontend actions.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Frontend
|
6 |
+
*/
|
7 |
+
|
8 |
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
exit; // Exit if accessed directly.
|
10 |
}
|
11 |
|
12 |
/**
|
13 |
+
* Extra_Checkout_Fields_For_Brazil_Front_End class.
|
14 |
*/
|
15 |
class Extra_Checkout_Fields_For_Brazil_Front_End {
|
16 |
|
18 |
* Initialize the front-end actions.
|
19 |
*/
|
20 |
public function __construct() {
|
|
|
|
|
|
|
21 |
// Load public-facing scripts.
|
22 |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
23 |
add_action( 'woocommerce_after_edit_account_address_form', array( $this, 'load_scripts' ) );
|
41 |
add_filter( 'woocommerce_get_order_address', array( $this, 'order_address' ), 10, 3 );
|
42 |
}
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
/**
|
45 |
* Register scripts.
|
46 |
*/
|
47 |
public function enqueue_scripts() {
|
48 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
49 |
|
50 |
+
wp_register_script( 'jquery-mask', plugins_url( 'assets/js/jquery.mask/jquery.mask' . $suffix . '.js', plugin_dir_path( __FILE__ ) ), array( 'jquery' ), '1.14.10', true );
|
51 |
|
52 |
wp_register_script( 'mailcheck', plugins_url( 'assets/js/mailcheck/mailcheck' . $suffix . '.js', plugin_dir_path( __FILE__ ) ), array( 'jquery' ), '1.1.1', true );
|
53 |
|
54 |
+
wp_register_script( 'woocommerce-extra-checkout-fields-for-brazil-front', plugins_url( 'assets/js/frontend/frontend' . $suffix . '.js', plugin_dir_path( __FILE__ ) ), array( 'jquery', 'jquery-mask', 'mailcheck' ), Extra_Checkout_Fields_For_Brazil::VERSION, true );
|
55 |
|
56 |
$settings = get_option( 'wcbcf_settings' );
|
57 |
$autofill = isset( $settings['addresscomplete'] ) ? 'yes' : 'no';
|
59 |
'woocommerce-extra-checkout-fields-for-brazil-front',
|
60 |
'wcbcf_public_params',
|
61 |
array(
|
62 |
+
'state' => esc_js( __( 'State', 'woocommerce-extra-checkout-fields-for-brazil' ) ),
|
63 |
+
'required' => esc_js( __( 'required', 'woocommerce-extra-checkout-fields-for-brazil' ) ),
|
64 |
+
'mailcheck' => isset( $settings['mailcheck'] ) ? 'yes' : 'no',
|
65 |
+
'maskedinput' => isset( $settings['maskedinput'] ) ? 'yes' : 'no',
|
66 |
+
'addresscomplete' => apply_filters( 'woocommerce_correios_enable_autofill_addresses', false ) ? false : $autofill,
|
67 |
+
'person_type' => absint( $settings['person_type'] ),
|
68 |
+
'only_brazil' => isset( $settings['only_brazil'] ) ? 'yes' : 'no',
|
69 |
+
'sort_state_country' => version_compare( WC_VERSION, '3.0', '>=' ),
|
70 |
)
|
71 |
);
|
72 |
}
|
89 |
$new_fields = array();
|
90 |
|
91 |
// Get plugin settings.
|
92 |
+
$settings = get_option( 'wcbcf_settings' );
|
93 |
+
$person_type = intval( $settings['person_type'] );
|
94 |
|
95 |
if ( isset( $fields['billing_first_name'] ) ) {
|
96 |
$new_fields['billing_first_name'] = $fields['billing_first_name'];
|
102 |
$new_fields['billing_last_name']['class'] = array( 'form-row-last' );
|
103 |
}
|
104 |
|
105 |
+
if ( 0 !== $person_type ) {
|
106 |
+
if ( 1 === $person_type ) {
|
107 |
$new_fields['billing_persontype'] = array(
|
108 |
'type' => 'select',
|
109 |
'label' => __( 'Person type', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
112 |
'options' => array(
|
113 |
'0' => __( 'Select', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
114 |
'1' => __( 'Individuals', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
115 |
+
'2' => __( 'Legal Person', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
116 |
+
),
|
117 |
+
'priority' => 22,
|
118 |
);
|
119 |
}
|
120 |
|
121 |
+
if ( 1 === $person_type || 2 === $person_type ) {
|
122 |
if ( isset( $settings['rg'] ) ) {
|
123 |
$new_fields['billing_cpf'] = array(
|
124 |
'label' => __( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
125 |
'placeholder' => _x( 'CPF', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
126 |
'class' => array( 'form-row-first', 'person-type-field' ),
|
127 |
+
'required' => false,
|
128 |
+
'type' => 'tel',
|
129 |
+
'priority' => 23,
|
130 |
);
|
131 |
|
132 |
$new_fields['billing_rg'] = array(
|
133 |
'label' => __( 'RG', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
134 |
'placeholder' => _x( 'RG', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
135 |
'class' => array( 'form-row-last', 'person-type-field' ),
|
136 |
+
'required' => false,
|
137 |
+
'priority' => 24,
|
138 |
);
|
139 |
} else {
|
140 |
$new_fields['billing_cpf'] = array(
|
141 |
'label' => __( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
142 |
'placeholder' => _x( 'CPF', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
143 |
'class' => array( 'form-row-wide', 'person-type-field' ),
|
144 |
+
'required' => false,
|
145 |
+
'type' => 'tel',
|
146 |
+
'priority' => 23,
|
147 |
);
|
148 |
}
|
149 |
}
|
150 |
|
151 |
+
if ( 1 === $person_type || 3 === $person_type ) {
|
152 |
if ( isset( $fields['billing_company'] ) ) {
|
153 |
$new_fields['billing_company'] = $fields['billing_company'];
|
154 |
$new_fields['billing_company']['class'] = array( 'form-row-wide' );
|
155 |
$new_fields['billing_company']['clear'] = true;
|
156 |
$new_fields['billing_company']['required'] = false;
|
157 |
+
$new_fields['billing_company']['priority'] = 25;
|
158 |
}
|
159 |
|
160 |
if ( isset( $settings['ie'] ) ) {
|
162 |
'label' => __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
163 |
'placeholder' => _x( 'CNPJ', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
164 |
'class' => array( 'form-row-first', 'person-type-field' ),
|
165 |
+
'required' => false,
|
166 |
+
'type' => 'tel',
|
167 |
+
'priority' => 26,
|
168 |
);
|
169 |
|
170 |
$new_fields['billing_ie'] = array(
|
171 |
'label' => __( 'State Registration', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
172 |
'placeholder' => _x( 'State Registration', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
173 |
'class' => array( 'form-row-last', 'person-type-field' ),
|
174 |
+
'required' => false,
|
175 |
+
'priority' => 27,
|
176 |
);
|
177 |
} else {
|
178 |
$new_fields['billing_cnpj'] = array(
|
179 |
'label' => __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
180 |
'placeholder' => _x( 'CNPJ', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
181 |
'class' => array( 'form-row-wide', 'person-type-field' ),
|
182 |
+
'required' => false,
|
183 |
+
'type' => 'tel',
|
184 |
+
'priority' => 26,
|
185 |
);
|
186 |
}
|
187 |
}
|
|
|
188 |
} else {
|
189 |
if ( isset( $fields['billing_company'] ) ) {
|
190 |
$new_fields['billing_company'] = $fields['billing_company'];
|
191 |
$new_fields['billing_company']['class'] = array( 'form-row-wide' );
|
192 |
$new_fields['billing_company']['clear'] = true;
|
193 |
}
|
194 |
+
} // End if().
|
195 |
|
196 |
if ( isset( $settings['birthdate_sex'] ) ) {
|
197 |
$new_fields['billing_birthdate'] = array(
|
199 |
'placeholder' => _x( 'Birthdate', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
200 |
'class' => array( 'form-row-first' ),
|
201 |
'clear' => false,
|
202 |
+
'required' => true,
|
203 |
+
'priority' => 31,
|
204 |
);
|
205 |
|
206 |
$new_fields['billing_sex'] = array(
|
212 |
'options' => array(
|
213 |
'' => __( 'Select', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
214 |
__( 'Female', 'woocommerce-extra-checkout-fields-for-brazil' ) => __( 'Female', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
215 |
+
__( 'Male', 'woocommerce-extra-checkout-fields-for-brazil' ) => __( 'Male', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
216 |
+
),
|
217 |
+
'priority' => 32,
|
218 |
);
|
219 |
}
|
220 |
|
226 |
if ( isset( $fields['billing_postcode'] ) ) {
|
227 |
$new_fields['billing_postcode'] = $fields['billing_postcode'];
|
228 |
$new_fields['billing_postcode']['class'] = array( 'form-row-last', 'address-field' );
|
229 |
+
$new_fields['billing_postcode']['priority'] = 45;
|
230 |
}
|
231 |
|
232 |
if ( isset( $fields['billing_address_1'] ) ) {
|
239 |
'placeholder' => _x( 'Number', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
240 |
'class' => array( 'form-row-last', 'address-field' ),
|
241 |
'clear' => true,
|
242 |
+
'required' => true,
|
243 |
+
'priority' => 55,
|
244 |
);
|
245 |
|
246 |
if ( isset( $fields['billing_address_2'] ) ) {
|
255 |
'placeholder' => _x( 'Neighborhood', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
256 |
'class' => array( 'form-row-last', 'address-field' ),
|
257 |
'clear' => true,
|
258 |
+
'priority' => 65,
|
259 |
);
|
260 |
|
261 |
if ( isset( $fields['billing_city'] ) ) {
|
281 |
'label' => __( 'Cell Phone', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
282 |
'placeholder' => _x( 'Cell Phone', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
283 |
'class' => array( 'form-row-last' ),
|
284 |
+
'clear' => true,
|
285 |
+
'priority' => 105,
|
286 |
);
|
287 |
|
288 |
if ( isset( $fields['billing_email'] ) ) {
|
289 |
$new_fields['billing_email'] = $fields['billing_email'];
|
290 |
$new_fields['billing_email']['class'] = array( 'form-row-wide' );
|
291 |
$new_fields['billing_email']['clear'] = true;
|
292 |
+
$new_fields['billing_email']['type'] = 'email';
|
293 |
}
|
|
|
294 |
} else {
|
295 |
if ( isset( $fields['billing_phone'] ) ) {
|
296 |
$new_fields['billing_phone'] = $fields['billing_phone'];
|
302 |
$new_fields['billing_email'] = $fields['billing_email'];
|
303 |
$new_fields['billing_email']['class'] = array( 'form-row-wide' );
|
304 |
$new_fields['billing_email']['clear'] = true;
|
305 |
+
$new_fields['billing_email']['type'] = 'email';
|
306 |
}
|
|
|
307 |
}
|
308 |
|
309 |
return apply_filters( 'wcbcf_billing_fields', $new_fields );
|
343 |
if ( isset( $fields['shipping_postcode'] ) ) {
|
344 |
$new_fields['shipping_postcode'] = $fields['shipping_postcode'];
|
345 |
$new_fields['shipping_postcode']['class'] = array( 'form-row-last', 'address-field' );
|
346 |
+
$new_fields['shipping_postcode']['priority'] = 45;
|
347 |
}
|
348 |
|
349 |
if ( isset( $fields['shipping_address_1'] ) ) {
|
356 |
'placeholder' => _x( 'Number', 'placeholder', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
357 |
'class' => array( 'form-row-last', 'address-field' ),
|
358 |
'clear' => true,
|
359 |
+
'required' => true,
|
360 |
+
'priority' => 55,
|
361 |
);
|
362 |
|
363 |
if ( isset( $fields['shipping_address_2'] ) ) {
|
400 |
|
401 |
// Get plugin settings.
|
402 |
$settings = get_option( 'wcbcf_settings' );
|
403 |
+
$person_type = intval( $settings['person_type'] );
|
404 |
$only_brazil = isset( $settings['only_brazil'] ) ? true : false;
|
405 |
+
$billing_persontype = isset( $_POST['billing_persontype'] ) ? intval( wp_unslash( $_POST['billing_persontype'] ) ) : 0;
|
406 |
|
407 |
+
if ( $only_brazil && 'BR' !== wp_unslash( $_POST['billing_country'] ) || 0 === $person_type ) {
|
408 |
return;
|
409 |
}
|
410 |
|
411 |
+
if ( 0 === $billing_persontype && 1 === $person_type ) {
|
412 |
wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'Person type', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is a required field', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
|
413 |
} else {
|
414 |
|
415 |
// Check CPF.
|
416 |
+
if ( ( 1 === $person_type && 1 === $billing_persontype ) || 2 === $person_type ) {
|
417 |
if ( empty( $_POST['billing_cpf'] ) ) {
|
418 |
wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is a required field', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
|
419 |
}
|
428 |
}
|
429 |
|
430 |
// Check Company and CPNJ.
|
431 |
+
if ( ( 1 === $person_type && 2 === $billing_persontype ) || 3 === $person_type ) {
|
432 |
if ( empty( $_POST['billing_company'] ) ) {
|
433 |
wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'Company', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is a required field', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
|
434 |
}
|
437 |
wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is a required field', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
|
438 |
}
|
439 |
|
440 |
+
if ( isset( $settings['validate_cnpj'] ) && ! empty( $_POST['billing_cnpj'] ) && ! Extra_Checkout_Fields_For_Brazil_Formatting::is_cnpj( wp_unslash( $_POST['billing_cnpj'] ) ) ) {
|
441 |
wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is not valid', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
|
442 |
}
|
443 |
|
445 |
wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'State Registration', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is a required field', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
|
446 |
}
|
447 |
}
|
448 |
+
} // End if().
|
449 |
}
|
450 |
|
451 |
/**
|
470 |
* @return array New replacements.
|
471 |
*/
|
472 |
public function formatted_address_replacements( $replacements, $args ) {
|
473 |
+
$replacements['{number}'] = $args['number'];
|
474 |
+
$replacements['{neighborhood}'] = $args['neighborhood'];
|
|
|
|
|
475 |
|
476 |
return $replacements;
|
477 |
}
|
479 |
/**
|
480 |
* Custom order formatted billing address.
|
481 |
*
|
482 |
+
* @param array $address Default address.
|
483 |
+
* @param object $order Order data.
|
484 |
*
|
485 |
+
* @return array New address format.
|
486 |
*/
|
487 |
public function order_formatted_billing_address( $address, $order ) {
|
488 |
+
// WooCommerce 3.0 or later.
|
489 |
+
if ( method_exists( $order, 'get_meta' ) ) {
|
490 |
+
$address['number'] = $order->get_meta( '_billing_number' );
|
491 |
+
$address['neighborhood'] = $order->get_meta( '_billing_neighborhood' );
|
492 |
+
} else {
|
493 |
+
$address['number'] = $order->billing_number;
|
494 |
+
$address['neighborhood'] = $order->billing_neighborhood;
|
495 |
+
}
|
496 |
|
497 |
return $address;
|
498 |
}
|
500 |
/**
|
501 |
* Custom order formatted shipping address.
|
502 |
*
|
503 |
+
* @param array $address Default address.
|
504 |
+
* @param object $order Order data.
|
505 |
*
|
506 |
+
* @return array New address format.
|
507 |
*/
|
508 |
public function order_formatted_shipping_address( $address, $order ) {
|
509 |
+
// WooCommerce 3.0 or later.
|
510 |
+
if ( method_exists( $order, 'get_meta' ) ) {
|
511 |
+
$address['number'] = $order->get_meta( '_shipping_number' );
|
512 |
+
$address['neighborhood'] = $order->get_meta( '_shipping_neighborhood' );
|
513 |
+
} else {
|
514 |
+
$address['number'] = $order->shipping_number;
|
515 |
+
$address['neighborhood'] = $order->shipping_neighborhood;
|
516 |
+
}
|
517 |
|
518 |
return $address;
|
519 |
}
|
521 |
/**
|
522 |
* Custom my address formatted address.
|
523 |
*
|
524 |
+
* @param array $address Default address.
|
525 |
+
* @param int $customer_id Customer ID.
|
526 |
+
* @param string $name Field name (billing or shipping).
|
527 |
*
|
528 |
+
* @return array New address format.
|
529 |
*/
|
530 |
public function my_account_my_address_formatted_address( $address, $customer_id, $name ) {
|
531 |
$address['number'] = get_user_meta( $customer_id, $name . '_number', true );
|
537 |
/**
|
538 |
* Order address.
|
539 |
*
|
540 |
+
* @param array $address Address data.
|
541 |
+
* @param string $type Address type.
|
542 |
+
* @param WC_Order $order Order object.
|
543 |
* @return array
|
544 |
*/
|
545 |
public function order_address( $address, $type, $order ) {
|
546 |
$number = $type . '_number';
|
547 |
$neighborhood = $type . '_neighborhood';
|
548 |
|
549 |
+
// WooCommerce 3.0 or later.
|
550 |
+
if ( method_exists( $order, 'get_meta' ) ) {
|
551 |
+
$address['number'] = $order->get_meta( '_' . $number );
|
552 |
+
$address['neighborhood'] = $order->get_meta( '_' . $neighborhood );
|
553 |
+
} else {
|
554 |
+
$address['number'] = $order->$number;
|
555 |
+
$address['neighborhood'] = $order->$neighborhood;
|
556 |
+
}
|
557 |
|
558 |
return $address;
|
559 |
}
|
includes/class-extra-checkout-fields-for-brazil-integrations.php
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Extra checkout fields integrations.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Integrations
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly.
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Extra_Checkout_Fields_For_Brazil_Integrations class.
|
14 |
+
*/
|
15 |
+
class Extra_Checkout_Fields_For_Brazil_Integrations {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Initialize integrations.
|
19 |
+
*/
|
20 |
+
public function __construct() {
|
21 |
+
add_filter( 'woocommerce_bcash_args', array( $this, 'bcash' ), 1, 2 );
|
22 |
+
add_filter( 'woocommerce_moip_args', array( $this, 'moip' ), 1, 2 );
|
23 |
+
add_filter( 'woocommerce_moip_holder_data', array( $this, 'moip_transparent_checkout' ), 1, 2 );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Custom Bcash arguments.
|
28 |
+
*
|
29 |
+
* @param array $args Bcash default arguments.
|
30 |
+
* @param object $order Order data.
|
31 |
+
*
|
32 |
+
* @return array New arguments.
|
33 |
+
*/
|
34 |
+
public function bcash( $args, $order ) {
|
35 |
+
// WooCommerce 3.0 or later.
|
36 |
+
if ( method_exists( $customer, 'get_meta' ) ) {
|
37 |
+
$args['numero'] = $order->get_meta( '_billing_number' );
|
38 |
+
$person_type = intval( $order->get_meta( '_billing_persontype' ) );
|
39 |
+
|
40 |
+
if ( $person_type ) {
|
41 |
+
if ( 1 === $person_type ) {
|
42 |
+
$args['cpf'] = str_replace( array( '-', '.' ), '', $order->get_meta( '_billing_cpf' ) );
|
43 |
+
}
|
44 |
+
|
45 |
+
if ( 2 === $person_type ) {
|
46 |
+
$args['cliente_cnpj'] = str_replace( array( '-', '.' ), '', $order->get_meta( '_billing_cnpj' ) );
|
47 |
+
$args['cliente_razao_social'] = $order->get_billing_company();
|
48 |
+
}
|
49 |
+
}
|
50 |
+
} else {
|
51 |
+
$args['numero'] = $order->billing_number;
|
52 |
+
|
53 |
+
if ( isset( $order->billing_persontype ) ) {
|
54 |
+
if ( 1 === intval( $order->billing_persontype ) ) {
|
55 |
+
$args['cpf'] = str_replace( array( '-', '.' ), '', $order->billing_cpf );
|
56 |
+
}
|
57 |
+
|
58 |
+
if ( 2 === intval( $order->billing_persontype ) ) {
|
59 |
+
$args['cliente_cnpj'] = str_replace( array( '-', '.' ), '', $order->billing_cnpj );
|
60 |
+
$args['cliente_razao_social'] = $order->billing_company;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
return $args;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Custom Moip arguments.
|
70 |
+
*
|
71 |
+
* @param array $args Moip default arguments.
|
72 |
+
* @param object $order Order data.
|
73 |
+
*
|
74 |
+
* @return array New arguments.
|
75 |
+
*/
|
76 |
+
public function moip( $args, $order ) {
|
77 |
+
// WooCommerce 3.0 or later.
|
78 |
+
if ( method_exists( $customer, 'get_meta' ) ) {
|
79 |
+
$args['pagador_numero'] = $order->get_meta( '_billing_number' );
|
80 |
+
$args['pagador_bairro'] = $order->get_meta( '_billing_neighborhood' );
|
81 |
+
} else {
|
82 |
+
$args['pagador_numero'] = $order->billing_number;
|
83 |
+
$args['pagador_bairro'] = $order->billing_neighborhood;
|
84 |
+
}
|
85 |
+
|
86 |
+
return $args;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Custom Moip Transparent Checkout arguments.
|
91 |
+
*
|
92 |
+
* @param array $args Moip Transparent Checkout default arguments.
|
93 |
+
* @param object $order Order data.
|
94 |
+
*
|
95 |
+
* @return array New arguments.
|
96 |
+
*/
|
97 |
+
public function moip_transparent_checkout( $args, $order ) {
|
98 |
+
// WooCommerce 3.0 or later.
|
99 |
+
if ( method_exists( $customer, 'get_meta' ) ) {
|
100 |
+
if ( '' !== $order->get_meta( '_billing_cpf' ) ) {
|
101 |
+
$args['cpf'] = $order->get_meta( '_billing_cpf' );
|
102 |
+
}
|
103 |
+
|
104 |
+
if ( '' !== $order->get_meta( '_billing_birthdate' ) ) {
|
105 |
+
$birthdate = explode( '/', $order->get_meta( '_billing_birthdate' ) );
|
106 |
+
|
107 |
+
$args['birthdate_day'] = $birthdate[0];
|
108 |
+
$args['birthdate_month'] = $birthdate[1];
|
109 |
+
$args['birthdate_year'] = $birthdate[2];
|
110 |
+
}
|
111 |
+
} else {
|
112 |
+
if ( isset( $order->billing_cpf ) ) {
|
113 |
+
$args['cpf'] = $order->billing_cpf;
|
114 |
+
}
|
115 |
+
|
116 |
+
if ( isset( $order->billing_birthdate ) ) {
|
117 |
+
$birthdate = explode( '/', $order->billing_birthdate );
|
118 |
+
|
119 |
+
$args['birthdate_day'] = $birthdate[0];
|
120 |
+
$args['birthdate_month'] = $birthdate[1];
|
121 |
+
$args['birthdate_year'] = $birthdate[2];
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
return $args;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
new Extra_Checkout_Fields_For_Brazil_Integrations();
|
includes/class-wc-ecfb-api.php
DELETED
@@ -1,319 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit; // Exit if accessed directly.
|
4 |
-
}
|
5 |
-
|
6 |
-
/**
|
7 |
-
* API integration.
|
8 |
-
*/
|
9 |
-
class Extra_Checkout_Fields_For_Brazil_API {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Initialize integrations.
|
13 |
-
*/
|
14 |
-
public function __construct() {
|
15 |
-
// Legacy REST API.
|
16 |
-
add_filter( 'woocommerce_api_order_response', array( $this, 'legacy_orders_response' ), 100, 4 );
|
17 |
-
add_filter( 'woocommerce_api_customer_response', array( $this, 'legacy_customers_response' ), 100, 4 );
|
18 |
-
|
19 |
-
// WP REST API.
|
20 |
-
add_filter( 'woocommerce_rest_prepare_customer', array( $this, 'customers_response' ), 100, 2 );
|
21 |
-
add_filter( 'woocommerce_rest_prepare_shop_order', array( $this, 'orders_response' ), 100, 2 );
|
22 |
-
add_filter( 'woocommerce_rest_customer_schema', array( $this, 'addresses_schema' ), 100 );
|
23 |
-
add_filter( 'woocommerce_rest_shop_order_schema', array( $this, 'addresses_schema' ), 100 );
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Format number.
|
28 |
-
*
|
29 |
-
* @param string $string
|
30 |
-
*
|
31 |
-
* @return string
|
32 |
-
*/
|
33 |
-
protected function format_number( $string ) {
|
34 |
-
return str_replace( array( '.', '-', '/' ), '', $string );
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Get formatted birthdate legacy.
|
39 |
-
*
|
40 |
-
* @param string $date
|
41 |
-
* @param WC_API_Server $server
|
42 |
-
*
|
43 |
-
* @return string
|
44 |
-
*/
|
45 |
-
protected function get_formatted_birthdate_legacy( $date, $server ) {
|
46 |
-
$birthdate = explode( '/', $date );
|
47 |
-
|
48 |
-
if ( isset( $birthdate[1] ) && ! empty( $birthdate[1] ) ) {
|
49 |
-
return $server->format_datetime( $birthdate[1] . '/' . $birthdate[0] . '/' . $birthdate[2] );
|
50 |
-
}
|
51 |
-
|
52 |
-
return '';
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Get formatted birthdate.
|
57 |
-
*
|
58 |
-
* @param string $date
|
59 |
-
* @param WC_API_Server $server
|
60 |
-
*
|
61 |
-
* @return string
|
62 |
-
*/
|
63 |
-
protected function get_formatted_birthdate( $date ) {
|
64 |
-
$birthdate = explode( '/', $date );
|
65 |
-
|
66 |
-
if ( isset( $birthdate[1] ) && ! empty( $birthdate[1] ) ) {
|
67 |
-
return sprintf( '%s-%s-%sT00:00:00', $birthdate[1], $birthdate[0], $birthdate[2] );
|
68 |
-
}
|
69 |
-
|
70 |
-
return '';
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Get person type.
|
75 |
-
*
|
76 |
-
* @param int $type
|
77 |
-
*
|
78 |
-
* @return string
|
79 |
-
*/
|
80 |
-
protected function get_person_type( $type ) {
|
81 |
-
$settings = get_option( 'wcbcf_settings' );
|
82 |
-
|
83 |
-
switch ( $settings['person_type'] ) {
|
84 |
-
case 1:
|
85 |
-
$persontype = ( 2 == $type ) ? 'J' : 'F';
|
86 |
-
break;
|
87 |
-
case 2:
|
88 |
-
$persontype = 'F';
|
89 |
-
break;
|
90 |
-
case 3:
|
91 |
-
$persontype = 'J';
|
92 |
-
break;
|
93 |
-
|
94 |
-
default:
|
95 |
-
$persontype = '';
|
96 |
-
break;
|
97 |
-
}
|
98 |
-
|
99 |
-
return $persontype;
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Add extra fields in legacy order response.
|
104 |
-
*
|
105 |
-
* @param array $order_data
|
106 |
-
* @param WC_Order $order
|
107 |
-
* @param array $fields
|
108 |
-
* @param WC_API_Server $server
|
109 |
-
*
|
110 |
-
* @return array
|
111 |
-
*/
|
112 |
-
public function legacy_orders_response( $order_data, $order, $fields, $server ) {
|
113 |
-
|
114 |
-
// Billing fields.
|
115 |
-
$order_data['billing_address']['persontype'] = $this->get_person_type( $order->billing_persontype );
|
116 |
-
$order_data['billing_address']['cpf'] = $this->format_number( $order->billing_cpf );
|
117 |
-
$order_data['billing_address']['rg'] = $this->format_number( $order->billing_rg );
|
118 |
-
$order_data['billing_address']['cnpj'] = $this->format_number( $order->billing_cnpj );
|
119 |
-
$order_data['billing_address']['ie'] = $this->format_number( $order->billing_ie );
|
120 |
-
$order_data['billing_address']['birthdate'] = $this->get_formatted_birthdate_legacy( $order->billing_birthdate, $server );
|
121 |
-
$order_data['billing_address']['sex'] = substr( $order->billing_sex, 0, 1 );
|
122 |
-
$order_data['billing_address']['number'] = $order->billing_number;
|
123 |
-
$order_data['billing_address']['neighborhood'] = $order->billing_neighborhood;
|
124 |
-
$order_data['billing_address']['cellphone'] = $order->billing_cellphone;
|
125 |
-
|
126 |
-
// Shipping fields.
|
127 |
-
$order_data['shipping_address']['number'] = $order->shipping_number;
|
128 |
-
$order_data['shipping_address']['neighborhood'] = $order->shipping_neighborhood;
|
129 |
-
|
130 |
-
// Customer fields.
|
131 |
-
if ( 0 == $order->customer_user && isset( $order_data['customer'] ) ) {
|
132 |
-
// Customer billing fields.
|
133 |
-
$order_data['customer']['billing_address']['persontype'] = $this->get_person_type( $order->billing_persontype );
|
134 |
-
$order_data['customer']['billing_address']['cpf'] = $this->format_number( $order->billing_cpf );
|
135 |
-
$order_data['customer']['billing_address']['rg'] = $this->format_number( $order->billing_rg );
|
136 |
-
$order_data['customer']['billing_address']['cnpj'] = $this->format_number( $order->billing_cnpj );
|
137 |
-
$order_data['customer']['billing_address']['ie'] = $this->format_number( $order->billing_ie );
|
138 |
-
$order_data['customer']['billing_address']['birthdate'] = $this->get_formatted_birthdate_legacy( $order->billing_birthdate, $server );
|
139 |
-
$order_data['customer']['billing_address']['sex'] = substr( $order->billing_sex, 0, 1 );
|
140 |
-
$order_data['customer']['billing_address']['number'] = $order->billing_number;
|
141 |
-
$order_data['customer']['billing_address']['neighborhood'] = $order->billing_neighborhood;
|
142 |
-
$order_data['customer']['billing_address']['cellphone'] = $order->billing_cellphone;
|
143 |
-
|
144 |
-
// Customer shipping fields.
|
145 |
-
$order_data['customer']['shipping_address']['number'] = $order->shipping_number;
|
146 |
-
$order_data['customer']['shipping_address']['neighborhood'] = $order->shipping_neighborhood;
|
147 |
-
}
|
148 |
-
|
149 |
-
if ( $fields ) {
|
150 |
-
$order_data = WC()->api->WC_API_Customers->filter_response_fields( $order_data, $order, $fields );
|
151 |
-
}
|
152 |
-
|
153 |
-
return $order_data;
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Add extra fields in legacy customers response.
|
158 |
-
*
|
159 |
-
* @param array $customer_data
|
160 |
-
* @param WC_Order $customer
|
161 |
-
* @param array $fields
|
162 |
-
* @param WC_API_Server $server
|
163 |
-
*
|
164 |
-
* @return array
|
165 |
-
*/
|
166 |
-
public function legacy_customers_response( $customer_data, $customer, $fields, $server ) {
|
167 |
-
// Billing fields.
|
168 |
-
$customer_data['billing_address']['persontype'] = $this->get_person_type( $customer->billing_persontype );
|
169 |
-
$customer_data['billing_address']['cpf'] = $this->format_number( $customer->billing_cpf );
|
170 |
-
$customer_data['billing_address']['rg'] = $this->format_number( $customer->billing_rg );
|
171 |
-
$customer_data['billing_address']['cnpj'] = $this->format_number( $customer->billing_cnpj );
|
172 |
-
$customer_data['billing_address']['ie'] = $this->format_number( $customer->billing_ie );
|
173 |
-
$customer_data['billing_address']['birthdate'] = $this->get_formatted_birthdate_legacy( $customer->billing_birthdate, $server );
|
174 |
-
$customer_data['billing_address']['sex'] = substr( $customer->billing_sex, 0, 1 );
|
175 |
-
$customer_data['billing_address']['number'] = $customer->billing_number;
|
176 |
-
$customer_data['billing_address']['neighborhood'] = $customer->billing_neighborhood;
|
177 |
-
$customer_data['billing_address']['cellphone'] = $customer->billing_cellphone;
|
178 |
-
|
179 |
-
// Shipping fields.
|
180 |
-
$customer_data['shipping_address']['number'] = $customer->shipping_number;
|
181 |
-
$customer_data['shipping_address']['neighborhood'] = $customer->shipping_neighborhood;
|
182 |
-
|
183 |
-
if ( $fields ) {
|
184 |
-
$customer_data = WC()->api->WC_API_Customers->filter_response_fields( $customer_data, $customer, $fields );
|
185 |
-
}
|
186 |
-
|
187 |
-
return $customer_data;
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Add extra fields in customers response.
|
192 |
-
*
|
193 |
-
* @param WP_REST_Response $response The response object.
|
194 |
-
* @param WP_User $customer User object used to create response.
|
195 |
-
* @param WP_REST_Request $request Request object.
|
196 |
-
*
|
197 |
-
* @return WP_REST_Response
|
198 |
-
*/
|
199 |
-
public function customers_response( $response, $customer ) {
|
200 |
-
// Billing fields.
|
201 |
-
$response->data['billing']['number'] = $customer->billing_number;
|
202 |
-
$response->data['billing']['neighborhood'] = $customer->billing_neighborhood;
|
203 |
-
$response->data['billing']['persontype'] = $this->get_person_type( $customer->billing_persontype );
|
204 |
-
$response->data['billing']['cpf'] = $this->format_number( $customer->billing_cpf );
|
205 |
-
$response->data['billing']['rg'] = $this->format_number( $customer->billing_rg );
|
206 |
-
$response->data['billing']['cnpj'] = $this->format_number( $customer->billing_cnpj );
|
207 |
-
$response->data['billing']['ie'] = $this->format_number( $customer->billing_ie );
|
208 |
-
$response->data['billing']['birthdate'] = $this->get_formatted_birthdate( $customer->billing_birthdate );
|
209 |
-
$response->data['billing']['sex'] = substr( $customer->billing_sex, 0, 1 );
|
210 |
-
$response->data['billing']['cellphone'] = $customer->billing_cellphone;
|
211 |
-
|
212 |
-
// Shipping fields.
|
213 |
-
$response->data['shipping']['number'] = $customer->shipping_number;
|
214 |
-
$response->data['shipping']['neighborhood'] = $customer->shipping_neighborhood;
|
215 |
-
|
216 |
-
return $response;
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Add extra fields in orders response.
|
221 |
-
*
|
222 |
-
* @param WP_REST_Response $response The response object.
|
223 |
-
* @param WP_Post $post Post object.
|
224 |
-
*
|
225 |
-
* @return WP_REST_Response
|
226 |
-
*/
|
227 |
-
public function orders_response( $response, $post ) {
|
228 |
-
// Billing fields.
|
229 |
-
$response->data['billing']['number'] = get_post_meta( $post->ID, '_billing_number', true );
|
230 |
-
$response->data['billing']['neighborhood'] = get_post_meta( $post->ID, '_billing_neighborhood', true );
|
231 |
-
$response->data['billing']['persontype'] = $this->get_person_type( get_post_meta( $post->ID, '_billing_persontype', true ) );
|
232 |
-
$response->data['billing']['cpf'] = $this->format_number( get_post_meta( $post->ID, '_billing_cpf', true ) );
|
233 |
-
$response->data['billing']['rg'] = $this->format_number( get_post_meta( $post->ID, '_billing_rg', true ) );
|
234 |
-
$response->data['billing']['cnpj'] = $this->format_number( get_post_meta( $post->ID, '_billing_cnpj', true ) );
|
235 |
-
$response->data['billing']['ie'] = $this->format_number( get_post_meta( $post->ID, '_billing_ie', true ) );
|
236 |
-
$response->data['billing']['birthdate'] = $this->get_formatted_birthdate( get_post_meta( $post->ID, '_billing_birthdate', true ) );
|
237 |
-
$response->data['billing']['sex'] = substr( get_post_meta( $post->ID, '_billing_sex', true ), 0, 1 );
|
238 |
-
$response->data['billing']['cellphone'] = get_post_meta( $post->ID, '_billing_cellphone', true );
|
239 |
-
|
240 |
-
// Shipping fields.
|
241 |
-
$response->data['shipping']['number'] = get_post_meta( $post->ID, '_shipping_number', true );
|
242 |
-
$response->data['shipping']['neighborhood'] = get_post_meta( $post->ID, '_shipping_neighborhood', true );
|
243 |
-
|
244 |
-
return $response;
|
245 |
-
}
|
246 |
-
|
247 |
-
/**
|
248 |
-
* Addresses schena.
|
249 |
-
*
|
250 |
-
* @param array $schema Default schema properties.
|
251 |
-
* @return array
|
252 |
-
*/
|
253 |
-
public function addresses_schema( $properties ) {
|
254 |
-
$properties['billing']['properties']['number'] = array(
|
255 |
-
'description' => __( 'Number.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
256 |
-
'type' => 'string',
|
257 |
-
'context' => array( 'view', 'edit' ),
|
258 |
-
);
|
259 |
-
$properties['billing']['properties']['neighborhood'] = array(
|
260 |
-
'description' => __( 'Neighborhood.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
261 |
-
'type' => 'string',
|
262 |
-
'context' => array( 'view', 'edit' ),
|
263 |
-
);
|
264 |
-
$properties['billing']['properties']['persontype'] = array(
|
265 |
-
'description' => __( 'Person type.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
266 |
-
'type' => 'string',
|
267 |
-
'context' => array( 'view', 'edit' ),
|
268 |
-
);
|
269 |
-
$properties['billing']['properties']['cpf'] = array(
|
270 |
-
'description' => __( 'CPF.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
271 |
-
'type' => 'string',
|
272 |
-
'context' => array( 'view', 'edit' ),
|
273 |
-
);
|
274 |
-
$properties['billing']['properties']['rg'] = array(
|
275 |
-
'description' => __( 'RG.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
276 |
-
'type' => 'string',
|
277 |
-
'context' => array( 'view', 'edit' ),
|
278 |
-
);
|
279 |
-
$properties['billing']['properties']['cnpj'] = array(
|
280 |
-
'description' => __( 'CNPJ.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
281 |
-
'type' => 'string',
|
282 |
-
'context' => array( 'view', 'edit' ),
|
283 |
-
);
|
284 |
-
$properties['billing']['properties']['ie'] = array(
|
285 |
-
'description' => __( 'IE.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
286 |
-
'type' => 'string',
|
287 |
-
'context' => array( 'view', 'edit' ),
|
288 |
-
);
|
289 |
-
$properties['billing']['properties']['birthdate'] = array(
|
290 |
-
'description' => __( 'Birthdate.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
291 |
-
'type' => 'string',
|
292 |
-
'context' => array( 'view', 'edit' ),
|
293 |
-
);
|
294 |
-
$properties['billing']['properties']['sex'] = array(
|
295 |
-
'description' => __( 'Gender.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
296 |
-
'type' => 'string',
|
297 |
-
'context' => array( 'view', 'edit' ),
|
298 |
-
);
|
299 |
-
$properties['billing']['properties']['cellphone'] = array(
|
300 |
-
'description' => __( 'Cell Phone.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
301 |
-
'type' => 'string',
|
302 |
-
'context' => array( 'view', 'edit' ),
|
303 |
-
);
|
304 |
-
$properties['shipping']['properties']['number'] = array(
|
305 |
-
'description' => __( 'Number.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
306 |
-
'type' => 'string',
|
307 |
-
'context' => array( 'view', 'edit' ),
|
308 |
-
);
|
309 |
-
$properties['shipping']['properties']['neighborhood'] = array(
|
310 |
-
'description' => __( 'Neighborhood.', 'woocommerce-extra-checkout-fields-for-brazil' ),
|
311 |
-
'type' => 'string',
|
312 |
-
'context' => array( 'view', 'edit' ),
|
313 |
-
);
|
314 |
-
|
315 |
-
return $properties;
|
316 |
-
}
|
317 |
-
}
|
318 |
-
|
319 |
-
new Extra_Checkout_Fields_For_Brazil_API();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-wc-ecfb-plugins-support.php
DELETED
@@ -1,86 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit; // Exit if accessed directly.
|
4 |
-
}
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Methods to make integrations with others plugins.
|
8 |
-
*/
|
9 |
-
class Extra_Checkout_Fields_For_Brazil_Plugins_Support {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Initialize integrations.
|
13 |
-
*/
|
14 |
-
public function __construct() {
|
15 |
-
add_filter( 'woocommerce_bcash_args', array( $this, 'bcash' ), 1, 2 );
|
16 |
-
add_filter( 'woocommerce_moip_args', array( $this, 'moip' ), 1, 2 );
|
17 |
-
add_filter( 'woocommerce_moip_holder_data', array( $this, 'moip_transparent_checkout' ), 1, 2 );
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Custom Bcash arguments.
|
22 |
-
*
|
23 |
-
* @param array $args Bcash default arguments.
|
24 |
-
* @param object $order Order data.
|
25 |
-
*
|
26 |
-
* @return array New arguments.
|
27 |
-
*/
|
28 |
-
public function bcash( $args, $order ) {
|
29 |
-
$args['numero'] = $order->billing_number;
|
30 |
-
|
31 |
-
if ( isset( $order->billing_persontype ) ) {
|
32 |
-
if ( 1 == $order->billing_persontype ) {
|
33 |
-
$args['cpf'] = str_replace( array( '-', '.' ), '', $order->billing_cpf );
|
34 |
-
}
|
35 |
-
|
36 |
-
if ( 2 == $order->billing_persontype ) {
|
37 |
-
$args['cliente_cnpj'] = str_replace( array( '-', '.' ), '', $order->billing_cnpj );
|
38 |
-
$args['cliente_razao_social'] = $order->billing_company;
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
return $args;
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Custom Moip arguments.
|
47 |
-
*
|
48 |
-
* @param array $args Moip default arguments.
|
49 |
-
* @param object $order Order data.
|
50 |
-
*
|
51 |
-
* @return array New arguments.
|
52 |
-
*/
|
53 |
-
public function moip( $args, $order ) {
|
54 |
-
$args['pagador_numero'] = $order->billing_number;
|
55 |
-
$args['pagador_bairro'] = $order->billing_neighborhood;
|
56 |
-
|
57 |
-
return $args;
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Custom Moip Transparent Checkout arguments.
|
62 |
-
*
|
63 |
-
* @param array $args Moip Transparent Checkout default arguments.
|
64 |
-
* @param object $order Order data.
|
65 |
-
*
|
66 |
-
* @return array New arguments.
|
67 |
-
*/
|
68 |
-
public function moip_transparent_checkout( $args, $order ) {
|
69 |
-
|
70 |
-
if ( isset( $order->billing_cpf ) ) {
|
71 |
-
$args['cpf'] = $order->billing_cpf;
|
72 |
-
}
|
73 |
-
|
74 |
-
if ( isset( $order->billing_birthdate ) ) {
|
75 |
-
$birthdate = explode( '/', $order->billing_birthdate );
|
76 |
-
|
77 |
-
$args['birthdate_day'] = $birthdate[0];
|
78 |
-
$args['birthdate_month'] = $birthdate[1];
|
79 |
-
$args['birthdate_year'] = $birthdate[2];
|
80 |
-
}
|
81 |
-
|
82 |
-
return $args;
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
new Extra_Checkout_Fields_For_Brazil_Plugins_Support();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/woocommerce-extra-checkout-fields-for-brazil.pot
CHANGED
@@ -1,425 +1,397 @@
|
|
1 |
# Copyright (C) 2017 Claudio Sanches
|
2 |
-
# This file is distributed under the
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: WooCommerce Extra Checkout Fields for Brazil 3.
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/woocommerce-extra-checkout-fields-for-"
|
8 |
"brazil\n"
|
9 |
-
"POT-Creation-Date: 2017-
|
10 |
"MIME-Version: 1.0\n"
|
11 |
"Content-Type: text/plain; charset=utf-8\n"
|
12 |
"Content-Transfer-Encoding: 8bit\n"
|
13 |
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
|
14 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
15 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
16 |
-
"X-Generator: grunt-wp-
|
17 |
|
18 |
-
#: includes/admin/class-
|
19 |
msgid "Load the customer extras data?"
|
20 |
msgstr ""
|
21 |
|
22 |
-
#: includes/admin/class-
|
23 |
msgid "Also copy the data of number and neighborhood?"
|
24 |
msgstr ""
|
25 |
|
26 |
-
#: includes/admin/class-
|
27 |
msgid "Customer Billing Address"
|
28 |
msgstr ""
|
29 |
|
30 |
-
#: includes/admin/class-
|
31 |
-
#: includes/admin/class-
|
32 |
-
#: includes/admin/
|
33 |
-
#: includes/
|
34 |
-
#: includes/class-
|
35 |
-
#: includes/class-
|
36 |
-
#: includes/class-
|
|
|
37 |
msgid "CPF"
|
38 |
msgstr ""
|
39 |
|
40 |
-
#: includes/admin/class-
|
41 |
-
#: includes/admin/class-
|
42 |
-
#: includes/admin/
|
43 |
-
#: includes/
|
44 |
-
#: includes/class-
|
|
|
45 |
msgid "RG"
|
46 |
msgstr ""
|
47 |
|
48 |
-
#: includes/admin/class-
|
49 |
-
#: includes/admin/class-
|
50 |
-
#: includes/admin/
|
51 |
-
#: includes/
|
52 |
-
#: includes/class-
|
53 |
-
#: includes/class-
|
54 |
-
#: includes/class-
|
|
|
55 |
msgid "CNPJ"
|
56 |
msgstr ""
|
57 |
|
58 |
-
#: includes/admin/class-
|
59 |
-
#: includes/admin/class-
|
60 |
-
#: includes/admin/
|
61 |
-
#: includes/
|
62 |
-
#: includes/class-
|
|
|
63 |
msgid "State Registration"
|
64 |
msgstr ""
|
65 |
|
66 |
-
#: includes/admin/class-
|
67 |
-
#: includes/admin/class-
|
68 |
-
#: includes/admin/
|
69 |
-
#: includes/
|
|
|
70 |
msgid "Birthdate"
|
71 |
msgstr ""
|
72 |
|
73 |
-
#: includes/admin/class-
|
74 |
-
#: includes/admin/class-
|
75 |
-
#: includes/admin/
|
76 |
-
#: includes/
|
|
|
77 |
msgid "Sex"
|
78 |
msgstr ""
|
79 |
|
80 |
-
#: includes/admin/class-
|
81 |
-
#: includes/admin/class-
|
82 |
-
#: includes/admin/class-
|
83 |
-
#: includes/admin/class-
|
84 |
-
#: includes/class-
|
85 |
-
#: includes/class-
|
86 |
msgid "Number"
|
87 |
msgstr ""
|
88 |
|
89 |
-
#: includes/admin/class-
|
90 |
-
#: includes/admin/class-
|
91 |
-
#: includes/admin/class-
|
92 |
-
#: includes/admin/class-
|
93 |
-
#: includes/class-
|
94 |
-
#: includes/class-
|
95 |
msgid "Neighborhood"
|
96 |
msgstr ""
|
97 |
|
98 |
-
#: includes/admin/class-
|
99 |
-
#: includes/admin/class-
|
100 |
-
#: includes/admin/
|
101 |
-
#: includes/
|
|
|
102 |
msgid "Cell Phone"
|
103 |
msgstr ""
|
104 |
|
105 |
-
#: includes/admin/class-
|
106 |
msgid "Customer Shipping Address"
|
107 |
msgstr ""
|
108 |
|
109 |
-
#: includes/admin/class-
|
110 |
-
#: includes/
|
111 |
-
|
112 |
-
msgstr ""
|
113 |
-
|
114 |
-
#: includes/admin/class-wc-ecfb-order.php:39
|
115 |
-
#: includes/admin/class-wc-ecfb-order.php:165
|
116 |
-
msgid "Last Name"
|
117 |
-
msgstr ""
|
118 |
-
|
119 |
-
#: includes/admin/class-wc-ecfb-order.php:47
|
120 |
-
#: includes/class-wc-ecfb-front-end.php:132
|
121 |
-
#: includes/class-wc-ecfb-front-end.php:415
|
122 |
msgid "Person type"
|
123 |
msgstr ""
|
124 |
|
125 |
-
#: includes/admin/class-
|
126 |
-
#: includes/class-
|
127 |
-
#: includes/class-
|
128 |
msgid "Select"
|
129 |
msgstr ""
|
130 |
|
131 |
-
#: includes/admin/class-
|
132 |
-
#: includes/class-
|
133 |
msgid "Individuals"
|
134 |
msgstr ""
|
135 |
|
136 |
-
#: includes/admin/class-
|
137 |
-
#: includes/class-
|
138 |
msgid "Legal Person"
|
139 |
msgstr ""
|
140 |
|
141 |
-
#: includes/admin/class-
|
142 |
-
#: includes/admin/
|
|
|
143 |
msgid "Company Name"
|
144 |
msgstr ""
|
145 |
|
146 |
-
#: includes/admin/class-
|
147 |
-
#: includes/admin/
|
148 |
-
#: includes/admin/
|
149 |
-
#: includes/class-
|
150 |
msgid "Company"
|
151 |
msgstr ""
|
152 |
|
153 |
-
#: includes/admin/class-
|
154 |
-
#: includes/admin/class-
|
155 |
-
msgid "Address 1"
|
156 |
-
msgstr ""
|
157 |
-
|
158 |
-
#: includes/admin/class-wc-ecfb-order.php:106
|
159 |
-
#: includes/admin/class-wc-ecfb-order.php:181
|
160 |
-
msgid "Address 2"
|
161 |
-
msgstr ""
|
162 |
-
|
163 |
-
#: includes/admin/class-wc-ecfb-order.php:114
|
164 |
-
#: includes/admin/class-wc-ecfb-order.php:189
|
165 |
-
msgid "City"
|
166 |
-
msgstr ""
|
167 |
-
|
168 |
-
#: includes/admin/class-wc-ecfb-order.php:118
|
169 |
-
#: includes/admin/class-wc-ecfb-order.php:193
|
170 |
-
#: includes/class-wc-ecfb-front-end.php:87
|
171 |
-
msgid "State"
|
172 |
-
msgstr ""
|
173 |
-
|
174 |
-
#: includes/admin/class-wc-ecfb-order.php:122
|
175 |
-
#: includes/admin/class-wc-ecfb-order.php:197
|
176 |
-
msgid "Country"
|
177 |
-
msgstr ""
|
178 |
-
|
179 |
-
#: includes/admin/class-wc-ecfb-order.php:126
|
180 |
-
#: includes/admin/class-wc-ecfb-order.php:201
|
181 |
-
msgid "Select a country…"
|
182 |
-
msgstr ""
|
183 |
-
|
184 |
-
#: includes/admin/class-wc-ecfb-order.php:130
|
185 |
-
#: includes/admin/class-wc-ecfb-order.php:205
|
186 |
-
msgid "Postcode"
|
187 |
-
msgstr ""
|
188 |
-
|
189 |
-
#: includes/admin/class-wc-ecfb-order.php:135
|
190 |
-
#: includes/admin/class-wc-ecfb-order.php:294
|
191 |
-
msgid "Phone"
|
192 |
-
msgstr ""
|
193 |
-
|
194 |
-
#: includes/admin/class-wc-ecfb-order.php:145
|
195 |
-
#: includes/admin/class-wc-ecfb-order.php:301
|
196 |
-
msgid "Email"
|
197 |
-
msgstr ""
|
198 |
-
|
199 |
-
#: includes/admin/class-wc-ecfb-order.php:250
|
200 |
-
#: includes/admin/class-wc-ecfb-order.php:253
|
201 |
-
#: includes/admin/class-wc-ecfb-order.php:327
|
202 |
-
#: includes/admin/class-wc-ecfb-order.php:330
|
203 |
-
msgid "Address"
|
204 |
-
msgstr ""
|
205 |
-
|
206 |
-
#: includes/admin/class-wc-ecfb-order.php:250
|
207 |
-
msgid "No billing address set."
|
208 |
-
msgstr ""
|
209 |
-
|
210 |
-
#: includes/admin/class-wc-ecfb-order.php:258
|
211 |
-
msgid "Customer data"
|
212 |
-
msgstr ""
|
213 |
-
|
214 |
-
#: includes/admin/class-wc-ecfb-order.php:327
|
215 |
-
msgid "No shipping address set."
|
216 |
-
msgstr ""
|
217 |
-
|
218 |
-
#: includes/admin/class-wc-ecfb-order.php:336
|
219 |
-
msgid "Customer Note"
|
220 |
-
msgstr ""
|
221 |
-
|
222 |
-
#: includes/admin/class-wc-ecfb-settings.php:25
|
223 |
-
#: includes/admin/class-wc-ecfb-settings.php:26
|
224 |
msgid "Checkout Fields"
|
225 |
msgstr ""
|
226 |
|
227 |
-
#: includes/admin/class-
|
228 |
msgid "Checkout Custom Fields:"
|
229 |
msgstr ""
|
230 |
|
231 |
-
#: includes/admin/class-
|
232 |
msgid "Display Person Type:"
|
233 |
msgstr ""
|
234 |
|
235 |
-
#: includes/admin/class-
|
236 |
msgid "Individuals enables CPF field and Legal Person enables CNPJ field."
|
237 |
msgstr ""
|
238 |
|
239 |
-
#: includes/admin/class-
|
240 |
msgid "None"
|
241 |
msgstr ""
|
242 |
|
243 |
-
#: includes/admin/class-
|
244 |
msgid "Individuals and Legal Person"
|
245 |
msgstr ""
|
246 |
|
247 |
-
#: includes/admin/class-
|
248 |
msgid "Individuals only"
|
249 |
msgstr ""
|
250 |
|
251 |
-
#: includes/admin/class-
|
252 |
msgid "Legal Person only"
|
253 |
msgstr ""
|
254 |
|
255 |
-
#: includes/admin/class-
|
256 |
msgid "Person Type is required only in Brazil?"
|
257 |
msgstr ""
|
258 |
|
259 |
-
#: includes/admin/class-
|
260 |
msgid ""
|
261 |
"If checked the Individuals and Legal Person options will be mandatory only "
|
262 |
"in Brazil."
|
263 |
msgstr ""
|
264 |
|
265 |
-
#: includes/admin/class-
|
266 |
msgid "Display RG:"
|
267 |
msgstr ""
|
268 |
|
269 |
-
#: includes/admin/class-
|
270 |
msgid "If checked show the RG field in billing options."
|
271 |
msgstr ""
|
272 |
|
273 |
-
#: includes/admin/class-
|
274 |
msgid "Display State Registration:"
|
275 |
msgstr ""
|
276 |
|
277 |
-
#: includes/admin/class-
|
278 |
msgid "If checked show the State Registration field in billing options."
|
279 |
msgstr ""
|
280 |
|
281 |
-
#: includes/admin/class-
|
282 |
msgid "Display Birthdate and Sex:"
|
283 |
msgstr ""
|
284 |
|
285 |
-
#: includes/admin/class-
|
286 |
msgid "If checked show the Birthdate and Sex field in billing options."
|
287 |
msgstr ""
|
288 |
|
289 |
-
#: includes/admin/class-
|
290 |
msgid "Display Cell Phone:"
|
291 |
msgstr ""
|
292 |
|
293 |
-
#: includes/admin/class-
|
294 |
msgid "If checked show the Cell Phone field in billing options."
|
295 |
msgstr ""
|
296 |
|
297 |
-
#: includes/admin/class-
|
298 |
msgid "jQuery Options:"
|
299 |
msgstr ""
|
300 |
|
301 |
-
#: includes/admin/class-
|
302 |
msgid "Enable Mail Check:"
|
303 |
msgstr ""
|
304 |
|
305 |
-
#: includes/admin/class-
|
306 |
msgid "If checked informs typos in email to users."
|
307 |
msgstr ""
|
308 |
|
309 |
-
#: includes/admin/class-
|
310 |
msgid "Enable Input Mask:"
|
311 |
msgstr ""
|
312 |
|
313 |
-
#: includes/admin/class-
|
314 |
msgid ""
|
315 |
"If checked create masks fill for in fields of CPF, CNPJ, Birthdate, Phone "
|
316 |
"and Cell Phone."
|
317 |
msgstr ""
|
318 |
|
319 |
-
#: includes/admin/class-
|
320 |
msgid "Enable Address Autocomplete:"
|
321 |
msgstr ""
|
322 |
|
323 |
-
#: includes/admin/class-
|
324 |
msgid "If checked automatically complete the address fields based on the zip code."
|
325 |
msgstr ""
|
326 |
|
327 |
-
#: includes/admin/class-
|
328 |
msgid "Validation:"
|
329 |
msgstr ""
|
330 |
|
331 |
-
#: includes/admin/class-
|
332 |
msgid "Validate CPF:"
|
333 |
msgstr ""
|
334 |
|
335 |
-
#: includes/admin/class-
|
336 |
msgid "Checks if the CPF is valid."
|
337 |
msgstr ""
|
338 |
|
339 |
-
#: includes/admin/class-
|
340 |
msgid "Validate CNPJ:"
|
341 |
msgstr ""
|
342 |
|
343 |
-
#: includes/admin/class-
|
344 |
msgid "Checks if the CNPJ is valid."
|
345 |
msgstr ""
|
346 |
|
347 |
-
#: includes/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
msgid "Number."
|
349 |
msgstr ""
|
350 |
|
351 |
-
#: includes/class-
|
|
|
352 |
msgid "Neighborhood."
|
353 |
msgstr ""
|
354 |
|
355 |
-
#: includes/class-
|
356 |
msgid "Person type."
|
357 |
msgstr ""
|
358 |
|
359 |
-
#: includes/class-
|
360 |
msgid "CPF."
|
361 |
msgstr ""
|
362 |
|
363 |
-
#: includes/class-
|
364 |
msgid "RG."
|
365 |
msgstr ""
|
366 |
|
367 |
-
#: includes/class-
|
368 |
msgid "CNPJ."
|
369 |
msgstr ""
|
370 |
|
371 |
-
#: includes/class-
|
372 |
msgid "IE."
|
373 |
msgstr ""
|
374 |
|
375 |
-
#: includes/class-
|
376 |
msgid "Birthdate."
|
377 |
msgstr ""
|
378 |
|
379 |
-
#: includes/class-
|
380 |
msgid "Gender."
|
381 |
msgstr ""
|
382 |
|
383 |
-
#: includes/class-
|
384 |
msgid "Cell Phone."
|
385 |
msgstr ""
|
386 |
|
387 |
-
#: includes/class-
|
|
|
|
|
|
|
|
|
388 |
msgid "required"
|
389 |
msgstr ""
|
390 |
|
391 |
-
#: includes/class-
|
392 |
msgid "Female"
|
393 |
msgstr ""
|
394 |
|
395 |
-
#: includes/class-
|
396 |
msgid "Male"
|
397 |
msgstr ""
|
398 |
|
399 |
-
#: includes/class-
|
400 |
-
#: includes/class-
|
401 |
msgid "Address line 2"
|
402 |
msgstr ""
|
403 |
|
404 |
-
#: includes/class-
|
405 |
-
#: includes/class-
|
406 |
-
#: includes/class-
|
407 |
-
#: includes/class-
|
408 |
-
#: includes/class-
|
409 |
-
#: includes/class-
|
410 |
msgid "is a required field"
|
411 |
msgstr ""
|
412 |
|
413 |
-
#: includes/class-
|
414 |
-
#: includes/class-
|
415 |
msgid "is not valid"
|
416 |
msgstr ""
|
417 |
|
418 |
-
#: woocommerce-extra-checkout-fields-for-brazil.php:
|
|
|
|
|
|
|
|
|
419 |
msgid "WooCommerce Extra Checkout Fields for Brazil depends on %s to work!"
|
420 |
msgstr ""
|
421 |
|
422 |
-
#: woocommerce-extra-checkout-fields-for-brazil.php:
|
423 |
msgid "WooCommerce"
|
424 |
msgstr ""
|
425 |
|
@@ -428,14 +400,15 @@ msgid "WooCommerce Extra Checkout Fields for Brazil"
|
|
428 |
msgstr ""
|
429 |
|
430 |
#. Plugin URI of the plugin/theme
|
431 |
-
msgid "
|
|
|
|
|
432 |
msgstr ""
|
433 |
|
434 |
#. Description of the plugin/theme
|
435 |
msgid ""
|
436 |
-
"
|
437 |
-
"
|
438 |
-
"incorreto e auto preenchimento dos campos de endereço pelo CEP."
|
439 |
msgstr ""
|
440 |
|
441 |
#. Author of the plugin/theme
|
@@ -443,49 +416,49 @@ msgid "Claudio Sanches"
|
|
443 |
msgstr ""
|
444 |
|
445 |
#. Author URI of the plugin/theme
|
446 |
-
msgid "
|
447 |
msgstr ""
|
448 |
|
449 |
-
#: includes/class-
|
450 |
-
#: includes/class-
|
451 |
msgctxt "placeholder"
|
452 |
msgid "CPF"
|
453 |
msgstr ""
|
454 |
|
455 |
-
#: includes/class-
|
456 |
msgctxt "placeholder"
|
457 |
msgid "RG"
|
458 |
msgstr ""
|
459 |
|
460 |
-
#: includes/class-
|
461 |
-
#: includes/class-
|
462 |
msgctxt "placeholder"
|
463 |
msgid "CNPJ"
|
464 |
msgstr ""
|
465 |
|
466 |
-
#: includes/class-
|
467 |
msgctxt "placeholder"
|
468 |
msgid "State Registration"
|
469 |
msgstr ""
|
470 |
|
471 |
-
#: includes/class-
|
472 |
msgctxt "placeholder"
|
473 |
msgid "Birthdate"
|
474 |
msgstr ""
|
475 |
|
476 |
-
#: includes/class-
|
477 |
-
#: includes/class-
|
478 |
msgctxt "placeholder"
|
479 |
msgid "Number"
|
480 |
msgstr ""
|
481 |
|
482 |
-
#: includes/class-
|
483 |
-
#: includes/class-
|
484 |
msgctxt "placeholder"
|
485 |
msgid "Neighborhood"
|
486 |
msgstr ""
|
487 |
|
488 |
-
#: includes/class-
|
489 |
msgctxt "placeholder"
|
490 |
msgid "Cell Phone"
|
491 |
msgstr ""
|
1 |
# Copyright (C) 2017 Claudio Sanches
|
2 |
+
# This file is distributed under the GPLv2 or later.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: WooCommerce Extra Checkout Fields for Brazil 3.5.0\n"
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/woocommerce-extra-checkout-fields-for-"
|
8 |
"brazil\n"
|
9 |
+
"POT-Creation-Date: 2017-04-03 07:02:17+00:00\n"
|
10 |
"MIME-Version: 1.0\n"
|
11 |
"Content-Type: text/plain; charset=utf-8\n"
|
12 |
"Content-Transfer-Encoding: 8bit\n"
|
13 |
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
|
14 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
15 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
16 |
+
"X-Generator: grunt-wp-i18n1.0.0\n"
|
17 |
|
18 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-admin.php:49
|
19 |
msgid "Load the customer extras data?"
|
20 |
msgstr ""
|
21 |
|
22 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-admin.php:50
|
23 |
msgid "Also copy the data of number and neighborhood?"
|
24 |
msgstr ""
|
25 |
|
26 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-customer.php:39
|
27 |
msgid "Customer Billing Address"
|
28 |
msgstr ""
|
29 |
|
30 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-customer.php:47
|
31 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:66
|
32 |
+
#: includes/admin/views/html-legacy-order-billing-data.php:22
|
33 |
+
#: includes/admin/views/html-order-billing-data.php:22
|
34 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:124
|
35 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:141
|
36 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:418
|
37 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:422
|
38 |
msgid "CPF"
|
39 |
msgstr ""
|
40 |
|
41 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-customer.php:53
|
42 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:71
|
43 |
+
#: includes/admin/views/html-legacy-order-billing-data.php:24
|
44 |
+
#: includes/admin/views/html-order-billing-data.php:24
|
45 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:133
|
46 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:426
|
47 |
msgid "RG"
|
48 |
msgstr ""
|
49 |
|
50 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-customer.php:62
|
51 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:83
|
52 |
+
#: includes/admin/views/html-legacy-order-billing-data.php:30
|
53 |
+
#: includes/admin/views/html-order-billing-data.php:30
|
54 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:162
|
55 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:179
|
56 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:437
|
57 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:441
|
58 |
msgid "CNPJ"
|
59 |
msgstr ""
|
60 |
|
61 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-customer.php:68
|
62 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:88
|
63 |
+
#: includes/admin/views/html-legacy-order-billing-data.php:33
|
64 |
+
#: includes/admin/views/html-order-billing-data.php:33
|
65 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:171
|
66 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:445
|
67 |
msgid "State Registration"
|
68 |
msgstr ""
|
69 |
|
70 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-customer.php:79
|
71 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:102
|
72 |
+
#: includes/admin/views/html-legacy-order-billing-data.php:41
|
73 |
+
#: includes/admin/views/html-order-billing-data.php:41
|
74 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:198
|
75 |
msgid "Birthdate"
|
76 |
msgstr ""
|
77 |
|
78 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-customer.php:83
|
79 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:106
|
80 |
+
#: includes/admin/views/html-legacy-order-billing-data.php:42
|
81 |
+
#: includes/admin/views/html-order-billing-data.php:42
|
82 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:208
|
83 |
msgid "Sex"
|
84 |
msgstr ""
|
85 |
|
86 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-customer.php:90
|
87 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-customer.php:120
|
88 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:113
|
89 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:154
|
90 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:238
|
91 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:355
|
92 |
msgid "Number"
|
93 |
msgstr ""
|
94 |
|
95 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-customer.php:95
|
96 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-customer.php:125
|
97 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:118
|
98 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:159
|
99 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:254
|
100 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:371
|
101 |
msgid "Neighborhood"
|
102 |
msgstr ""
|
103 |
|
104 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-customer.php:106
|
105 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:130
|
106 |
+
#: includes/admin/views/html-legacy-order-billing-data.php:48
|
107 |
+
#: includes/admin/views/html-order-billing-data.php:48
|
108 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:281
|
109 |
msgid "Cell Phone"
|
110 |
msgstr ""
|
111 |
|
112 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-customer.php:114
|
113 |
msgid "Customer Shipping Address"
|
114 |
msgstr ""
|
115 |
|
116 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:54
|
117 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:109
|
118 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:412
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
msgid "Person type"
|
120 |
msgstr ""
|
121 |
|
122 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:57
|
123 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:113
|
124 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:213
|
125 |
msgid "Select"
|
126 |
msgstr ""
|
127 |
|
128 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:58
|
129 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:114
|
130 |
msgid "Individuals"
|
131 |
msgstr ""
|
132 |
|
133 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:59
|
134 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:115
|
135 |
msgid "Legal Person"
|
136 |
msgstr ""
|
137 |
|
138 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:79
|
139 |
+
#: includes/admin/views/html-legacy-order-billing-data.php:29
|
140 |
+
#: includes/admin/views/html-order-billing-data.php:29
|
141 |
msgid "Company Name"
|
142 |
msgstr ""
|
143 |
|
144 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-order.php:95
|
145 |
+
#: includes/admin/views/html-legacy-order-billing-data.php:37
|
146 |
+
#: includes/admin/views/html-order-billing-data.php:37
|
147 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:433
|
148 |
msgid "Company"
|
149 |
msgstr ""
|
150 |
|
151 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:31
|
152 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:32
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
msgid "Checkout Fields"
|
154 |
msgstr ""
|
155 |
|
156 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:55
|
157 |
msgid "Checkout Custom Fields:"
|
158 |
msgstr ""
|
159 |
|
160 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:63
|
161 |
msgid "Display Person Type:"
|
162 |
msgstr ""
|
163 |
|
164 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:70
|
165 |
msgid "Individuals enables CPF field and Legal Person enables CNPJ field."
|
166 |
msgstr ""
|
167 |
|
168 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:72
|
169 |
msgid "None"
|
170 |
msgstr ""
|
171 |
|
172 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:73
|
173 |
msgid "Individuals and Legal Person"
|
174 |
msgstr ""
|
175 |
|
176 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:74
|
177 |
msgid "Individuals only"
|
178 |
msgstr ""
|
179 |
|
180 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:75
|
181 |
msgid "Legal Person only"
|
182 |
msgstr ""
|
183 |
|
184 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:83
|
185 |
msgid "Person Type is required only in Brazil?"
|
186 |
msgstr ""
|
187 |
|
188 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:90
|
189 |
msgid ""
|
190 |
"If checked the Individuals and Legal Person options will be mandatory only "
|
191 |
"in Brazil."
|
192 |
msgstr ""
|
193 |
|
194 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:97
|
195 |
msgid "Display RG:"
|
196 |
msgstr ""
|
197 |
|
198 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:104
|
199 |
msgid "If checked show the RG field in billing options."
|
200 |
msgstr ""
|
201 |
|
202 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:111
|
203 |
msgid "Display State Registration:"
|
204 |
msgstr ""
|
205 |
|
206 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:118
|
207 |
msgid "If checked show the State Registration field in billing options."
|
208 |
msgstr ""
|
209 |
|
210 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:125
|
211 |
msgid "Display Birthdate and Sex:"
|
212 |
msgstr ""
|
213 |
|
214 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:132
|
215 |
msgid "If checked show the Birthdate and Sex field in billing options."
|
216 |
msgstr ""
|
217 |
|
218 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:139
|
219 |
msgid "Display Cell Phone:"
|
220 |
msgstr ""
|
221 |
|
222 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:146
|
223 |
msgid "If checked show the Cell Phone field in billing options."
|
224 |
msgstr ""
|
225 |
|
226 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:153
|
227 |
msgid "jQuery Options:"
|
228 |
msgstr ""
|
229 |
|
230 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:161
|
231 |
msgid "Enable Mail Check:"
|
232 |
msgstr ""
|
233 |
|
234 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:168
|
235 |
msgid "If checked informs typos in email to users."
|
236 |
msgstr ""
|
237 |
|
238 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:175
|
239 |
msgid "Enable Input Mask:"
|
240 |
msgstr ""
|
241 |
|
242 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:182
|
243 |
msgid ""
|
244 |
"If checked create masks fill for in fields of CPF, CNPJ, Birthdate, Phone "
|
245 |
"and Cell Phone."
|
246 |
msgstr ""
|
247 |
|
248 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:190
|
249 |
msgid "Enable Address Autocomplete:"
|
250 |
msgstr ""
|
251 |
|
252 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:197
|
253 |
msgid "If checked automatically complete the address fields based on the zip code."
|
254 |
msgstr ""
|
255 |
|
256 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:205
|
257 |
msgid "Validation:"
|
258 |
msgstr ""
|
259 |
|
260 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:213
|
261 |
msgid "Validate CPF:"
|
262 |
msgstr ""
|
263 |
|
264 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:220
|
265 |
msgid "Checks if the CPF is valid."
|
266 |
msgstr ""
|
267 |
|
268 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:227
|
269 |
msgid "Validate CNPJ:"
|
270 |
msgstr ""
|
271 |
|
272 |
+
#: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:234
|
273 |
msgid "Checks if the CNPJ is valid."
|
274 |
msgstr ""
|
275 |
|
276 |
+
#: includes/admin/views/html-admin-help-message.php:14
|
277 |
+
msgid ""
|
278 |
+
"Help us keep the %s plugin free making a donation or rate "
|
279 |
+
"★★★★★ on WordPress.org. Thank you in advance!"
|
280 |
+
msgstr ""
|
281 |
+
|
282 |
+
#: includes/admin/views/html-admin-help-message.php:14
|
283 |
+
msgid "WooCommerce Correios"
|
284 |
+
msgstr ""
|
285 |
+
|
286 |
+
#: includes/admin/views/html-admin-help-message.php:15
|
287 |
+
msgid "Make a donation"
|
288 |
+
msgstr ""
|
289 |
+
|
290 |
+
#: includes/admin/views/html-admin-help-message.php:15
|
291 |
+
msgid "Make a review"
|
292 |
+
msgstr ""
|
293 |
+
|
294 |
+
#: includes/admin/views/html-legacy-order-billing-data.php:17
|
295 |
+
#: includes/admin/views/html-order-billing-data.php:17
|
296 |
+
msgid "Customer data"
|
297 |
+
msgstr ""
|
298 |
+
|
299 |
+
#: includes/admin/views/html-legacy-order-billing-data.php:45
|
300 |
+
#: includes/admin/views/html-order-billing-data.php:45
|
301 |
+
msgid "Phone"
|
302 |
+
msgstr ""
|
303 |
+
|
304 |
+
#: includes/admin/views/html-legacy-order-billing-data.php:51
|
305 |
+
#: includes/admin/views/html-order-billing-data.php:51
|
306 |
+
msgid "Email"
|
307 |
+
msgstr ""
|
308 |
+
|
309 |
+
#: includes/class-extra-checkout-fields-for-brazil-api.php:373
|
310 |
+
#: includes/class-extra-checkout-fields-for-brazil-api.php:423
|
311 |
msgid "Number."
|
312 |
msgstr ""
|
313 |
|
314 |
+
#: includes/class-extra-checkout-fields-for-brazil-api.php:378
|
315 |
+
#: includes/class-extra-checkout-fields-for-brazil-api.php:428
|
316 |
msgid "Neighborhood."
|
317 |
msgstr ""
|
318 |
|
319 |
+
#: includes/class-extra-checkout-fields-for-brazil-api.php:383
|
320 |
msgid "Person type."
|
321 |
msgstr ""
|
322 |
|
323 |
+
#: includes/class-extra-checkout-fields-for-brazil-api.php:388
|
324 |
msgid "CPF."
|
325 |
msgstr ""
|
326 |
|
327 |
+
#: includes/class-extra-checkout-fields-for-brazil-api.php:393
|
328 |
msgid "RG."
|
329 |
msgstr ""
|
330 |
|
331 |
+
#: includes/class-extra-checkout-fields-for-brazil-api.php:398
|
332 |
msgid "CNPJ."
|
333 |
msgstr ""
|
334 |
|
335 |
+
#: includes/class-extra-checkout-fields-for-brazil-api.php:403
|
336 |
msgid "IE."
|
337 |
msgstr ""
|
338 |
|
339 |
+
#: includes/class-extra-checkout-fields-for-brazil-api.php:408
|
340 |
msgid "Birthdate."
|
341 |
msgstr ""
|
342 |
|
343 |
+
#: includes/class-extra-checkout-fields-for-brazil-api.php:413
|
344 |
msgid "Gender."
|
345 |
msgstr ""
|
346 |
|
347 |
+
#: includes/class-extra-checkout-fields-for-brazil-api.php:418
|
348 |
msgid "Cell Phone."
|
349 |
msgstr ""
|
350 |
|
351 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:62
|
352 |
+
msgid "State"
|
353 |
+
msgstr ""
|
354 |
+
|
355 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:63
|
356 |
msgid "required"
|
357 |
msgstr ""
|
358 |
|
359 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:214
|
360 |
msgid "Female"
|
361 |
msgstr ""
|
362 |
|
363 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:215
|
364 |
msgid "Male"
|
365 |
msgstr ""
|
366 |
|
367 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:248
|
368 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:365
|
369 |
msgid "Address line 2"
|
370 |
msgstr ""
|
371 |
|
372 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:412
|
373 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:418
|
374 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:426
|
375 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:433
|
376 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:437
|
377 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:445
|
378 |
msgid "is a required field"
|
379 |
msgstr ""
|
380 |
|
381 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:422
|
382 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:441
|
383 |
msgid "is not valid"
|
384 |
msgstr ""
|
385 |
|
386 |
+
#: woocommerce-extra-checkout-fields-for-brazil.php:137
|
387 |
+
msgid "Settings"
|
388 |
+
msgstr ""
|
389 |
+
|
390 |
+
#: woocommerce-extra-checkout-fields-for-brazil.php:148
|
391 |
msgid "WooCommerce Extra Checkout Fields for Brazil depends on %s to work!"
|
392 |
msgstr ""
|
393 |
|
394 |
+
#: woocommerce-extra-checkout-fields-for-brazil.php:148
|
395 |
msgid "WooCommerce"
|
396 |
msgstr ""
|
397 |
|
400 |
msgstr ""
|
401 |
|
402 |
#. Plugin URI of the plugin/theme
|
403 |
+
msgid ""
|
404 |
+
"https://github.com/claudiosanches/woocommerce-extra-checkout-fields-for-"
|
405 |
+
"brazil"
|
406 |
msgstr ""
|
407 |
|
408 |
#. Description of the plugin/theme
|
409 |
msgid ""
|
410 |
+
"Adds new checkout fields, field masks and other things necessary to "
|
411 |
+
"properly work with WooCommerce on Brazil."
|
|
|
412 |
msgstr ""
|
413 |
|
414 |
#. Author of the plugin/theme
|
416 |
msgstr ""
|
417 |
|
418 |
#. Author URI of the plugin/theme
|
419 |
+
msgid "https://claudiosanches.com"
|
420 |
msgstr ""
|
421 |
|
422 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:125
|
423 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:142
|
424 |
msgctxt "placeholder"
|
425 |
msgid "CPF"
|
426 |
msgstr ""
|
427 |
|
428 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:134
|
429 |
msgctxt "placeholder"
|
430 |
msgid "RG"
|
431 |
msgstr ""
|
432 |
|
433 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:163
|
434 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:180
|
435 |
msgctxt "placeholder"
|
436 |
msgid "CNPJ"
|
437 |
msgstr ""
|
438 |
|
439 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:172
|
440 |
msgctxt "placeholder"
|
441 |
msgid "State Registration"
|
442 |
msgstr ""
|
443 |
|
444 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:199
|
445 |
msgctxt "placeholder"
|
446 |
msgid "Birthdate"
|
447 |
msgstr ""
|
448 |
|
449 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:239
|
450 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:356
|
451 |
msgctxt "placeholder"
|
452 |
msgid "Number"
|
453 |
msgstr ""
|
454 |
|
455 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:255
|
456 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:372
|
457 |
msgctxt "placeholder"
|
458 |
msgid "Neighborhood"
|
459 |
msgstr ""
|
460 |
|
461 |
+
#: includes/class-extra-checkout-fields-for-brazil-front-end.php:282
|
462 |
msgctxt "placeholder"
|
463 |
msgid "Cell Phone"
|
464 |
msgstr ""
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://claudiosmweb.com/doacoes/
|
|
4 |
Tags: woocommerce, checkout, brazil, cpf, cpnj, rg, ie
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 4.7
|
7 |
-
Stable tag: 3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -16,11 +16,9 @@ Adiciona novos campos para Pessoa Física ou Jurídica, Data de Nascimento, Sexo
|
|
16 |
|
17 |
É necessário estar utilizando uma versão do [WooCommerce](http://wordpress.org/extend/plugins/woocommerce/) para que o WooCommerce Extra Checkout Fields for Brazil funcione.
|
18 |
|
19 |
-
A partir da versão 3.1.0 é feita integração também com a [API](http://docs.woothemes.com/document/woocommerce-rest-api/) de pedidos e de clientes do WooCommerce.
|
20 |
-
|
21 |
= Compatibilidade =
|
22 |
|
23 |
-
Compatível desde a versão 2.2.x até
|
24 |
|
25 |
Funciona com os plugins:
|
26 |
|
@@ -40,23 +38,13 @@ Você pode esclarecer suas dúvidas usando:
|
|
40 |
Foram utilizados os seguintes scripts/serviços de terceiros:
|
41 |
|
42 |
* [MailCheck jQuery](https://github.com/Kicksend/mailcheck).
|
43 |
-
* [
|
44 |
* [Correios RESTful API por Emerson Soares](http://correiosapi.apphb.com/).
|
45 |
|
46 |
= Colaborar =
|
47 |
|
48 |
Você pode contribuir com código-fonte em nossa página no [GitHub](https://github.com/claudiosmweb/woocommerce-extra-checkout-fields-for-brazil).
|
49 |
|
50 |
-
== Installation ==
|
51 |
-
|
52 |
-
* Upload plugin files to your plugins folder, or install using WordPress built-in Add New Plugin installer;
|
53 |
-
* Activate the plugin.
|
54 |
-
|
55 |
-
= Instalação e configuração em Português: =
|
56 |
-
|
57 |
-
* Envie os arquivos do plugin para a pasta wp-content/plugins ou usando o instalador de plugins do WordPress.
|
58 |
-
* Ative o plugin.
|
59 |
-
|
60 |
== Frequently Asked Questions ==
|
61 |
|
62 |
= Qual é a licença do plugin? =
|
@@ -77,45 +65,16 @@ Você pode contribuir com código-fonte em nossa página no [GitHub](https://git
|
|
77 |
|
78 |
== Changelog ==
|
79 |
|
80 |
-
= 3.
|
81 |
-
|
82 |
-
- Corrigido alinhamento do campo de CEP na página de edição de endereços em "Minha conta".
|
83 |
-
|
84 |
-
= 3.4.5 - 2016/10/09 =
|
85 |
-
|
86 |
-
- Melhorada validação do campo "sexo".
|
87 |
-
- Melhorado o registro e carregamento dos scripts do plugin.
|
88 |
-
|
89 |
-
= 3.4.4 - 2016/06/20 =
|
90 |
-
|
91 |
-
- Adicionado suporte a nova API REST do WooCommerce.
|
92 |
-
- Corrigido localização do campo de CEP na página de editar endereços.
|
93 |
-
- Corrigido os campos de bairro e número no método `WC_Order::get_order_address()`.
|
94 |
-
- Adicionada compatibilidade com o WooCommerce Correios 3.0.0.
|
95 |
-
|
96 |
-
= 3.4.3 - 2016/03/20 =
|
97 |
-
|
98 |
-
- Corrigida as mascaras quando não esta preenchendo um endereço brasileiro.
|
99 |
-
- Incluídos os campos de bairro e número no método `WC_Order::get_order_address()`.
|
100 |
-
|
101 |
-
= 3.4.2 - 2016/02/10 =
|
102 |
-
|
103 |
-
- Adicionado o filtro `wcbcf_disable_checkout_validation` para suportar o plugin [WooCommerce Digital Goods Checkout](https://wordpress.org/plugins/wc-digital-goods-checkout/).
|
104 |
-
|
105 |
-
= 3.4.1 - 2015/09/07 =
|
106 |
-
|
107 |
-
- Corrigido erros na tela de configurações do plugin.
|
108 |
-
- Corrigido os campos de estado e país na tela de edição de usuário no administrador do WordPress.
|
109 |
-
|
110 |
-
= 3.4.0 - 2015/08/18 =
|
111 |
|
112 |
-
- Adicionado suporte
|
113 |
-
-
|
114 |
-
- Corrigida
|
|
|
|
|
115 |
|
116 |
== Upgrade Notice ==
|
117 |
|
118 |
-
= 3.
|
119 |
|
120 |
-
-
|
121 |
-
- Melhorado o registro e carregamento dos scripts do plugin.
|
4 |
Tags: woocommerce, checkout, brazil, cpf, cpnj, rg, ie
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 4.7
|
7 |
+
Stable tag: 3.5.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
16 |
|
17 |
É necessário estar utilizando uma versão do [WooCommerce](http://wordpress.org/extend/plugins/woocommerce/) para que o WooCommerce Extra Checkout Fields for Brazil funcione.
|
18 |
|
|
|
|
|
19 |
= Compatibilidade =
|
20 |
|
21 |
+
Compatível desde a versão 2.2.x até 3.0.x do WooCommerce.
|
22 |
|
23 |
Funciona com os plugins:
|
24 |
|
38 |
Foram utilizados os seguintes scripts/serviços de terceiros:
|
39 |
|
40 |
* [MailCheck jQuery](https://github.com/Kicksend/mailcheck).
|
41 |
+
* [jQuery Mask Plugin](https://github.com/igorescobar/jQuery-Mask-Plugin).
|
42 |
* [Correios RESTful API por Emerson Soares](http://correiosapi.apphb.com/).
|
43 |
|
44 |
= Colaborar =
|
45 |
|
46 |
Você pode contribuir com código-fonte em nossa página no [GitHub](https://github.com/claudiosmweb/woocommerce-extra-checkout-fields-for-brazil).
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
== Frequently Asked Questions ==
|
49 |
|
50 |
= Qual é a licença do plugin? =
|
65 |
|
66 |
== Changelog ==
|
67 |
|
68 |
+
= 3.5.0 - 2017/03/04 =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
+
- Adicionado suporte ao WooCommerce 3.0.
|
71 |
+
- Alterado o plugin de máscara de [jquery.maskedinput](https://github.com/digitalBush/jquery.maskedinput) para [jquery.mask](https://github.com/igorescobar/jQuery-Mask-Plugin). (Possível com a ajuda de [Thiago Guimarães](https://github.com/thiagogsr)).
|
72 |
+
- Corrigida a máscara dos campos telefone e celular, permitido ter 10 ou 11 dígitos sem alterar a experiência do usuário. (Possível com a ajuda de [Thiago Guimarães](https://github.com/thiagogsr)).
|
73 |
+
- Alterados os tipos dos campos telefone, celular, cep, data de nascimento para `tel` quando o país selecionado for BR. (Possível com a ajuda de [Thiago Guimarães](https://github.com/thiagogsr)).
|
74 |
+
- Alterados os tipos dos campos cpf, cnpj para `tel` e e-mail para `email`. (Possível com a ajuda de [Thiago Guimarães](https://github.com/thiagogsr)).
|
75 |
|
76 |
== Upgrade Notice ==
|
77 |
|
78 |
+
= 3.5.0 =
|
79 |
|
80 |
+
- Suporte ao WooCommerce 3.0, correção das máscaras no mobile e outras correções.
|
|
uninstall.php
CHANGED
@@ -1,4 +1,10 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
// If uninstall not called from WordPress exit.
|
3 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
4 |
exit();
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Uninstall file.
|
4 |
+
*
|
5 |
+
* @package Extra_Checkout_Fields_For_Brazil/Uninstall
|
6 |
+
*/
|
7 |
+
|
8 |
// If uninstall not called from WordPress exit.
|
9 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
10 |
exit();
|
woocommerce-extra-checkout-fields-for-brazil.php
CHANGED
@@ -1,15 +1,30 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: WooCommerce Extra Checkout Fields for Brazil
|
4 |
-
* Plugin URI:
|
5 |
-
* Description:
|
6 |
-
*
|
7 |
-
* Author:
|
8 |
-
*
|
|
|
9 |
* Text Domain: woocommerce-extra-checkout-fields-for-brazil
|
10 |
-
* License: GPL-2.0+
|
11 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
12 |
* Domain Path: /languages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
*/
|
14 |
|
15 |
if ( ! defined( 'ABSPATH' ) ) {
|
@@ -28,7 +43,7 @@ class Extra_Checkout_Fields_For_Brazil {
|
|
28 |
*
|
29 |
* @var string
|
30 |
*/
|
31 |
-
const VERSION = '3.
|
32 |
|
33 |
/**
|
34 |
* Instance of this class.
|
@@ -51,6 +66,7 @@ class Extra_Checkout_Fields_For_Brazil {
|
|
51 |
}
|
52 |
|
53 |
$this->includes();
|
|
|
54 |
} else {
|
55 |
add_action( 'admin_notices', array( $this, 'woocommerce_fallback_notice' ) );
|
56 |
}
|
@@ -63,7 +79,7 @@ class Extra_Checkout_Fields_For_Brazil {
|
|
63 |
*/
|
64 |
public static function get_instance() {
|
65 |
// If the single instance hasn't been set, set it now.
|
66 |
-
if ( null
|
67 |
self::$instance = new self;
|
68 |
}
|
69 |
|
@@ -93,20 +109,34 @@ class Extra_Checkout_Fields_For_Brazil {
|
|
93 |
* Includes.
|
94 |
*/
|
95 |
private function includes() {
|
96 |
-
include_once 'includes/class-
|
97 |
-
include_once 'includes/class-
|
98 |
-
include_once 'includes/class-
|
99 |
-
include_once 'includes/class-
|
100 |
}
|
101 |
|
102 |
/**
|
103 |
* Admin includes.
|
104 |
*/
|
105 |
private function admin_includes() {
|
106 |
-
include_once 'includes/admin/class-
|
107 |
-
include_once 'includes/admin/class-
|
108 |
-
include_once 'includes/admin/class-
|
109 |
-
include_once 'includes/admin/class-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
111 |
|
112 |
/**
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: WooCommerce Extra Checkout Fields for Brazil
|
4 |
+
* Plugin URI: https://github.com/claudiosanches/woocommerce-extra-checkout-fields-for-brazil
|
5 |
+
* Description: Adds new checkout fields, field masks and other things necessary to properly work with WooCommerce on Brazil.
|
6 |
+
* Author: Claudio Sanches
|
7 |
+
* Author URI: https://claudiosanches.com
|
8 |
+
* Version: 3.5.0
|
9 |
+
* License: GPLv2 or later
|
10 |
* Text Domain: woocommerce-extra-checkout-fields-for-brazil
|
|
|
|
|
11 |
* Domain Path: /languages
|
12 |
+
*
|
13 |
+
* WooCommerce Extra Checkout Fields for Brazil is free software: you can
|
14 |
+
* redistribute it and/or modify it under the terms of the
|
15 |
+
* GNU General Public License as published by the Free Software Foundation,
|
16 |
+
* either version 2 of the License, or any later version.
|
17 |
+
*
|
18 |
+
* WooCommerce Extra Checkout Fields for Brazil is distributed in the hope
|
19 |
+
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
20 |
+
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
+
* GNU General Public License for more details.
|
22 |
+
*
|
23 |
+
* You should have received a copy of the GNU General Public License
|
24 |
+
* along with WooCommerce Extra Checkout Fields for Brazil. If not, see
|
25 |
+
* <https://www.gnu.org/licenses/gpl-2.0.txt>.
|
26 |
+
*
|
27 |
+
* @package Extra_Checkout_Fields_For_Brazil
|
28 |
*/
|
29 |
|
30 |
if ( ! defined( 'ABSPATH' ) ) {
|
43 |
*
|
44 |
* @var string
|
45 |
*/
|
46 |
+
const VERSION = '3.5.0';
|
47 |
|
48 |
/**
|
49 |
* Instance of this class.
|
66 |
}
|
67 |
|
68 |
$this->includes();
|
69 |
+
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
|
70 |
} else {
|
71 |
add_action( 'admin_notices', array( $this, 'woocommerce_fallback_notice' ) );
|
72 |
}
|
79 |
*/
|
80 |
public static function get_instance() {
|
81 |
// If the single instance hasn't been set, set it now.
|
82 |
+
if ( null === self::$instance ) {
|
83 |
self::$instance = new self;
|
84 |
}
|
85 |
|
109 |
* Includes.
|
110 |
*/
|
111 |
private function includes() {
|
112 |
+
include_once dirname( __FILE__ ) . '/includes/class-extra-checkout-fields-for-brazil-formatting.php';
|
113 |
+
include_once dirname( __FILE__ ) . '/includes/class-extra-checkout-fields-for-brazil-front-end.php';
|
114 |
+
include_once dirname( __FILE__ ) . '/includes/class-extra-checkout-fields-for-brazil-integrations.php';
|
115 |
+
include_once dirname( __FILE__ ) . '/includes/class-extra-checkout-fields-for-brazil-api.php';
|
116 |
}
|
117 |
|
118 |
/**
|
119 |
* Admin includes.
|
120 |
*/
|
121 |
private function admin_includes() {
|
122 |
+
include_once dirname( __FILE__ ) . '/includes/admin/class-extra-checkout-fields-for-brazil-admin.php';
|
123 |
+
include_once dirname( __FILE__ ) . '/includes/admin/class-extra-checkout-fields-for-brazil-settings.php';
|
124 |
+
include_once dirname( __FILE__ ) . '/includes/admin/class-extra-checkout-fields-for-brazil-order.php';
|
125 |
+
include_once dirname( __FILE__ ) . '/includes/admin/class-extra-checkout-fields-for-brazil-customer.php';
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Action links.
|
130 |
+
*
|
131 |
+
* @param array $links Default plugin links.
|
132 |
+
*
|
133 |
+
* @return array
|
134 |
+
*/
|
135 |
+
public function plugin_action_links( $links ) {
|
136 |
+
$plugin_links = array();
|
137 |
+
$plugin_links[] = '<a href="' . esc_url( admin_url( 'admin.php?page=woocommerce-extra-checkout-fields-for-brazil' ) ) . '">' . __( 'Settings', 'woocommerce-extra-checkout-fields-for-brazil' ) . '</a>';
|
138 |
+
|
139 |
+
return array_merge( $plugin_links, $links );
|
140 |
}
|
141 |
|
142 |
/**
|