WooCommerce Extra Checkout Fields for Brazil - Version 3.7.0

Version Description

  • 2019/09/20 =

  • Nome do plugin alterado de "WooCommerce Extra Checkout Fields for Brazil" to "Brazilian Market on WooCommerce".

  • Removida opo obsoleta de preenchimento de endereo, no lugar dela utilize a integrao direta que existe no plugin "Claudio Sanches - Correios for WooCommerce".

Download this release

Release Info

Developer claudiosanches
Plugin Icon 128x128 WooCommerce Extra Checkout Fields for Brazil
Version 3.7.0
Comparing to
See all releases

Code changes from version 3.6.1 to 3.7.0

Files changed (42) hide show
  1. assets/js/frontend/frontend.js +3 -62
  2. assets/js/frontend/frontend.min.js +1 -1
  3. includes/admin/class-extra-checkout-fields-for-brazil-settings.php +3 -19
  4. includes/admin/views/html-admin-help-message.php +1 -1
  5. includes/class-extra-checkout-fields-for-brazil-front-end.php +6 -0
  6. trunk/phpcs.ruleset.xml → phpcs.ruleset.xml +0 -0
  7. readme.txt +18 -11
  8. trunk/assets/css/admin/admin.css +0 -1
  9. trunk/assets/css/admin/admin.scss +0 -20
  10. trunk/assets/css/admin/settings.css +0 -1
  11. trunk/assets/css/admin/settings.scss +0 -42
  12. trunk/assets/css/frontend/frontend.css +0 -1
  13. trunk/assets/css/frontend/frontend.scss +0 -9
  14. trunk/assets/js/admin/admin.js +0 -43
  15. trunk/assets/js/admin/admin.min.js +0 -1
  16. trunk/assets/js/admin/shop-order.js +0 -133
  17. trunk/assets/js/admin/shop-order.min.js +0 -1
  18. trunk/assets/js/frontend/frontend.js +0 -236
  19. trunk/assets/js/frontend/frontend.min.js +0 -1
  20. trunk/assets/js/jquery.mask/jquery.mask.js +0 -540
  21. trunk/assets/js/jquery.mask/jquery.mask.min.js +0 -18
  22. trunk/assets/js/mailcheck/mailcheck.js +0 -267
  23. trunk/assets/js/mailcheck/mailcheck.min.js +0 -1
  24. trunk/includes/admin/class-extra-checkout-fields-for-brazil-admin.php +0 -101
  25. trunk/includes/admin/class-extra-checkout-fields-for-brazil-customer.php +0 -169
  26. trunk/includes/admin/class-extra-checkout-fields-for-brazil-order.php +0 -327
  27. trunk/includes/admin/class-extra-checkout-fields-for-brazil-settings.php +0 -309
  28. trunk/includes/admin/views/html-admin-help-message.php +0 -17
  29. trunk/includes/admin/views/html-checkbox-field.php +0 -18
  30. trunk/includes/admin/views/html-legacy-order-billing-data.php +0 -55
  31. trunk/includes/admin/views/html-order-billing-data.php +0 -55
  32. trunk/includes/admin/views/html-select-field.php +0 -19
  33. trunk/includes/admin/views/html-settings-page.php +0 -28
  34. trunk/includes/class-extra-checkout-fields-for-brazil-api.php +0 -437
  35. trunk/includes/class-extra-checkout-fields-for-brazil-formatting.php +0 -73
  36. trunk/includes/class-extra-checkout-fields-for-brazil-front-end.php +0 -567
  37. trunk/includes/class-extra-checkout-fields-for-brazil-integrations.php +0 -129
  38. trunk/languages/woocommerce-extra-checkout-fields-for-brazil.pot +0 -415
  39. trunk/readme.txt +0 -93
  40. trunk/uninstall.php +0 -14
  41. trunk/woocommerce-extra-checkout-fields-for-brazil.php +0 -157
  42. woocommerce-extra-checkout-fields-for-brazil.php +7 -7
assets/js/frontend/frontend.js CHANGED
@@ -43,20 +43,13 @@ jQuery( function( $ ) {
43
  this.emailCheck();
44
  }
45
 
46
- if ( 'yes' === wcbcf_public_params.addresscomplete ) {
47
- // Auto complete billing address.
48
- this.addressAutoComplete( 'billing' );
49
- this.addressAutoCompleteOnChange( 'billing' );
50
-
51
- // Auto complete shipping address.
52
- this.addressAutoComplete( 'shipping' );
53
- this.addressAutoCompleteOnChange( 'shipping' );
54
- }
55
-
56
  // Check if select2 exists.
57
  if ( $().select2 ) {
58
  $( '.wc-ecfb-select' ).select2();
59
  }
 
 
 
60
  },
61
 
62
  /**
@@ -177,58 +170,6 @@ jQuery( function( $ ) {
177
  color: '#c00',
178
  fontSize: 'small'
179
  });
180
- },
181
-
182
- addressAutoComplete: function( field ) {
183
- // Checks with *_postcode field exist.
184
- if ( $( '#' + field + '_postcode' ).length ) {
185
-
186
- // Valid CEP.
187
- var cep = $( '#' + field + '_postcode' ).val().replace( '.', '' ).replace( '-', '' ),
188
- country = $( '#' + field + '_country' ).val(),
189
- address_1 = $( '#' + field + '_address_1' ).val();
190
-
191
- // Check country is BR.
192
- if ( cep !== '' && 8 === cep.length && 'BR' === country && 0 === address_1.length ) {
193
-
194
- // Gets the address.
195
- $.ajax({
196
- type: 'GET',
197
- url: '//correiosapi.apphb.com/cep/' + cep,
198
- dataType: 'jsonp',
199
- crossDomain: true,
200
- contentType: 'application/json',
201
- success: function ( address ) {
202
-
203
- // Address.
204
- if ( '' !== address.tipoDeLogradouro ) {
205
- $( '#' + field + '_address_1' ).val( address.tipoDeLogradouro + ' ' + address.logradouro ).change();
206
- } else {
207
- $( '#' + field + '_address_1' ).val( address.logradouro ).change();
208
- }
209
-
210
- // Neighborhood.
211
- $( '#' + field + '_neighborhood' ).val( address.bairro ).change();
212
-
213
- // City.
214
- $( '#' + field + '_city' ).val( address.cidade ).change();
215
-
216
- // State.
217
- $( '#' + field + '_state option:selected' ).attr( 'selected', false ).change();
218
- $( '#' + field + '_state option[value="' + address.estado + '"]' ).attr( 'selected', 'selected' ).change();
219
-
220
- // Chosen support.
221
- $( '#' + field + '_state' ).trigger( 'liszt:updated' ).trigger( 'chosen:updated' );
222
- }
223
- });
224
- }
225
- }
226
- },
227
-
228
- addressAutoCompleteOnChange: function( field ) {
229
- $( document.body ).on( 'blur', '#' + field + '_postcode', function() {
230
- wc_ecfb_frontend.addressAutoComplete( field );
231
- });
232
  }
233
  };
234
 
43
  this.emailCheck();
44
  }
45
 
 
 
 
 
 
 
 
 
 
 
46
  // Check if select2 exists.
47
  if ( $().select2 ) {
48
  $( '.wc-ecfb-select' ).select2();
49
  }
50
+ if ($('#billing_country').val() === 'BR' ) {
51
+ wc_ecfb_frontend.maskBilling();
52
+ }
53
  },
54
 
55
  /**
170
  color: '#c00',
171
  fontSize: 'small'
172
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  }
174
  };
175
 
assets/js/frontend/frontend.min.js CHANGED
@@ -1 +1 @@
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")),a().select2&&a(".wc-ecfb-select").select2()},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 label .required").remove(),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 label .required").remove(),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 .required").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()});
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(),a().select2&&a(".wc-ecfb-select").select2(),"BR"===a("#billing_country").val()&&b.maskBilling()},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 label .required").remove(),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 label .required").remove(),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 .required").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"})}};b.init()});
includes/admin/class-extra-checkout-fields-for-brazil-settings.php CHANGED
@@ -49,7 +49,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
49
  public function plugin_settings() {
50
  $option = 'wcbcf_settings';
51
 
52
- // Set Custom Fields cection.
53
  add_settings_section(
54
  'options_section',
55
  __( 'Checkout Custom Fields:', 'woocommerce-extra-checkout-fields-for-brazil' ),
@@ -147,7 +147,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
147
  )
148
  );
149
 
150
- // Set Custom Fields cection.
151
  add_settings_section(
152
  'jquery_section',
153
  __( 'jQuery Options:', 'woocommerce-extra-checkout-fields-for-brazil' ),
@@ -183,23 +183,7 @@ class Extra_Checkout_Fields_For_Brazil_Settings {
183
  )
184
  );
185
 
186
- // Address Autocomplete option.
187
- if ( ! apply_filters( 'woocommerce_correios_enable_autofill_addresses', false ) ) {
188
- add_settings_field(
189
- 'addresscomplete',
190
- __( 'Enable Address Autocomplete:', 'woocommerce-extra-checkout-fields-for-brazil' ),
191
- array( $this, 'checkbox_element_callback' ),
192
- $option,
193
- 'jquery_section',
194
- array(
195
- 'menu' => $option,
196
- 'id' => 'addresscomplete',
197
- 'label' => __( 'If checked automatically complete the address fields based on the zip code.', 'woocommerce-extra-checkout-fields-for-brazil' ),
198
- )
199
- );
200
- }
201
-
202
- // Set Custom Fields cection.
203
  add_settings_section(
204
  'validation_section',
205
  __( 'Validation:', 'woocommerce-extra-checkout-fields-for-brazil' ),
49
  public function plugin_settings() {
50
  $option = 'wcbcf_settings';
51
 
52
+ // Set Custom Fields section.
53
  add_settings_section(
54
  'options_section',
55
  __( 'Checkout Custom Fields:', 'woocommerce-extra-checkout-fields-for-brazil' ),
147
  )
148
  );
149
 
150
+ // Set Custom Fields section.
151
  add_settings_section(
152
  'jquery_section',
153
  __( 'jQuery Options:', 'woocommerce-extra-checkout-fields-for-brazil' ),
183
  )
184
  );
185
 
186
+ // Set Custom Fields section.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  add_settings_section(
188
  'validation_section',
189
  __( 'Validation:', 'woocommerce-extra-checkout-fields-for-brazil' ),
includes/admin/views/html-admin-help-message.php CHANGED
@@ -11,7 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) {
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 &#9733;&#9733;&#9733;&#9733;&#9733; on WordPress.org. Thank you in advance!', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'WooCommerce Extra Checkout Fields for Brazil', '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;
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 &#9733;&#9733;&#9733;&#9733;&#9733; on WordPress.org. Thank you in advance!', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'Brazilian Market on WooCommerce', '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/class-extra-checkout-fields-for-brazil-front-end.php CHANGED
@@ -361,6 +361,7 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
361
  'label' => __( 'Neighborhood', 'woocommerce-extra-checkout-fields-for-brazil' ),
362
  'class' => array( 'form-row-first', 'address-field' ),
363
  'clear' => true,
 
364
  );
365
 
366
  if ( isset( $fields['shipping_city'] ) ) {
@@ -475,6 +476,11 @@ class Extra_Checkout_Fields_For_Brazil_Front_End {
475
  * @return array New replacements.
476
  */
477
  public function formatted_address_replacements( $replacements, $args ) {
 
 
 
 
 
478
  $replacements['{number}'] = $args['number'];
479
  $replacements['{neighborhood}'] = $args['neighborhood'];
480
 
361
  'label' => __( 'Neighborhood', 'woocommerce-extra-checkout-fields-for-brazil' ),
362
  'class' => array( 'form-row-first', 'address-field' ),
363
  'clear' => true,
364
+ 'priority' => 65,
365
  );
366
 
367
  if ( isset( $fields['shipping_city'] ) ) {
476
  * @return array New replacements.
477
  */
478
  public function formatted_address_replacements( $replacements, $args ) {
479
+ $args = wp_parse_args( $args, array(
480
+ 'number' => '',
481
+ 'neighborhood' => '',
482
+ ) );
483
+
484
  $replacements['{number}'] = $args['number'];
485
  $replacements['{neighborhood}'] = $args['neighborhood'];
486
 
trunk/phpcs.ruleset.xml → phpcs.ruleset.xml RENAMED
File without changes
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
- === WooCommerce Extra Checkout Fields for Brazil ===
2
  Contributors: claudiosanches
3
  Donate link: http://claudiosmweb.com/doacoes/
4
  Tags: woocommerce, checkout, brazil, cpf, cpnj
5
  Requires at least: 3.5
6
- Tested up to: 4.9
7
- Stable tag: 3.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,9 +12,11 @@ Adds Brazilian checkout fields in WooCommerce
12
 
13
  == Description ==
14
 
15
- Adiciona novos campos para Pessoa Física ou Jurídica, Data de Nascimento, Sexo, Número, Bairro e Celular. Além de máscaras em campos, aviso de e-mail incorreto e auto preenchimento dos campos de endereço pelo CEP.
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
 
@@ -22,9 +24,9 @@ Compatível desde a versão 3.0.x do WooCommerce.
22
 
23
  Funciona com os plugins:
24
 
25
- * [WooCommerce Bcash](http://wordpress.org/extend/plugins/woocommerce-bcash/) (adiciona as informações de **número**, **CPF**, **Razão Social** e **CNPJ**)
26
- * [WooCommerce Moip](http://wordpress.org/extend/plugins/woocommerce-moip/) (adiciona as informações de **bairro** e **número** e melhora o Checkout Transparente)
27
- * [WooCommerce PagSeguro](http://wordpress.org/extend/plugins/woocommerce-pagseguro/) (adiciona as informações de **bairro**, **CPF** e **número**)
28
 
29
  = Dúvidas? =
30
 
@@ -39,7 +41,6 @@ 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
 
@@ -65,6 +66,11 @@ Você pode contribuir com código-fonte em nossa página no [GitHub](https://git
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
68
  = 3.6.1 - 2018/05/24 =
69
 
70
  - Correção de mensagens dizendo que alguns campos eram opcionais, mesmo quando marcados como obrigatórios.
@@ -88,6 +94,7 @@ Você pode contribuir com código-fonte em nossa página no [GitHub](https://git
88
 
89
  == Upgrade Notice ==
90
 
91
- = 3.6.1 =
92
 
93
- - Correção de mensagens dizendo que alguns campos eram opcionais, mesmo quando marcados como obrigatórios.
 
1
+ === Brazilian Market on WooCommerce ===
2
  Contributors: claudiosanches
3
  Donate link: http://claudiosmweb.com/doacoes/
4
  Tags: woocommerce, checkout, brazil, cpf, cpnj
5
  Requires at least: 3.5
6
+ Tested up to: 5.2
7
+ Stable tag: 3.7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ Adiciona novos campos para Pessoa Física ou Jurídica, Data de Nascimento, Sexo, Número, Bairro e Celular. Além de máscaras em campos e aviso de e-mail incorreto.
16
 
17
+ Em breve serão integradas mais novidades para o mercado brasileiro, como poder fazer login por CPF/CNPJ, ocultar alguns campos no carrinho, aguardem!
18
+
19
+ É necessário estar utilizando uma versão do [WooCommerce](http://wordpress.org/extend/plugins/woocommerce/) para que o Brazilian Market on WooCommerce funcione.
20
 
21
  = Compatibilidade =
22
 
24
 
25
  Funciona com os plugins:
26
 
27
+ * [Bcash](http://wordpress.org/extend/plugins/woocommerce-bcash/) (adiciona as informações de **número**, **CPF**, **Razão Social** e **CNPJ**)
28
+ * [Moip](http://wordpress.org/extend/plugins/woocommerce-moip/) (adiciona as informações de **bairro** e **número** e melhora o Checkout Transparente)
29
+ * [PagSeguro](http://wordpress.org/extend/plugins/woocommerce-pagseguro/) (adiciona as informações de **bairro**, **CPF** e **número**)
30
 
31
  = Dúvidas? =
32
 
41
 
42
  * [MailCheck jQuery](https://github.com/Kicksend/mailcheck).
43
  * [jQuery Mask Plugin](https://github.com/igorescobar/jQuery-Mask-Plugin).
 
44
 
45
  = Colaborar =
46
 
66
 
67
  == Changelog ==
68
 
69
+ = 3.7.0 - 2019/09/20 =
70
+
71
+ - Nome do plugin alterado de "WooCommerce Extra Checkout Fields for Brazil" to "Brazilian Market on WooCommerce".
72
+ - Removida opção obsoleta de preenchimento de endereço, no lugar dela utilize a integração direta que existe no plugin "Claudio Sanches - Correios for WooCommerce".
73
+
74
  = 3.6.1 - 2018/05/24 =
75
 
76
  - Correção de mensagens dizendo que alguns campos eram opcionais, mesmo quando marcados como obrigatórios.
94
 
95
  == Upgrade Notice ==
96
 
97
+ = 3.7.0 =
98
 
99
+ - Nome do plugin alterado de "WooCommerce Extra Checkout Fields for Brazil" to "Brazilian Market on WooCommerce".
100
+ - Removida opção obsoleta de preenchimento de endereço, no lugar dela utilize a integração direta que existe no plugin "Claudio Sanches - Correios for WooCommerce".
trunk/assets/css/admin/admin.css DELETED
@@ -1 +0,0 @@
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}
 
trunk/assets/css/admin/admin.scss DELETED
@@ -1,20 +0,0 @@
1
- #order_data {
2
-
3
- .order_data_column {
4
- ._billing_persontype_field,
5
- ._billing_cpf_field,
6
- ._billing_rg_field,
7
- ._billing_cnpj_field,
8
- ._billing_ie_field {
9
- clear: both !important;
10
- width: 100% !important;
11
- }
12
-
13
- ._billing_sex_field,
14
- ._billing_number_field,
15
- ._shipping_number_field {
16
- float: right !important;
17
- clear: right !important;
18
- }
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/assets/css/admin/settings.css DELETED
@@ -1 +0,0 @@
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}
 
trunk/assets/css/admin/settings.scss DELETED
@@ -1,42 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/assets/css/frontend/frontend.css DELETED
@@ -1 +0,0 @@
1
- #billing_persontype_field .optional,#billing_cnpj_field .optional,#billing_ie_field .optional,#billing_cpf_field .optional,#billing_rg_field .optional{display:none}
 
trunk/assets/css/frontend/frontend.scss DELETED
@@ -1,9 +0,0 @@
1
- #billing_persontype_field,
2
- #billing_cnpj_field,
3
- #billing_ie_field,
4
- #billing_cpf_field,
5
- #billing_rg_field {
6
- .optional {
7
- display: none;
8
- }
9
- }
 
 
 
 
 
 
 
 
 
trunk/assets/js/admin/admin.js DELETED
@@ -1,43 +0,0 @@
1
- /*jshint devel: true */
2
- (function ( $ ) {
3
- 'use strict';
4
-
5
- $(function () {
6
- $( '#person_type' ).on( 'change', function () {
7
- var onlyBrazil = $( '.wrap form .form-table:eq(0) tr:eq(1)' ),
8
- rg = $( '.wrap form .form-table:eq(0) tr:eq(2)' ),
9
- ie = $( '.wrap form .form-table:eq(0) tr:eq(3)' ),
10
- validate = $( '.wrap form h3:eq(2), .wrap form .form-table:eq(2)' ),
11
- validateCPF = $( '.wrap form .form-table:eq(2) tr:eq(0)' ),
12
- validateCNPJ = $( '.wrap form .form-table:eq(2) tr:eq(1)' ),
13
- selected = $( this ).val();
14
-
15
- onlyBrazil.hide();
16
- rg.hide();
17
- ie.hide();
18
- validate.hide();
19
- validateCPF.hide();
20
- validateCNPJ.hide();
21
-
22
- if ( '1' === selected ) {
23
- onlyBrazil.show();
24
- rg.show();
25
- ie.show();
26
- validate.show();
27
- validateCPF.show();
28
- validateCNPJ.show();
29
- } else if ( '2' === selected ) {
30
- onlyBrazil.show();
31
- rg.show();
32
- validate.show();
33
- validateCPF.show();
34
- } else if ( '3' === selected ) {
35
- onlyBrazil.show();
36
- ie.show();
37
- validate.show();
38
- validateCNPJ.show();
39
- }
40
- }).change();
41
- });
42
-
43
- }(jQuery));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/assets/js/admin/admin.min.js DELETED
@@ -1 +0,0 @@
1
- !function(a){"use strict";a(function(){a("#person_type").on("change",function(){var b=a(".wrap form .form-table:eq(0) tr:eq(1)"),c=a(".wrap form .form-table:eq(0) tr:eq(2)"),d=a(".wrap form .form-table:eq(0) tr:eq(3)"),e=a(".wrap form h3:eq(2), .wrap form .form-table:eq(2)"),f=a(".wrap form .form-table:eq(2) tr:eq(0)"),g=a(".wrap form .form-table:eq(2) tr:eq(1)"),h=a(this).val();b.hide(),c.hide(),d.hide(),e.hide(),f.hide(),g.hide(),"1"===h?(b.show(),c.show(),d.show(),e.show(),f.show(),g.show()):"2"===h?(b.show(),c.show(),e.show(),f.show()):"3"===h&&(b.show(),d.show(),e.show(),g.show())}).change()})}(jQuery);
 
trunk/assets/js/admin/shop-order.js DELETED
@@ -1,133 +0,0 @@
1
- /* global wcbcf_shop_order_params, woocommerce_admin_meta_boxes */
2
-
3
- /**
4
- * Plugin settings.
5
- */
6
- (function ( $ ) {
7
- 'use strict';
8
-
9
- $( function () {
10
-
11
- if ( '1' === wcbcf_shop_order_params.person_type ) {
12
- $( '#_billing_persontype' ).on( 'change', function () {
13
- var current = $( this ).val();
14
-
15
- $( '._billing_cpf_field, ._billing_rg_field, ._billing_company_field, ._billing_cnpj_field, ._billing_ie_field' ).hide();
16
-
17
- if ( '1' === current ) {
18
- $( '._billing_cpf_field, ._billing_rg_field' ).show();
19
- }
20
-
21
- if ( '2' === current ) {
22
- $( '._billing_company_field, ._billing_cnpj_field, ._billing_ie_field' ).show();
23
- }
24
- }).change();
25
- }
26
-
27
- $( '.load_customer_billing' ).on( 'click', function () {
28
- var userId = $( '#customer_user' ).val(),
29
- data;
30
-
31
- if ( window.confirm( wcbcf_shop_order_params.load_message ) ) {
32
- if ( ! userId ) {
33
- window.alert( woocommerce_admin_meta_boxes.no_customer_selected );
34
- return false;
35
- }
36
-
37
- data = {
38
- user_id: userId,
39
- type_to_load: 'billing',
40
- action: 'woocommerce_get_customer_details',
41
- security: woocommerce_admin_meta_boxes.get_customer_details_nonce
42
- };
43
-
44
- $( this ).closest( '.edit_address' ).block({
45
- message: null,
46
- overlayCSS: {
47
- background: '#fff url(' + woocommerce_admin_meta_boxes.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center',
48
- opacity: 0.6
49
- }
50
- });
51
-
52
- $.ajax({
53
- url: woocommerce_admin_meta_boxes.ajax_url,
54
- data: data,
55
- type: 'POST',
56
- success: function( response ) {
57
- if ( response ) {
58
- $( 'input#_billing_number' ).val( response.billing_number );
59
- $( 'input#_billing_neighborhood' ).val( response.billing_neighborhood );
60
- $( 'input#_billing_persontype' ).val( response.billing_persontype );
61
- $( 'input#_billing_cpf' ).val( response.billing_cpf );
62
- $( 'input#_billing_rg' ).val( response.billing_rg );
63
- $( 'input#_billing_cnpj' ).val( response.billing_cnpj );
64
- $( 'input#_billing_ie' ).val( response.billing_ie );
65
- $( 'input#_billing_birthdate' ).val( response.billing_birthdate );
66
- $( 'input#_billing_sex' ).val( response.billing_sex );
67
- $( 'input#_billing_cellphone' ).val( response.billing_cellphone );
68
- }
69
-
70
- $( '.edit_address' ).unblock();
71
- }
72
- });
73
- }
74
-
75
- return false;
76
- });
77
-
78
- $( '.load_customer_shipping' ).on( 'click', function () {
79
- var userId = $( '#customer_user' ).val(),
80
- data;
81
-
82
- if ( window.confirm( wcbcf_shop_order_params.load_message ) ) {
83
-
84
- if ( ! userId ) {
85
- window.alert( woocommerce_admin_meta_boxes.no_customer_selected );
86
- return false;
87
- }
88
-
89
- data = {
90
- user_id: userId,
91
- type_to_load: 'shipping',
92
- action: 'woocommerce_get_customer_details',
93
- security: woocommerce_admin_meta_boxes.get_customer_details_nonce
94
- };
95
-
96
- $( this ).closest( '.edit_address' ).block({
97
- message: null,
98
- overlayCSS: {
99
- background: '#fff url(' + woocommerce_admin_meta_boxes.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center',
100
- opacity: 0.6
101
- }
102
- });
103
-
104
- $.ajax({
105
- url: woocommerce_admin_meta_boxes.ajax_url,
106
- data: data,
107
- type: 'POST',
108
- success: function( response ) {
109
- if ( response ) {
110
- $( 'input#_shipping_number' ).val( response.shipping_number );
111
- $( 'input#_shipping_neighborhood' ).val( response.shipping_neighborhood );
112
- }
113
-
114
- $( '.edit_address' ).unblock();
115
- }
116
- });
117
- }
118
-
119
- return false;
120
- });
121
-
122
- $( 'button.billing-same-as-shipping' ).on( 'click', function () {
123
- if ( window.confirm( wcbcf_shop_order_params.copy_message ) ) {
124
- $( 'input#_shipping_number' ).val( $( 'input#_billing_number' ).val() );
125
- $( 'input#_shipping_neighborhood' ).val( $( 'input#_billing_neighborhood' ).val() );
126
- }
127
-
128
- return false;
129
- });
130
-
131
- });
132
-
133
- }( jQuery ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/assets/js/admin/shop-order.min.js DELETED
@@ -1 +0,0 @@
1
- !function(a){"use strict";a(function(){"1"===wcbcf_shop_order_params.person_type&&a("#_billing_persontype").on("change",function(){var b=a(this).val();a("._billing_cpf_field, ._billing_rg_field, ._billing_company_field, ._billing_cnpj_field, ._billing_ie_field").hide(),"1"===b&&a("._billing_cpf_field, ._billing_rg_field").show(),"2"===b&&a("._billing_company_field, ._billing_cnpj_field, ._billing_ie_field").show()}).change(),a(".load_customer_billing").on("click",function(){var b,c=a("#customer_user").val();if(window.confirm(wcbcf_shop_order_params.load_message)){if(!c)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;b={user_id:c,type_to_load:"billing",action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce},a(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:b,type:"POST",success:function(b){b&&(a("input#_billing_number").val(b.billing_number),a("input#_billing_neighborhood").val(b.billing_neighborhood),a("input#_billing_persontype").val(b.billing_persontype),a("input#_billing_cpf").val(b.billing_cpf),a("input#_billing_rg").val(b.billing_rg),a("input#_billing_cnpj").val(b.billing_cnpj),a("input#_billing_ie").val(b.billing_ie),a("input#_billing_birthdate").val(b.billing_birthdate),a("input#_billing_sex").val(b.billing_sex),a("input#_billing_cellphone").val(b.billing_cellphone)),a(".edit_address").unblock()}})}return!1}),a(".load_customer_shipping").on("click",function(){var b,c=a("#customer_user").val();if(window.confirm(wcbcf_shop_order_params.load_message)){if(!c)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;b={user_id:c,type_to_load:"shipping",action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce},a(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:b,type:"POST",success:function(b){b&&(a("input#_shipping_number").val(b.shipping_number),a("input#_shipping_neighborhood").val(b.shipping_neighborhood)),a(".edit_address").unblock()}})}return!1}),a("button.billing-same-as-shipping").on("click",function(){return window.confirm(wcbcf_shop_order_params.copy_message)&&(a("input#_shipping_number").val(a("input#_billing_number").val()),a("input#_shipping_neighborhood").val(a("input#_billing_neighborhood").val())),!1})})}(jQuery);
 
trunk/assets/js/frontend/frontend.js DELETED
@@ -1,236 +0,0 @@
1
- /* global wcbcf_public_params */
2
- /*jshint devel: true */
3
- jQuery( function( $ ) {
4
-
5
- /**
6
- * Frontend actions
7
- */
8
- var wc_ecfb_frontend = {
9
-
10
- /**
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();
20
- }
21
-
22
- if ( 'yes' === wcbcf_public_params.maskedinput ) {
23
- $( document.body ).on( 'change', '#billing_country', function() {
24
- if ( 'BR' === $( this ).val() ) {
25
- wc_ecfb_frontend.maskBilling();
26
- } else {
27
- wc_ecfb_frontend.unmaskBilling();
28
- }
29
- });
30
-
31
- $( document.body ).on( 'change', '#shipping_country', function() {
32
- if ( 'BR' === $( this ).val() ) {
33
- wc_ecfb_frontend.maskShipping();
34
- } else {
35
- wc_ecfb_frontend.unmaskShipping();
36
- }
37
- });
38
-
39
- this.maskGeneral();
40
- }
41
-
42
- if ( 'yes' === wcbcf_public_params.mailcheck ) {
43
- this.emailCheck();
44
- }
45
-
46
- if ( 'yes' === wcbcf_public_params.addresscomplete ) {
47
- // Auto complete billing address.
48
- this.addressAutoComplete( 'billing' );
49
- this.addressAutoCompleteOnChange( 'billing' );
50
-
51
- // Auto complete shipping address.
52
- this.addressAutoComplete( 'shipping' );
53
- this.addressAutoCompleteOnChange( 'shipping' );
54
- }
55
-
56
- // Check if select2 exists.
57
- if ( $().select2 ) {
58
- $( '.wc-ecfb-select' ).select2();
59
- }
60
- },
61
-
62
- /**
63
- * Country to state changing.
64
- * Fix the fields order.
65
- */
66
- country_to_state_changing: function() {
67
- // Billing.
68
- $( '#billing_state_field label' ).html( wcbcf_public_params.state + ' <abbr class="required" title="' + wcbcf_public_params.required + '">*</abbr>' );
69
- $( '#billing_postcode_field' ).insertAfter( '#billing_country_field' );
70
-
71
- // Shipping.
72
- if ( $( '#shipping_state_field' ).length ) {
73
- $( '#shipping_state_field label' ).html( wcbcf_public_params.state + ' <abbr class="required" title="' + wcbcf_public_params.required + '">*</abbr>' );
74
- $( '#shipping_postcode_field' ).insertAfter( '#shipping_country_field' );
75
- }
76
- },
77
-
78
- person_type_fields: function() {
79
- // Required fields.
80
- if ( 'no' === wcbcf_public_params.only_brazil ) {
81
- $( '.person-type-field label .required' ).remove();
82
- $( '.person-type-field' ).addClass( 'validate-required' );
83
- $( '.person-type-field label' ).append( ' <abbr class="required" title="' + wcbcf_public_params.required + '">*</abbr>' );
84
- } else {
85
- $( '#billing_country' ).on( 'change', function () {
86
- var current = $( this ).val();
87
-
88
- if ( 'BR' === current ) {
89
- $( '.person-type-field label .required' ).remove();
90
- $( '.person-type-field' ).addClass( 'validate-required' );
91
- $( '.person-type-field label' ).append( ' <abbr class="required" title="' + wcbcf_public_params.required + '">*</abbr>' );
92
- } else {
93
- $( '.person-type-field' ).removeClass( 'validate-required' );
94
- $( '.person-type-field label .required' ).remove();
95
- }
96
- }).change();
97
- }
98
-
99
- if ( '1' === wcbcf_public_params.person_type ) {
100
- $( '#billing_persontype' ).on( 'change', function () {
101
- var current = $( this ).val();
102
-
103
- $( '#billing_cpf_field' ).hide();
104
- $( '#billing_rg_field' ).hide();
105
- $( '#billing_company_field' ).hide();
106
- $( '#billing_cnpj_field' ).hide();
107
- $( '#billing_ie_field' ).hide();
108
-
109
- if ( '1' === current ) {
110
- $( '#billing_cpf_field' ).show();
111
- $( '#billing_rg_field' ).show();
112
- }
113
-
114
- if ( '2' === current ) {
115
- $( '#billing_company_field' ).show();
116
- $( '#billing_cnpj_field' ).show();
117
- $( '#billing_ie_field' ).show();
118
- }
119
- }).change();
120
- }
121
- },
122
-
123
- maskBilling: function() {
124
- wc_ecfb_frontend.maskPhone( '#billing_phone, #billing_cellphone' );
125
- $( '#billing_birthdate' ).mask( '00/00/0000' );
126
- $( '#billing_postcode' ).mask( '00000-000' );
127
- $( '#billing_phone, #billing_cellphone, #billing_birthdate, #billing_postcode' ).attr( 'type', 'tel' );
128
- },
129
-
130
- unmaskBilling: function() {
131
- $( '#billing_phone, #billing_cellphone, #billing_birthdate, #billing_postcode' ).unmask().attr( 'type', 'text' );
132
- },
133
-
134
- maskShipping: function() {
135
- $( '#shipping_postcode' ).mask( '00000-000' ).attr( 'type', 'tel' );
136
- },
137
-
138
- unmaskShipping: function() {
139
- $( '#shipping_postcode' ).unmask().attr( 'type', 'text' );
140
- },
141
-
142
- maskGeneral: function() {
143
- $( '#billing_cpf, #credit-card-cpf' ).mask( '000.000.000-00' );
144
- $( '#billing_cnpj' ).mask( '00.000.000/0000-00' );
145
- wc_ecfb_frontend.maskPhone( '#credit-card-phone' );
146
- },
147
-
148
- maskPhone: function(selector) {
149
- var $element = $(selector),
150
- MaskBehavior = function(val) {
151
- return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009';
152
- },
153
- maskOptions = {
154
- onKeyPress: function(val, e, field, options) {
155
- field.mask(MaskBehavior.apply({}, arguments), options);
156
- }
157
- };
158
-
159
- $element.mask(MaskBehavior, maskOptions);
160
- },
161
-
162
- emailCheck: function() {
163
- if ( $( '#wcbcf-mailsuggest' ).length < 1 ) {
164
- $( '#billing_email' ).after( '<div id="wcbcf-mailsuggest"></div>' );
165
- }
166
-
167
- $( '#billing_email' ).on( 'blur', function () {
168
- $( '#wcbcf-mailsuggest' ).html( '' );
169
- $( this ).mailcheck({
170
- suggested: function( element, suggestion ) {
171
- $( '#wcbcf-mailsuggest' ).html( 'Você quis dizer: ' + suggestion.full + '?' );
172
- }
173
- });
174
- });
175
-
176
- $( '#wcbcf-mailsuggest' ).css({
177
- color: '#c00',
178
- fontSize: 'small'
179
- });
180
- },
181
-
182
- addressAutoComplete: function( field ) {
183
- // Checks with *_postcode field exist.
184
- if ( $( '#' + field + '_postcode' ).length ) {
185
-
186
- // Valid CEP.
187
- var cep = $( '#' + field + '_postcode' ).val().replace( '.', '' ).replace( '-', '' ),
188
- country = $( '#' + field + '_country' ).val(),
189
- address_1 = $( '#' + field + '_address_1' ).val();
190
-
191
- // Check country is BR.
192
- if ( cep !== '' && 8 === cep.length && 'BR' === country && 0 === address_1.length ) {
193
-
194
- // Gets the address.
195
- $.ajax({
196
- type: 'GET',
197
- url: '//correiosapi.apphb.com/cep/' + cep,
198
- dataType: 'jsonp',
199
- crossDomain: true,
200
- contentType: 'application/json',
201
- success: function ( address ) {
202
-
203
- // Address.
204
- if ( '' !== address.tipoDeLogradouro ) {
205
- $( '#' + field + '_address_1' ).val( address.tipoDeLogradouro + ' ' + address.logradouro ).change();
206
- } else {
207
- $( '#' + field + '_address_1' ).val( address.logradouro ).change();
208
- }
209
-
210
- // Neighborhood.
211
- $( '#' + field + '_neighborhood' ).val( address.bairro ).change();
212
-
213
- // City.
214
- $( '#' + field + '_city' ).val( address.cidade ).change();
215
-
216
- // State.
217
- $( '#' + field + '_state option:selected' ).attr( 'selected', false ).change();
218
- $( '#' + field + '_state option[value="' + address.estado + '"]' ).attr( 'selected', 'selected' ).change();
219
-
220
- // Chosen support.
221
- $( '#' + field + '_state' ).trigger( 'liszt:updated' ).trigger( 'chosen:updated' );
222
- }
223
- });
224
- }
225
- }
226
- },
227
-
228
- addressAutoCompleteOnChange: function( field ) {
229
- $( document.body ).on( 'blur', '#' + field + '_postcode', function() {
230
- wc_ecfb_frontend.addressAutoComplete( field );
231
- });
232
- }
233
- };
234
-
235
- wc_ecfb_frontend.init();
236
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/assets/js/frontend/frontend.min.js DELETED
@@ -1 +0,0 @@
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")),a().select2&&a(".wc-ecfb-select").select2()},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 label .required").remove(),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 label .required").remove(),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 .required").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()});
 
trunk/assets/js/jquery.mask/jquery.mask.js DELETED
@@ -1,540 +0,0 @@
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));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/assets/js/jquery.mask/jquery.mask.min.js DELETED
@@ -1,18 +0,0 @@
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);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/assets/js/mailcheck/mailcheck.js DELETED
@@ -1,267 +0,0 @@
1
- /*
2
- * Mailcheck https://github.com/mailcheck/mailcheck
3
- * Author
4
- * Derrick Ko (@derrickko)
5
- *
6
- * Released under the MIT License.
7
- *
8
- * v 1.1.1
9
- */
10
-
11
- var Mailcheck = {
12
- domainThreshold: 2,
13
- secondLevelThreshold: 2,
14
- topLevelThreshold: 2,
15
-
16
- defaultDomains: ['msn.com', 'bellsouth.net',
17
- 'telus.net', 'comcast.net', 'optusnet.com.au',
18
- 'earthlink.net', 'qq.com', 'sky.com', 'icloud.com',
19
- 'mac.com', 'sympatico.ca', 'googlemail.com',
20
- 'att.net', 'xtra.co.nz', 'web.de',
21
- 'cox.net', 'gmail.com', 'ymail.com',
22
- 'aim.com', 'rogers.com', 'verizon.net',
23
- 'rocketmail.com', 'google.com', 'optonline.net',
24
- 'sbcglobal.net', 'aol.com', 'me.com', 'btinternet.com',
25
- 'charter.net', 'shaw.ca'],
26
-
27
- defaultSecondLevelDomains: ["yahoo", "hotmail", "mail", "live", "outlook", "gmx"],
28
-
29
- defaultTopLevelDomains: ["com", "com.au", "com.tw", "ca", "co.nz", "co.uk", "de",
30
- "fr", "it", "ru", "net", "org", "edu", "gov", "jp", "nl", "kr", "se", "eu",
31
- "ie", "co.il", "us", "at", "be", "dk", "hk", "es", "gr", "ch", "no", "cz",
32
- "in", "net", "net.au", "info", "biz", "mil", "co.jp", "sg", "hu"],
33
-
34
- run: function(opts) {
35
- opts.domains = opts.domains || Mailcheck.defaultDomains;
36
- opts.secondLevelDomains = opts.secondLevelDomains || Mailcheck.defaultSecondLevelDomains;
37
- opts.topLevelDomains = opts.topLevelDomains || Mailcheck.defaultTopLevelDomains;
38
- opts.distanceFunction = opts.distanceFunction || Mailcheck.sift3Distance;
39
-
40
- var defaultCallback = function(result){ return result };
41
- var suggestedCallback = opts.suggested || defaultCallback;
42
- var emptyCallback = opts.empty || defaultCallback;
43
-
44
- var result = Mailcheck.suggest(Mailcheck.encodeEmail(opts.email), opts.domains, opts.secondLevelDomains, opts.topLevelDomains, opts.distanceFunction);
45
-
46
- return result ? suggestedCallback(result) : emptyCallback()
47
- },
48
-
49
- suggest: function(email, domains, secondLevelDomains, topLevelDomains, distanceFunction) {
50
- email = email.toLowerCase();
51
-
52
- var emailParts = this.splitEmail(email);
53
-
54
- if (secondLevelDomains && topLevelDomains) {
55
- // If the email is a valid 2nd-level + top-level, do not suggest anything.
56
- if (secondLevelDomains.indexOf(emailParts.secondLevelDomain) !== -1 && topLevelDomains.indexOf(emailParts.topLevelDomain) !== -1) {
57
- return false;
58
- }
59
- }
60
-
61
- var closestDomain = this.findClosestDomain(emailParts.domain, domains, distanceFunction, this.domainThreshold);
62
-
63
- if (closestDomain) {
64
- if (closestDomain == emailParts.domain) {
65
- // The email address exactly matches one of the supplied domains; do not return a suggestion.
66
- return false;
67
- } else {
68
- // The email address closely matches one of the supplied domains; return a suggestion
69
- return { address: emailParts.address, domain: closestDomain, full: emailParts.address + "@" + closestDomain };
70
- }
71
- }
72
-
73
- // The email address does not closely match one of the supplied domains
74
- var closestSecondLevelDomain = this.findClosestDomain(emailParts.secondLevelDomain, secondLevelDomains, distanceFunction, this.secondLevelThreshold);
75
- var closestTopLevelDomain = this.findClosestDomain(emailParts.topLevelDomain, topLevelDomains, distanceFunction, this.topLevelThreshold);
76
-
77
- if (emailParts.domain) {
78
- var closestDomain = emailParts.domain;
79
- var rtrn = false;
80
-
81
- if(closestSecondLevelDomain && closestSecondLevelDomain != emailParts.secondLevelDomain) {
82
- // The email address may have a mispelled second-level domain; return a suggestion
83
- closestDomain = closestDomain.replace(emailParts.secondLevelDomain, closestSecondLevelDomain);
84
- rtrn = true;
85
- }
86
-
87
- if(closestTopLevelDomain && closestTopLevelDomain != emailParts.topLevelDomain) {
88
- // The email address may have a mispelled top-level domain; return a suggestion
89
- closestDomain = closestDomain.replace(emailParts.topLevelDomain, closestTopLevelDomain);
90
- rtrn = true;
91
- }
92
-
93
- if (rtrn == true) {
94
- return { address: emailParts.address, domain: closestDomain, full: emailParts.address + "@" + closestDomain };
95
- }
96
- }
97
-
98
- /* The email address exactly matches one of the supplied domains, does not closely
99
- * match any domain and does not appear to simply have a mispelled top-level domain,
100
- * or is an invalid email address; do not return a suggestion.
101
- */
102
- return false;
103
- },
104
-
105
- findClosestDomain: function(domain, domains, distanceFunction, threshold) {
106
- threshold = threshold || this.topLevelThreshold;
107
- var dist;
108
- var minDist = 99;
109
- var closestDomain = null;
110
-
111
- if (!domain || !domains) {
112
- return false;
113
- }
114
- if(!distanceFunction) {
115
- distanceFunction = this.sift3Distance;
116
- }
117
-
118
- for (var i = 0; i < domains.length; i++) {
119
- if (domain === domains[i]) {
120
- return domain;
121
- }
122
- dist = distanceFunction(domain, domains[i]);
123
- if (dist < minDist) {
124
- minDist = dist;
125
- closestDomain = domains[i];
126
- }
127
- }
128
-
129
- if (minDist <= threshold && closestDomain !== null) {
130
- return closestDomain;
131
- } else {
132
- return false;
133
- }
134
- },
135
-
136
- sift3Distance: function(s1, s2) {
137
- // sift3: http://siderite.blogspot.com/2007/04/super-fast-and-accurate-string-distance.html
138
- if (s1 == null || s1.length === 0) {
139
- if (s2 == null || s2.length === 0) {
140
- return 0;
141
- } else {
142
- return s2.length;
143
- }
144
- }
145
-
146
- if (s2 == null || s2.length === 0) {
147
- return s1.length;
148
- }
149
-
150
- var c = 0;
151
- var offset1 = 0;
152
- var offset2 = 0;
153
- var lcs = 0;
154
- var maxOffset = 5;
155
-
156
- while ((c + offset1 < s1.length) && (c + offset2 < s2.length)) {
157
- if (s1.charAt(c + offset1) == s2.charAt(c + offset2)) {
158
- lcs++;
159
- } else {
160
- offset1 = 0;
161
- offset2 = 0;
162
- for (var i = 0; i < maxOffset; i++) {
163
- if ((c + i < s1.length) && (s1.charAt(c + i) == s2.charAt(c))) {
164
- offset1 = i;
165
- break;
166
- }
167
- if ((c + i < s2.length) && (s1.charAt(c) == s2.charAt(c + i))) {
168
- offset2 = i;
169
- break;
170
- }
171
- }
172
- }
173
- c++;
174
- }
175
- return (s1.length + s2.length) /2 - lcs;
176
- },
177
-
178
- splitEmail: function(email) {
179
- var parts = email.trim().split('@');
180
-
181
- if (parts.length < 2) {
182
- return false;
183
- }
184
-
185
- for (var i = 0; i < parts.length; i++) {
186
- if (parts[i] === '') {
187
- return false;
188
- }
189
- }
190
-
191
- var domain = parts.pop();
192
- var domainParts = domain.split('.');
193
- var sld = '';
194
- var tld = '';
195
-
196
- if (domainParts.length == 0) {
197
- // The address does not have a top-level domain
198
- return false;
199
- } else if (domainParts.length == 1) {
200
- // The address has only a top-level domain (valid under RFC)
201
- tld = domainParts[0];
202
- } else {
203
- // The address has a domain and a top-level domain
204
- sld = domainParts[0];
205
- for (var i = 1; i < domainParts.length; i++) {
206
- tld += domainParts[i] + '.';
207
- }
208
- tld = tld.substring(0, tld.length - 1);
209
- }
210
-
211
- return {
212
- topLevelDomain: tld,
213
- secondLevelDomain: sld,
214
- domain: domain,
215
- address: parts.join('@')
216
- }
217
- },
218
-
219
- // Encode the email address to prevent XSS but leave in valid
220
- // characters, following this official spec:
221
- // http://en.wikipedia.org/wiki/Email_address#Syntax
222
- encodeEmail: function(email) {
223
- var result = encodeURI(email);
224
- result = result.replace('%20', ' ').replace('%25', '%').replace('%5E', '^')
225
- .replace('%60', '`').replace('%7B', '{').replace('%7C', '|')
226
- .replace('%7D', '}');
227
- return result;
228
- }
229
- };
230
-
231
- // Export the mailcheck object if we're in a CommonJS env (e.g. Node).
232
- // Modeled off of Underscore.js.
233
- if (typeof module !== 'undefined' && module.exports) {
234
- module.exports = Mailcheck;
235
- }
236
-
237
- // Support AMD style definitions
238
- // Based on jQuery (see http://stackoverflow.com/a/17954882/1322410)
239
- if (typeof define === "function" && define.amd) {
240
- define("mailcheck", [], function() {
241
- return Mailcheck;
242
- });
243
- }
244
-
245
- if (typeof window !== 'undefined' && window.jQuery) {
246
- (function($){
247
- $.fn.mailcheck = function(opts) {
248
- var self = this;
249
- if (opts.suggested) {
250
- var oldSuggested = opts.suggested;
251
- opts.suggested = function(result) {
252
- oldSuggested(self, result);
253
- };
254
- }
255
-
256
- if (opts.empty) {
257
- var oldEmpty = opts.empty;
258
- opts.empty = function() {
259
- oldEmpty.call(null, self);
260
- };
261
- }
262
-
263
- opts.email = this.val();
264
- Mailcheck.run(opts);
265
- }
266
- })(jQuery);
267
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/assets/js/mailcheck/mailcheck.min.js DELETED
@@ -1 +0,0 @@
1
- /*! mailcheck v1.1.1 @licence MIT */var Mailcheck={domainThreshold:2,secondLevelThreshold:2,topLevelThreshold:2,defaultDomains:["msn.com","bellsouth.net","telus.net","comcast.net","optusnet.com.au","earthlink.net","qq.com","sky.com","icloud.com","mac.com","sympatico.ca","googlemail.com","att.net","xtra.co.nz","web.de","cox.net","gmail.com","ymail.com","aim.com","rogers.com","verizon.net","rocketmail.com","google.com","optonline.net","sbcglobal.net","aol.com","me.com","btinternet.com","charter.net","shaw.ca"],defaultSecondLevelDomains:["yahoo","hotmail","mail","live","outlook","gmx"],defaultTopLevelDomains:["com","com.au","com.tw","ca","co.nz","co.uk","de","fr","it","ru","net","org","edu","gov","jp","nl","kr","se","eu","ie","co.il","us","at","be","dk","hk","es","gr","ch","no","cz","in","net","net.au","info","biz","mil","co.jp","sg","hu"],run:function(a){a.domains=a.domains||Mailcheck.defaultDomains,a.secondLevelDomains=a.secondLevelDomains||Mailcheck.defaultSecondLevelDomains,a.topLevelDomains=a.topLevelDomains||Mailcheck.defaultTopLevelDomains,a.distanceFunction=a.distanceFunction||Mailcheck.sift3Distance;var b=function(a){return a},c=a.suggested||b,d=a.empty||b,e=Mailcheck.suggest(Mailcheck.encodeEmail(a.email),a.domains,a.secondLevelDomains,a.topLevelDomains,a.distanceFunction);return e?c(e):d()},suggest:function(a,b,c,d,e){a=a.toLowerCase();var f=this.splitEmail(a);if(c&&d&&-1!==c.indexOf(f.secondLevelDomain)&&-1!==d.indexOf(f.topLevelDomain))return!1;var g=this.findClosestDomain(f.domain,b,e,this.domainThreshold);if(g)return g==f.domain?!1:{address:f.address,domain:g,full:f.address+"@"+g};var h=this.findClosestDomain(f.secondLevelDomain,c,e,this.secondLevelThreshold),i=this.findClosestDomain(f.topLevelDomain,d,e,this.topLevelThreshold);if(f.domain){var g=f.domain,j=!1;if(h&&h!=f.secondLevelDomain&&(g=g.replace(f.secondLevelDomain,h),j=!0),i&&i!=f.topLevelDomain&&(g=g.replace(f.topLevelDomain,i),j=!0),1==j)return{address:f.address,domain:g,full:f.address+"@"+g}}return!1},findClosestDomain:function(a,b,c,d){d=d||this.topLevelThreshold;var e,f=99,g=null;if(!a||!b)return!1;c||(c=this.sift3Distance);for(var h=0;h<b.length;h++){if(a===b[h])return a;e=c(a,b[h]),f>e&&(f=e,g=b[h])}return d>=f&&null!==g?g:!1},sift3Distance:function(a,b){if(null==a||0===a.length)return null==b||0===b.length?0:b.length;if(null==b||0===b.length)return a.length;for(var c=0,d=0,e=0,f=0,g=5;c+d<a.length&&c+e<b.length;){if(a.charAt(c+d)==b.charAt(c+e))f++;else{d=0,e=0;for(var h=0;g>h;h++){if(c+h<a.length&&a.charAt(c+h)==b.charAt(c)){d=h;break}if(c+h<b.length&&a.charAt(c)==b.charAt(c+h)){e=h;break}}}c++}return(a.length+b.length)/2-f},splitEmail:function(a){var b=a.trim().split("@");if(b.length<2)return!1;for(var c=0;c<b.length;c++)if(""===b[c])return!1;var d=b.pop(),e=d.split("."),f="",g="";if(0==e.length)return!1;if(1==e.length)g=e[0];else{f=e[0];for(var c=1;c<e.length;c++)g+=e[c]+".";g=g.substring(0,g.length-1)}return{topLevelDomain:g,secondLevelDomain:f,domain:d,address:b.join("@")}},encodeEmail:function(a){var b=encodeURI(a);return b=b.replace("%20"," ").replace("%25","%").replace("%5E","^").replace("%60","`").replace("%7B","{").replace("%7C","|").replace("%7D","}")}};"undefined"!=typeof module&&module.exports&&(module.exports=Mailcheck),"function"==typeof define&&define.amd&&define("mailcheck",[],function(){return Mailcheck}),"undefined"!=typeof window&&window.jQuery&&!function(a){a.fn.mailcheck=function(a){var b=this;if(a.suggested){var c=a.suggested;a.suggested=function(a){c(b,a)}}if(a.empty){var d=a.empty;a.empty=function(){d.call(null,b)}}a.email=this.val(),Mailcheck.run(a)}}(jQuery);
 
trunk/includes/admin/class-extra-checkout-fields-for-brazil-admin.php DELETED
@@ -1,101 +0,0 @@
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
-
17
- /**
18
- * Initialize the plugin admin.
19
- */
20
- public function __construct() {
21
- // Load admin style sheet and JavaScript.
22
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
23
-
24
- $this->maybe_install();
25
- }
26
-
27
- /**
28
- * Admin scripts
29
- */
30
- public function admin_scripts() {
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
-
38
- // Styles.
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(
46
- 'woocommerce-extra-checkout-fields-for-brazil-shop-order',
47
- 'wcbcf_shop_order_params',
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
-
62
- /**
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
-
72
- // Update to version 3.0.0.
73
- if ( version_compare( $version, '3.0.0', '<' ) ) {
74
- if ( isset( $options['person_type'] ) ) {
75
- $options['person_type'] = 1;
76
- } else {
77
- $options['person_type'] = 0;
78
- }
79
- }
80
-
81
- update_option( 'wcbcf_settings', $options );
82
- update_option( 'wcbcf_version', Extra_Checkout_Fields_For_Brazil::VERSION );
83
- }
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 );
96
- add_option( 'wcbcf_version', Extra_Checkout_Fields_For_Brazil::VERSION );
97
- }
98
- }
99
- }
100
-
101
- new Extra_Checkout_Fields_For_Brazil_Admin();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/admin/class-extra-checkout-fields-for-brazil-customer.php DELETED
@@ -1,169 +0,0 @@
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
-
17
- /**
18
- * Initialize the customer actions.
19
- */
20
- public function __construct() {
21
- add_filter( 'woocommerce_customer_meta_fields', array( $this, 'customer_meta_fields' ) );
22
- add_filter( 'woocommerce_user_column_billing_address', array( $this, 'user_column_billing_address' ), 1, 2 );
23
- add_filter( 'woocommerce_user_column_shipping_address', array( $this, 'user_column_shipping_address' ), 1, 2 );
24
- }
25
-
26
- /**
27
- * Custom user edit fields.
28
- *
29
- * @param array $fields Default fields.
30
- *
31
- * @return array Custom fields.
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
- }
73
- } else {
74
- $new_fields['billing']['fields']['billing_company'] = $fields['billing']['fields']['billing_company'];
75
- }
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'];
100
- $new_fields['billing']['fields']['billing_country'] = $fields['billing']['fields']['billing_country'];
101
- $new_fields['billing']['fields']['billing_state'] = $fields['billing']['fields']['billing_state'];
102
- $new_fields['billing']['fields']['billing_phone'] = $fields['billing']['fields']['billing_phone'];
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
-
111
- $new_fields['billing']['fields']['billing_email'] = $fields['billing']['fields']['billing_email'];
112
-
113
- // Shipping fields.
114
- $new_fields['shipping']['title'] = __( 'Customer Shipping Address', 'woocommerce-extra-checkout-fields-for-brazil' );
115
- $new_fields['shipping']['fields']['shipping_first_name'] = $fields['shipping']['fields']['shipping_first_name'];
116
- $new_fields['shipping']['fields']['shipping_last_name'] = $fields['shipping']['fields']['shipping_last_name'];
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'];
130
- $new_fields['shipping']['fields']['shipping_country'] = $fields['shipping']['fields']['shipping_country'];
131
- $new_fields['shipping']['fields']['shipping_state'] = $fields['shipping']['fields']['shipping_state'];
132
-
133
- $new_fields = apply_filters( 'wcbcf_customer_meta_fields', $new_fields );
134
-
135
- return $new_fields;
136
- }
137
-
138
- /**
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
- */
146
- public function user_column_billing_address( $address, $user_id ) {
147
- $address['number'] = get_user_meta( $user_id, 'billing_number', true );
148
- $address['neighborhood'] = get_user_meta( $user_id, 'billing_neighborhood', true );
149
-
150
- return $address;
151
- }
152
-
153
- /**
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
- */
161
- public function user_column_shipping_address( $address, $user_id ) {
162
- $address['number'] = get_user_meta( $user_id, 'shipping_number', true );
163
- $address['neighborhood'] = get_user_meta( $user_id, 'shipping_neighborhood', true );
164
-
165
- return $address;
166
- }
167
- }
168
-
169
- new Extra_Checkout_Fields_For_Brazil_Customer();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/admin/class-extra-checkout-fields-for-brazil-order.php DELETED
@@ -1,327 +0,0 @@
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();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/admin/class-extra-checkout-fields-for-brazil-settings.php DELETED
@@ -1,309 +0,0 @@
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
-
17
- /**
18
- * Initialize the settings.
19
- */
20
- public function __construct() {
21
- add_action( 'admin_menu', array( $this, 'settings_menu' ), 59 );
22
- add_action( 'admin_init', array( $this, 'plugin_settings' ) );
23
- }
24
-
25
- /**
26
- * Add the settings page.
27
- */
28
- public function settings_menu() {
29
- add_submenu_page(
30
- 'woocommerce',
31
- __( 'Checkout Fields', 'woocommerce-extra-checkout-fields-for-brazil' ),
32
- __( 'Checkout Fields', 'woocommerce-extra-checkout-fields-for-brazil' ),
33
- 'manage_options',
34
- 'woocommerce-extra-checkout-fields-for-brazil',
35
- array( $this, 'html_settings_page' )
36
- );
37
- }
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
- /**
47
- * Plugin settings form fields.
48
- */
49
- public function plugin_settings() {
50
- $option = 'wcbcf_settings';
51
-
52
- // Set Custom Fields section.
53
- add_settings_section(
54
- 'options_section',
55
- __( 'Checkout Custom Fields:', 'woocommerce-extra-checkout-fields-for-brazil' ),
56
- array( $this, 'section_options_callback' ),
57
- $option
58
- );
59
-
60
- // Person Type option.
61
- add_settings_field(
62
- 'person_type',
63
- __( 'Display Person Type:', 'woocommerce-extra-checkout-fields-for-brazil' ),
64
- array( $this, 'select_element_callback' ),
65
- $option,
66
- 'options_section',
67
- array(
68
- 'menu' => $option,
69
- 'id' => 'person_type',
70
- 'description' => __( 'Individuals enables CPF field and Legal Person enables CNPJ field.', 'woocommerce-extra-checkout-fields-for-brazil' ),
71
- 'options' => array(
72
- 0 => __( 'None', 'woocommerce-extra-checkout-fields-for-brazil' ),
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
-
80
- // Person Type is Required option.
81
- add_settings_field(
82
- 'only_brazil',
83
- __( 'Person Type is required only in Brazil?', 'woocommerce-extra-checkout-fields-for-brazil' ),
84
- array( $this, 'checkbox_element_callback' ),
85
- $option,
86
- 'options_section',
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
-
94
- // RG option.
95
- add_settings_field(
96
- 'rg',
97
- __( 'Display RG:', 'woocommerce-extra-checkout-fields-for-brazil' ),
98
- array( $this, 'checkbox_element_callback' ),
99
- $option,
100
- 'options_section',
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
-
108
- // State Registration option.
109
- add_settings_field(
110
- 'ie',
111
- __( 'Display State Registration:', 'woocommerce-extra-checkout-fields-for-brazil' ),
112
- array( $this, 'checkbox_element_callback' ),
113
- $option,
114
- 'options_section',
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
-
122
- // Birthdate and Sex option.
123
- add_settings_field(
124
- 'birthdate_sex',
125
- __( 'Display Birthdate and Sex:', 'woocommerce-extra-checkout-fields-for-brazil' ),
126
- array( $this, 'checkbox_element_callback' ),
127
- $option,
128
- 'options_section',
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
-
136
- // Cell Phone option.
137
- add_settings_field(
138
- 'cell_phone',
139
- __( 'Display Cell Phone:', 'woocommerce-extra-checkout-fields-for-brazil' ),
140
- array( $this, 'checkbox_element_callback' ),
141
- $option,
142
- 'options_section',
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
-
150
- // Set Custom Fields section.
151
- add_settings_section(
152
- 'jquery_section',
153
- __( 'jQuery Options:', 'woocommerce-extra-checkout-fields-for-brazil' ),
154
- array( $this, 'section_options_callback' ),
155
- $option
156
- );
157
-
158
- // Mail Check option.
159
- add_settings_field(
160
- 'mailcheck',
161
- __( 'Enable Mail Check:', 'woocommerce-extra-checkout-fields-for-brazil' ),
162
- array( $this, 'checkbox_element_callback' ),
163
- $option,
164
- 'jquery_section',
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
-
172
- // Input Mask option.
173
- add_settings_field(
174
- 'maskedinput',
175
- __( 'Enable Input Mask:', 'woocommerce-extra-checkout-fields-for-brazil' ),
176
- array( $this, 'checkbox_element_callback' ),
177
- $option,
178
- 'jquery_section',
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
-
186
- // Address Autocomplete option.
187
- if ( ! apply_filters( 'woocommerce_correios_enable_autofill_addresses', false ) ) {
188
- add_settings_field(
189
- 'addresscomplete',
190
- __( 'Enable Address Autocomplete:', 'woocommerce-extra-checkout-fields-for-brazil' ),
191
- array( $this, 'checkbox_element_callback' ),
192
- $option,
193
- 'jquery_section',
194
- array(
195
- 'menu' => $option,
196
- 'id' => 'addresscomplete',
197
- 'label' => __( 'If checked automatically complete the address fields based on the zip code.', 'woocommerce-extra-checkout-fields-for-brazil' ),
198
- )
199
- );
200
- }
201
-
202
- // Set Custom Fields section.
203
- add_settings_section(
204
- 'validation_section',
205
- __( 'Validation:', 'woocommerce-extra-checkout-fields-for-brazil' ),
206
- array( $this, 'section_options_callback' ),
207
- $option
208
- );
209
-
210
- // Validate CPF option.
211
- add_settings_field(
212
- 'validate_cpf',
213
- __( 'Validate CPF:', 'woocommerce-extra-checkout-fields-for-brazil' ),
214
- array( $this, 'checkbox_element_callback' ),
215
- $option,
216
- 'validation_section',
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
-
224
- // Validate CPF option.
225
- add_settings_field(
226
- 'validate_cnpj',
227
- __( 'Validate CNPJ:', 'woocommerce-extra-checkout-fields-for-brazil' ),
228
- array( $this, 'checkbox_element_callback' ),
229
- $option,
230
- 'validation_section',
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
-
238
- // Register settings.
239
- register_setting( $option, $option, array( $this, 'validate_options' ) );
240
- }
241
-
242
- /**
243
- * Section null fallback.
244
- */
245
- public function section_options_callback() {
246
-
247
- }
248
-
249
- /**
250
- * Checkbox element fallback.
251
- *
252
- * @param array $args Callback arguments.
253
- */
254
- public function checkbox_element_callback( $args ) {
255
- $menu = $args['menu'];
256
- $id = $args['id'];
257
- $options = get_option( $menu );
258
-
259
- if ( isset( $options[ $id ] ) ) {
260
- $current = $options[ $id ];
261
- } else {
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'];
275
- $id = $args['id'];
276
- $options = get_option( $menu );
277
-
278
- if ( isset( $options[ $id ] ) ) {
279
- $current = $options[ $id ];
280
- } else {
281
- $current = isset( $args['default'] ) ? $args['default'] : 0;
282
- }
283
-
284
- include dirname( __FILE__ ) . '/views/html-select-field.php';
285
- }
286
-
287
- /**
288
- * Valid options.
289
- *
290
- * @param array $input options to valid.
291
- *
292
- * @return array validated options.
293
- */
294
- public function validate_options( $input ) {
295
- $output = array();
296
-
297
- // Loop through each of the incoming options.
298
- foreach ( $input as $key => $value ) {
299
- // Check to see if the current option has a value. If so, process it.
300
- if ( isset( $input[ $key ] ) ) {
301
- $output[ $key ] = sanitize_text_field( $input[ $key ] );
302
- }
303
- }
304
-
305
- return $output;
306
- }
307
- }
308
-
309
- new Extra_Checkout_Fields_For_Brazil_Settings();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/admin/views/html-admin-help-message.php DELETED
@@ -1,17 +0,0 @@
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 &#9733;&#9733;&#9733;&#9733;&#9733; on WordPress.org. Thank you in advance!', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'WooCommerce Extra Checkout Fields for Brazil', '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;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/admin/views/html-checkbox-field.php DELETED
@@ -1,18 +0,0 @@
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;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/admin/views/html-legacy-order-billing-data.php DELETED
@@ -1,55 +0,0 @@
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/admin/views/html-order-billing-data.php DELETED
@@ -1,55 +0,0 @@
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/admin/views/html-select-field.php DELETED
@@ -1,19 +0,0 @@
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;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/admin/views/html-settings-page.php DELETED
@@ -1,28 +0,0 @@
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/class-extra-checkout-fields-for-brazil-api.php DELETED
@@ -1,437 +0,0 @@
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();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/class-extra-checkout-fields-for-brazil-formatting.php DELETED
@@ -1,73 +0,0 @@
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
-
31
- $digit = substr( $cpf, 0, 9 );
32
-
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
-
61
- for ( $t = 11; $t < 13; ) {
62
- for ( $d = 0, $p = 2, $c = $t; $c >= 0; $c--, ( $p < 9 ) ? $p++ : $p = 2 ) {
63
- $d += $cnpj[ $c ] * $p;
64
- }
65
-
66
- if ( intval( $cnpj[ ++$t ] ) !== ( $d = ( ( 10 * $d ) % 11 ) % 10 ) ) {
67
- return false;
68
- }
69
- }
70
-
71
- return true;
72
- }
73
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/class-extra-checkout-fields-for-brazil-front-end.php DELETED
@@ -1,567 +0,0 @@
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
-
17
- /**
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' ) );
24
- add_action( 'woocommerce_after_checkout_form', array( $this, 'load_scripts' ) );
25
-
26
- // New checkout fields.
27
- add_filter( 'woocommerce_billing_fields', array( $this, 'checkout_billing_fields' ), 10 );
28
- add_filter( 'woocommerce_shipping_fields', array( $this, 'checkout_shipping_fields' ), 10 );
29
- add_filter( 'woocommerce_get_country_locale', array( $this, 'address_fields_priority' ), 10 );
30
-
31
- // Valid checkout fields.
32
- add_action( 'woocommerce_checkout_process', array( $this, 'valid_checkout_fields' ), 10 );
33
-
34
- // Custom address format.
35
- add_filter( 'woocommerce_localisation_address_formats', array( $this, 'localisation_address_formats' ) );
36
- add_filter( 'woocommerce_formatted_address_replacements', array( $this, 'formatted_address_replacements' ), 1, 2 );
37
- add_filter( 'woocommerce_order_formatted_billing_address', array( $this, 'order_formatted_billing_address' ), 1, 2 );
38
- add_filter( 'woocommerce_order_formatted_shipping_address', array( $this, 'order_formatted_shipping_address' ), 1, 2 );
39
- add_filter( 'woocommerce_my_account_my_address_formatted_address', array( $this, 'my_account_my_address_formatted_address' ), 1, 3 );
40
-
41
- // Orders.
42
- add_filter( 'woocommerce_get_order_address', array( $this, 'order_address' ), 10, 3 );
43
- }
44
-
45
- /**
46
- * Register scripts.
47
- */
48
- public function enqueue_scripts() {
49
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
50
-
51
- wp_register_style( 'woocommerce-extra-checkout-fields-for-brazil-front', plugins_url( 'assets/css/frontend/frontend.css', plugin_dir_path( __FILE__ ) ), array(), Extra_Checkout_Fields_For_Brazil::VERSION, 'all' );
52
-
53
- 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 );
54
-
55
- wp_register_script( 'mailcheck', plugins_url( 'assets/js/mailcheck/mailcheck' . $suffix . '.js', plugin_dir_path( __FILE__ ) ), array( 'jquery' ), '1.1.1', true );
56
-
57
- 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 );
58
-
59
- $settings = get_option( 'wcbcf_settings' );
60
- $autofill = isset( $settings['addresscomplete'] ) ? 'yes' : 'no';
61
- wp_localize_script(
62
- 'woocommerce-extra-checkout-fields-for-brazil-front',
63
- 'wcbcf_public_params',
64
- array(
65
- 'state' => esc_js( __( 'State', 'woocommerce-extra-checkout-fields-for-brazil' ) ),
66
- 'required' => esc_js( __( 'required', 'woocommerce-extra-checkout-fields-for-brazil' ) ),
67
- 'mailcheck' => isset( $settings['mailcheck'] ) ? 'yes' : 'no',
68
- 'maskedinput' => isset( $settings['maskedinput'] ) ? 'yes' : 'no',
69
- 'addresscomplete' => apply_filters( 'woocommerce_correios_enable_autofill_addresses', false ) ? false : $autofill,
70
- 'person_type' => absint( $settings['person_type'] ),
71
- 'only_brazil' => isset( $settings['only_brazil'] ) ? 'yes' : 'no',
72
- 'sort_state_country' => version_compare( WC_VERSION, '3.0', '>=' ),
73
- )
74
- );
75
- }
76
-
77
- /**
78
- * Load scripts.
79
- */
80
- public function load_scripts() {
81
- wp_enqueue_script( 'woocommerce-extra-checkout-fields-for-brazil-front' );
82
- wp_enqueue_style( 'woocommerce-extra-checkout-fields-for-brazil-front' );
83
- }
84
-
85
- /**
86
- * New checkout billing fields.
87
- *
88
- * @param array $fields Default fields.
89
- *
90
- * @return array
91
- */
92
- public function checkout_billing_fields( $fields ) {
93
- $new_fields = array();
94
-
95
- // Get plugin settings.
96
- $settings = get_option( 'wcbcf_settings' );
97
- $person_type = intval( $settings['person_type'] );
98
-
99
- if ( isset( $fields['billing_first_name'] ) ) {
100
- $new_fields['billing_first_name'] = $fields['billing_first_name'];
101
- $new_fields['billing_first_name']['class'] = array( 'form-row-first' );
102
- }
103
-
104
- if ( isset( $fields['billing_last_name'] ) ) {
105
- $new_fields['billing_last_name'] = $fields['billing_last_name'];
106
- $new_fields['billing_last_name']['class'] = array( 'form-row-last' );
107
- }
108
-
109
- if ( 0 !== $person_type ) {
110
- if ( 1 === $person_type ) {
111
- $new_fields['billing_persontype'] = array(
112
- 'type' => 'select',
113
- 'label' => __( 'Person type', 'woocommerce-extra-checkout-fields-for-brazil' ),
114
- 'class' => array( 'form-row-wide', 'person-type-field' ),
115
- 'input_class' => array( 'wc-ecfb-select' ),
116
- 'required' => false,
117
- 'options' => array(
118
- '1' => __( 'Individuals', 'woocommerce-extra-checkout-fields-for-brazil' ),
119
- '2' => __( 'Legal Person', 'woocommerce-extra-checkout-fields-for-brazil' ),
120
- ),
121
- 'priority' => 22,
122
- );
123
- }
124
-
125
- if ( 1 === $person_type || 2 === $person_type ) {
126
- if ( isset( $settings['rg'] ) ) {
127
- $new_fields['billing_cpf'] = array(
128
- 'label' => __( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ),
129
- 'class' => array( 'form-row-first', 'person-type-field' ),
130
- 'required' => false,
131
- 'type' => 'tel',
132
- 'priority' => 23,
133
- );
134
-
135
- $new_fields['billing_rg'] = array(
136
- 'label' => __( 'RG', 'woocommerce-extra-checkout-fields-for-brazil' ),
137
- 'class' => array( 'form-row-last', 'person-type-field' ),
138
- 'required' => false,
139
- 'priority' => 24,
140
- );
141
- } else {
142
- $new_fields['billing_cpf'] = array(
143
- 'label' => __( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ),
144
- 'class' => array( 'form-row-wide', 'person-type-field' ),
145
- 'required' => false,
146
- 'type' => 'tel',
147
- 'priority' => 23,
148
- );
149
- }
150
- }
151
-
152
- if ( 1 === $person_type || 3 === $person_type ) {
153
- if ( isset( $fields['billing_company'] ) ) {
154
- $new_fields['billing_company'] = $fields['billing_company'];
155
- $new_fields['billing_company']['class'] = array( 'form-row-wide' );
156
- $new_fields['billing_company']['clear'] = true;
157
- $new_fields['billing_company']['priority'] = 25;
158
- }
159
-
160
- if ( isset( $settings['ie'] ) ) {
161
- $new_fields['billing_cnpj'] = array(
162
- 'label' => __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ),
163
- 'class' => array( 'form-row-first', 'person-type-field' ),
164
- 'required' => false,
165
- 'type' => 'tel',
166
- 'priority' => 26,
167
- );
168
-
169
- $new_fields['billing_ie'] = array(
170
- 'label' => __( 'State Registration', 'woocommerce-extra-checkout-fields-for-brazil' ),
171
- 'class' => array( 'form-row-last', 'person-type-field' ),
172
- 'required' => false,
173
- 'priority' => 27,
174
- );
175
- } else {
176
- $new_fields['billing_cnpj'] = array(
177
- 'label' => __( 'CNPJ', 'woocommerce-extra-checkout-fields-for-brazil' ),
178
- 'class' => array( 'form-row-wide', 'person-type-field' ),
179
- 'required' => false,
180
- 'type' => 'tel',
181
- 'priority' => 26,
182
- );
183
- }
184
- }
185
- } else {
186
- if ( isset( $fields['billing_company'] ) ) {
187
- $new_fields['billing_company'] = $fields['billing_company'];
188
- $new_fields['billing_company']['class'] = array( 'form-row-wide' );
189
- $new_fields['billing_company']['clear'] = true;
190
- }
191
- } // End if().
192
-
193
- if ( isset( $settings['birthdate_sex'] ) ) {
194
- $new_fields['billing_birthdate'] = array(
195
- 'label' => __( 'Birthdate', 'woocommerce-extra-checkout-fields-for-brazil' ),
196
- 'class' => array( 'form-row-first' ),
197
- 'clear' => false,
198
- 'required' => true,
199
- 'priority' => 31,
200
- );
201
-
202
- $new_fields['billing_sex'] = array(
203
- 'type' => 'select',
204
- 'label' => __( 'Sex', 'woocommerce-extra-checkout-fields-for-brazil' ),
205
- 'class' => array( 'form-row-last' ),
206
- 'input_class' => array( 'wc-ecfb-select' ),
207
- 'clear' => true,
208
- 'required' => true,
209
- 'options' => array(
210
- '' => __( 'Select', 'woocommerce-extra-checkout-fields-for-brazil' ),
211
- __( 'Female', 'woocommerce-extra-checkout-fields-for-brazil' ) => __( 'Female', 'woocommerce-extra-checkout-fields-for-brazil' ),
212
- __( 'Male', 'woocommerce-extra-checkout-fields-for-brazil' ) => __( 'Male', 'woocommerce-extra-checkout-fields-for-brazil' ),
213
- ),
214
- 'priority' => 32,
215
- );
216
- }
217
-
218
- if ( isset( $fields['billing_country'] ) ) {
219
- $new_fields['billing_country'] = $fields['billing_country'];
220
- $new_fields['billing_country']['class'] = array( 'form-row-wide', 'address-field', 'update_totals_on_change' );
221
- }
222
-
223
- if ( isset( $fields['billing_postcode'] ) ) {
224
- $new_fields['billing_postcode'] = $fields['billing_postcode'];
225
- $new_fields['billing_postcode']['class'] = array( 'form-row-first', 'address-field' );
226
- $new_fields['billing_postcode']['priority'] = 45;
227
- }
228
-
229
- if ( isset( $fields['billing_address_1'] ) ) {
230
- $new_fields['billing_address_1'] = $fields['billing_address_1'];
231
- $new_fields['billing_address_1']['class'] = array( 'form-row-last', 'address-field' );
232
- }
233
-
234
- $new_fields['billing_number'] = array(
235
- 'label' => __( 'Number', 'woocommerce-extra-checkout-fields-for-brazil' ),
236
- 'class' => array( 'form-row-first', 'address-field' ),
237
- 'clear' => true,
238
- 'required' => true,
239
- 'priority' => 55,
240
- );
241
-
242
- if ( isset( $fields['billing_address_2'] ) ) {
243
- $new_fields['billing_address_2'] = $fields['billing_address_2'];
244
- $new_fields['billing_address_2']['label'] = __( 'Address line 2', 'woocommerce-extra-checkout-fields-for-brazil' );
245
- $new_fields['billing_address_2']['class'] = array( 'form-row-last', 'address-field' );
246
- }
247
-
248
- $new_fields['billing_neighborhood'] = array(
249
- 'label' => __( 'Neighborhood', 'woocommerce-extra-checkout-fields-for-brazil' ),
250
- 'class' => array( 'form-row-first', 'address-field' ),
251
- 'clear' => true,
252
- 'priority' => 65,
253
- );
254
-
255
- if ( isset( $fields['billing_city'] ) ) {
256
- $new_fields['billing_city'] = $fields['billing_city'];
257
- $new_fields['billing_city']['class'] = array( 'form-row-last', 'address-field' );
258
- }
259
-
260
- if ( isset( $fields['billing_state'] ) ) {
261
- $new_fields['billing_state'] = $fields['billing_state'];
262
- $new_fields['billing_state']['class'] = array( 'form-row-wide', 'address-field' );
263
- $new_fields['billing_state']['clear'] = true;
264
- }
265
-
266
- if ( isset( $settings['cell_phone'] ) ) {
267
- if ( isset( $fields['billing_phone'] ) ) {
268
- $new_fields['billing_phone'] = $fields['billing_phone'];
269
- $new_fields['billing_phone']['class'] = array( 'form-row-first' );
270
- $new_fields['billing_phone']['clear'] = false;
271
- }
272
-
273
- $new_fields['billing_cellphone'] = array(
274
- 'label' => __( 'Cell Phone', 'woocommerce-extra-checkout-fields-for-brazil' ),
275
- 'class' => array( 'form-row-last' ),
276
- 'clear' => true,
277
- 'priority' => 105,
278
- );
279
-
280
- if ( isset( $fields['billing_email'] ) ) {
281
- $new_fields['billing_email'] = $fields['billing_email'];
282
- $new_fields['billing_email']['class'] = array( 'form-row-wide' );
283
- $new_fields['billing_email']['clear'] = true;
284
- $new_fields['billing_email']['type'] = 'email';
285
- }
286
- } else {
287
- if ( isset( $fields['billing_phone'] ) ) {
288
- $new_fields['billing_phone'] = $fields['billing_phone'];
289
- $new_fields['billing_phone']['class'] = array( 'form-row-wide' );
290
- $new_fields['billing_phone']['clear'] = true;
291
- }
292
-
293
- if ( isset( $fields['billing_email'] ) ) {
294
- $new_fields['billing_email'] = $fields['billing_email'];
295
- $new_fields['billing_email']['class'] = array( 'form-row-wide' );
296
- $new_fields['billing_email']['clear'] = true;
297
- $new_fields['billing_email']['type'] = 'email';
298
- }
299
- }
300
-
301
- return apply_filters( 'wcbcf_billing_fields', $new_fields );
302
- }
303
-
304
- /**
305
- * New checkout shipping fields
306
- *
307
- * @param array $fields Default fields.
308
- *
309
- * @return array
310
- */
311
- public function checkout_shipping_fields( $fields ) {
312
- $new_fields = array();
313
-
314
- if ( isset( $fields['shipping_first_name'] ) ) {
315
- $new_fields['shipping_first_name'] = $fields['shipping_first_name'];
316
- $new_fields['shipping_first_name']['class'] = array( 'form-row-first' );
317
- }
318
-
319
- if ( isset( $fields['shipping_last_name'] ) ) {
320
- $new_fields['shipping_last_name'] = $fields['shipping_last_name'];
321
- $new_fields['shipping_last_name']['class'] = array( 'form-row-last' );
322
- }
323
-
324
- if ( isset( $fields['shipping_company'] ) ) {
325
- $new_fields['shipping_company'] = $fields['shipping_company'];
326
- $new_fields['shipping_company']['class'] = array( 'form-row-wide' );
327
- $new_fields['shipping_company']['clear'] = true;
328
- }
329
-
330
- if ( isset( $fields['shipping_country'] ) ) {
331
- $new_fields['shipping_country'] = $fields['shipping_country'];
332
- $new_fields['shipping_country']['class'] = array( 'form-row-wide', 'address-field', 'update_totals_on_change' );
333
- }
334
-
335
- if ( isset( $fields['shipping_postcode'] ) ) {
336
- $new_fields['shipping_postcode'] = $fields['shipping_postcode'];
337
- $new_fields['shipping_postcode']['class'] = array( 'form-row-first', 'address-field' );
338
- $new_fields['shipping_postcode']['priority'] = 45;
339
- }
340
-
341
- if ( isset( $fields['shipping_address_1'] ) ) {
342
- $new_fields['shipping_address_1'] = $fields['shipping_address_1'];
343
- $new_fields['shipping_address_1']['class'] = array( 'form-row-last', 'address-field' );
344
- }
345
-
346
- $new_fields['shipping_number'] = array(
347
- 'label' => __( 'Number', 'woocommerce-extra-checkout-fields-for-brazil' ),
348
- 'class' => array( 'form-row-first', 'address-field' ),
349
- 'clear' => true,
350
- 'required' => true,
351
- 'priority' => 55,
352
- );
353
-
354
- if ( isset( $fields['shipping_address_2'] ) ) {
355
- $new_fields['shipping_address_2'] = $fields['shipping_address_2'];
356
- $new_fields['shipping_address_2']['label'] = __( 'Address line 2', 'woocommerce-extra-checkout-fields-for-brazil' );
357
- $new_fields['shipping_address_2']['class'] = array( 'form-row-last', 'address-field' );
358
- }
359
-
360
- $new_fields['shipping_neighborhood'] = array(
361
- 'label' => __( 'Neighborhood', 'woocommerce-extra-checkout-fields-for-brazil' ),
362
- 'class' => array( 'form-row-first', 'address-field' ),
363
- 'clear' => true,
364
- );
365
-
366
- if ( isset( $fields['shipping_city'] ) ) {
367
- $new_fields['shipping_city'] = $fields['shipping_city'];
368
- $new_fields['shipping_city']['class'] = array( 'form-row-last', 'address-field' );
369
- }
370
-
371
- if ( isset( $fields['shipping_state'] ) ) {
372
- $new_fields['shipping_state'] = $fields['shipping_state'];
373
- $new_fields['shipping_state']['class'] = array( 'form-row-wide', 'address-field' );
374
- $new_fields['shipping_state']['clear'] = true;
375
- }
376
-
377
- return apply_filters( 'wcbcf_shipping_fields', $new_fields );
378
- }
379
-
380
- /**
381
- * Update address fields priority.
382
- *
383
- * @param array $locales Default WooCommerce locales.
384
- * @return array
385
- */
386
- public function address_fields_priority( $locales ) {
387
- $locales['BR'] = array(
388
- 'postcode' => array(
389
- 'priority' => 45,
390
- ),
391
- );
392
-
393
- return $locales;
394
- }
395
-
396
- /**
397
- * Valid checkout fields.
398
- *
399
- * @return string Displays the error message.
400
- */
401
- public function valid_checkout_fields() {
402
- if ( apply_filters( 'wcbcf_disable_checkout_validation', false ) ) {
403
- return;
404
- }
405
-
406
- // Get plugin settings.
407
- $settings = get_option( 'wcbcf_settings' );
408
- $person_type = intval( $settings['person_type'] );
409
- $only_brazil = isset( $settings['only_brazil'] ) ? true : false;
410
- $billing_persontype = isset( $_POST['billing_persontype'] ) ? intval( wp_unslash( $_POST['billing_persontype'] ) ) : 0;
411
-
412
- if ( $only_brazil && 'BR' !== wp_unslash( $_POST['billing_country'] ) || 0 === $person_type ) {
413
- return;
414
- }
415
-
416
- if ( 0 === $billing_persontype && 1 === $person_type ) {
417
- 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' );
418
- } else {
419
-
420
- // Check CPF.
421
- if ( ( 1 === $person_type && 1 === $billing_persontype ) || 2 === $person_type ) {
422
- if ( empty( $_POST['billing_cpf'] ) ) {
423
- 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' );
424
- }
425
-
426
- if ( isset( $settings['validate_cpf'] ) && ! empty( $_POST['billing_cpf'] ) && ! Extra_Checkout_Fields_For_Brazil_Formatting::is_cpf( $_POST['billing_cpf'] ) ) {
427
- wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'CPF', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is not valid', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
428
- }
429
-
430
- if ( isset( $settings['rg'] ) && empty( $_POST['billing_rg'] ) ) {
431
- wc_add_notice( sprintf( '<strong>%s</strong> %s.', __( 'RG', 'woocommerce-extra-checkout-fields-for-brazil' ), __( 'is a required field', 'woocommerce-extra-checkout-fields-for-brazil' ) ), 'error' );
432
- }
433
- }
434
-
435
- // Check Company and CPNJ.
436
- if ( ( 1 === $person_type && 2 === $billing_persontype ) || 3 === $person_type ) {
437
- if ( empty( $_POST['billing_company'] ) ) {
438
- 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' );
439
- }
440
-
441
- if ( empty( $_POST['billing_cnpj'] ) ) {
442
- 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' );
443
- }
444
-
445
- if ( isset( $settings['validate_cnpj'] ) && ! empty( $_POST['billing_cnpj'] ) && ! Extra_Checkout_Fields_For_Brazil_Formatting::is_cnpj( wp_unslash( $_POST['billing_cnpj'] ) ) ) {
446
- 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' );
447
- }
448
-
449
- if ( isset( $settings['ie'] ) && empty( $_POST['billing_ie'] ) ) {
450
- 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' );
451
- }
452
- }
453
- } // End if().
454
- }
455
-
456
- /**
457
- * Custom country address formats.
458
- *
459
- * @param array $formats Defaul formats.
460
- *
461
- * @return array New BR format.
462
- */
463
- public function localisation_address_formats( $formats ) {
464
- $formats['BR'] = "{name}\n{address_1}, {number}\n{address_2}\n{neighborhood}\n{city}\n{state}\n{postcode}\n{country}";
465
-
466
- return $formats;
467
- }
468
-
469
- /**
470
- * Custom country address format.
471
- *
472
- * @param array $replacements Default replacements.
473
- * @param array $args Arguments to replace.
474
- *
475
- * @return array New replacements.
476
- */
477
- public function formatted_address_replacements( $replacements, $args ) {
478
- $replacements['{number}'] = $args['number'];
479
- $replacements['{neighborhood}'] = $args['neighborhood'];
480
-
481
- return $replacements;
482
- }
483
-
484
- /**
485
- * Custom order formatted billing address.
486
- *
487
- * @param array $address Default address.
488
- * @param object $order Order data.
489
- *
490
- * @return array New address format.
491
- */
492
- public function order_formatted_billing_address( $address, $order ) {
493
- // WooCommerce 3.0 or later.
494
- if ( method_exists( $order, 'get_meta' ) ) {
495
- $address['number'] = $order->get_meta( '_billing_number' );
496
- $address['neighborhood'] = $order->get_meta( '_billing_neighborhood' );
497
- } else {
498
- $address['number'] = $order->billing_number;
499
- $address['neighborhood'] = $order->billing_neighborhood;
500
- }
501
-
502
- return $address;
503
- }
504
-
505
- /**
506
- * Custom order formatted shipping address.
507
- *
508
- * @param array $address Default address.
509
- * @param object $order Order data.
510
- *
511
- * @return array New address format.
512
- */
513
- public function order_formatted_shipping_address( $address, $order ) {
514
- // WooCommerce 3.0 or later.
515
- if ( method_exists( $order, 'get_meta' ) ) {
516
- $address['number'] = $order->get_meta( '_shipping_number' );
517
- $address['neighborhood'] = $order->get_meta( '_shipping_neighborhood' );
518
- } else {
519
- $address['number'] = $order->shipping_number;
520
- $address['neighborhood'] = $order->shipping_neighborhood;
521
- }
522
-
523
- return $address;
524
- }
525
-
526
- /**
527
- * Custom my address formatted address.
528
- *
529
- * @param array $address Default address.
530
- * @param int $customer_id Customer ID.
531
- * @param string $name Field name (billing or shipping).
532
- *
533
- * @return array New address format.
534
- */
535
- public function my_account_my_address_formatted_address( $address, $customer_id, $name ) {
536
- $address['number'] = get_user_meta( $customer_id, $name . '_number', true );
537
- $address['neighborhood'] = get_user_meta( $customer_id, $name . '_neighborhood', true );
538
-
539
- return $address;
540
- }
541
-
542
- /**
543
- * Order address.
544
- *
545
- * @param array $address Address data.
546
- * @param string $type Address type.
547
- * @param WC_Order $order Order object.
548
- * @return array
549
- */
550
- public function order_address( $address, $type, $order ) {
551
- $number = $type . '_number';
552
- $neighborhood = $type . '_neighborhood';
553
-
554
- // WooCommerce 3.0 or later.
555
- if ( method_exists( $order, 'get_meta' ) ) {
556
- $address['number'] = $order->get_meta( '_' . $number );
557
- $address['neighborhood'] = $order->get_meta( '_' . $neighborhood );
558
- } else {
559
- $address['number'] = $order->$number;
560
- $address['neighborhood'] = $order->$neighborhood;
561
- }
562
-
563
- return $address;
564
- }
565
- }
566
-
567
- new Extra_Checkout_Fields_For_Brazil_Front_End();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/includes/class-extra-checkout-fields-for-brazil-integrations.php DELETED
@@ -1,129 +0,0 @@
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();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/languages/woocommerce-extra-checkout-fields-for-brazil.pot DELETED
@@ -1,415 +0,0 @@
1
- # Copyright (C) 2018 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.6.1\n"
6
- "Report-Msgid-Bugs-To: "
7
- "https://wordpress.org/support/plugin/woocommerce-extra-checkout-fields-for-"
8
- "brazil\n"
9
- "POT-Creation-Date: 2018-05-24 15:50:55+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: 2018-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.2\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:128
35
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:143
36
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:423
37
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:427
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:136
46
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:431
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:177
56
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:442
57
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:446
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:170
66
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:450
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:195
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:204
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:235
91
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:347
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:249
100
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:361
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:274
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:113
118
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:417
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:210
124
- msgid "Select"
125
- msgstr ""
126
-
127
- #: includes/admin/class-extra-checkout-fields-for-brazil-order.php:58
128
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:118
129
- msgid "Individuals"
130
- msgstr ""
131
-
132
- #: includes/admin/class-extra-checkout-fields-for-brazil-order.php:59
133
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:119
134
- msgid "Legal Person"
135
- msgstr ""
136
-
137
- #: includes/admin/class-extra-checkout-fields-for-brazil-order.php:79
138
- #: includes/admin/views/html-legacy-order-billing-data.php:29
139
- #: includes/admin/views/html-order-billing-data.php:29
140
- msgid "Company Name"
141
- msgstr ""
142
-
143
- #: includes/admin/class-extra-checkout-fields-for-brazil-order.php:95
144
- #: includes/admin/views/html-legacy-order-billing-data.php:37
145
- #: includes/admin/views/html-order-billing-data.php:37
146
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:438
147
- msgid "Company"
148
- msgstr ""
149
-
150
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:31
151
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:32
152
- msgid "Checkout Fields"
153
- msgstr ""
154
-
155
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:55
156
- msgid "Checkout Custom Fields:"
157
- msgstr ""
158
-
159
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:63
160
- msgid "Display Person Type:"
161
- msgstr ""
162
-
163
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:70
164
- msgid "Individuals enables CPF field and Legal Person enables CNPJ field."
165
- msgstr ""
166
-
167
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:72
168
- msgid "None"
169
- msgstr ""
170
-
171
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:73
172
- msgid "Individuals and Legal Person"
173
- msgstr ""
174
-
175
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:74
176
- msgid "Individuals only"
177
- msgstr ""
178
-
179
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:75
180
- msgid "Legal Person only"
181
- msgstr ""
182
-
183
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:83
184
- msgid "Person Type is required only in Brazil?"
185
- msgstr ""
186
-
187
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:90
188
- msgid ""
189
- "If checked the Individuals and Legal Person options will be mandatory only "
190
- "in Brazil."
191
- msgstr ""
192
-
193
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:97
194
- msgid "Display RG:"
195
- msgstr ""
196
-
197
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:104
198
- msgid "If checked show the RG field in billing options."
199
- msgstr ""
200
-
201
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:111
202
- msgid "Display State Registration:"
203
- msgstr ""
204
-
205
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:118
206
- msgid "If checked show the State Registration field in billing options."
207
- msgstr ""
208
-
209
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:125
210
- msgid "Display Birthdate and Sex:"
211
- msgstr ""
212
-
213
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:132
214
- msgid "If checked show the Birthdate and Sex field in billing options."
215
- msgstr ""
216
-
217
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:139
218
- msgid "Display Cell Phone:"
219
- msgstr ""
220
-
221
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:146
222
- msgid "If checked show the Cell Phone field in billing options."
223
- msgstr ""
224
-
225
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:153
226
- msgid "jQuery Options:"
227
- msgstr ""
228
-
229
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:161
230
- msgid "Enable Mail Check:"
231
- msgstr ""
232
-
233
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:168
234
- msgid "If checked informs typos in email to users."
235
- msgstr ""
236
-
237
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:175
238
- msgid "Enable Input Mask:"
239
- msgstr ""
240
-
241
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:182
242
- msgid ""
243
- "If checked create masks fill for in fields of CPF, CNPJ, Birthdate, Phone "
244
- "and Cell Phone."
245
- msgstr ""
246
-
247
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:190
248
- msgid "Enable Address Autocomplete:"
249
- msgstr ""
250
-
251
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:197
252
- msgid "If checked automatically complete the address fields based on the zip code."
253
- msgstr ""
254
-
255
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:205
256
- msgid "Validation:"
257
- msgstr ""
258
-
259
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:213
260
- msgid "Validate CPF:"
261
- msgstr ""
262
-
263
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:220
264
- msgid "Checks if the CPF is valid."
265
- msgstr ""
266
-
267
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:227
268
- msgid "Validate CNPJ:"
269
- msgstr ""
270
-
271
- #: includes/admin/class-extra-checkout-fields-for-brazil-settings.php:234
272
- msgid "Checks if the CNPJ is valid."
273
- msgstr ""
274
-
275
- #: includes/admin/views/html-admin-help-message.php:14
276
- msgid ""
277
- "Help us keep the %s plugin free making a donation or rate "
278
- "&#9733;&#9733;&#9733;&#9733;&#9733; on WordPress.org. Thank you in advance!"
279
- msgstr ""
280
-
281
- #. Plugin Name of the plugin/theme
282
- msgid "WooCommerce Extra Checkout Fields for Brazil"
283
- msgstr ""
284
-
285
- #: includes/admin/views/html-admin-help-message.php:15
286
- msgid "Make a donation"
287
- msgstr ""
288
-
289
- #: includes/admin/views/html-admin-help-message.php:15
290
- msgid "Make a review"
291
- msgstr ""
292
-
293
- #: includes/admin/views/html-legacy-order-billing-data.php:17
294
- #: includes/admin/views/html-order-billing-data.php:17
295
- msgid "Customer data"
296
- msgstr ""
297
-
298
- #: includes/admin/views/html-legacy-order-billing-data.php:45
299
- #: includes/admin/views/html-order-billing-data.php:45
300
- msgid "Phone"
301
- msgstr ""
302
-
303
- #: includes/admin/views/html-legacy-order-billing-data.php:51
304
- #: includes/admin/views/html-order-billing-data.php:51
305
- msgid "Email"
306
- msgstr ""
307
-
308
- #: includes/class-extra-checkout-fields-for-brazil-api.php:373
309
- #: includes/class-extra-checkout-fields-for-brazil-api.php:423
310
- msgid "Number."
311
- msgstr ""
312
-
313
- #: includes/class-extra-checkout-fields-for-brazil-api.php:378
314
- #: includes/class-extra-checkout-fields-for-brazil-api.php:428
315
- msgid "Neighborhood."
316
- msgstr ""
317
-
318
- #: includes/class-extra-checkout-fields-for-brazil-api.php:383
319
- msgid "Person type."
320
- msgstr ""
321
-
322
- #: includes/class-extra-checkout-fields-for-brazil-api.php:388
323
- msgid "CPF."
324
- msgstr ""
325
-
326
- #: includes/class-extra-checkout-fields-for-brazil-api.php:393
327
- msgid "RG."
328
- msgstr ""
329
-
330
- #: includes/class-extra-checkout-fields-for-brazil-api.php:398
331
- msgid "CNPJ."
332
- msgstr ""
333
-
334
- #: includes/class-extra-checkout-fields-for-brazil-api.php:403
335
- msgid "IE."
336
- msgstr ""
337
-
338
- #: includes/class-extra-checkout-fields-for-brazil-api.php:408
339
- msgid "Birthdate."
340
- msgstr ""
341
-
342
- #: includes/class-extra-checkout-fields-for-brazil-api.php:413
343
- msgid "Gender."
344
- msgstr ""
345
-
346
- #: includes/class-extra-checkout-fields-for-brazil-api.php:418
347
- msgid "Cell Phone."
348
- msgstr ""
349
-
350
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:65
351
- msgid "State"
352
- msgstr ""
353
-
354
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:66
355
- msgid "required"
356
- msgstr ""
357
-
358
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:211
359
- msgid "Female"
360
- msgstr ""
361
-
362
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:212
363
- msgid "Male"
364
- msgstr ""
365
-
366
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:244
367
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:356
368
- msgid "Address line 2"
369
- msgstr ""
370
-
371
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:417
372
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:423
373
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:431
374
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:438
375
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:442
376
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:450
377
- msgid "is a required field"
378
- msgstr ""
379
-
380
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:427
381
- #: includes/class-extra-checkout-fields-for-brazil-front-end.php:446
382
- msgid "is not valid"
383
- msgstr ""
384
-
385
- #: woocommerce-extra-checkout-fields-for-brazil.php:137
386
- msgid "Settings"
387
- msgstr ""
388
-
389
- #: woocommerce-extra-checkout-fields-for-brazil.php:148
390
- msgid "WooCommerce Extra Checkout Fields for Brazil depends on %s to work!"
391
- msgstr ""
392
-
393
- #: woocommerce-extra-checkout-fields-for-brazil.php:148
394
- msgid "WooCommerce"
395
- msgstr ""
396
-
397
- #. Plugin URI of the plugin/theme
398
- msgid ""
399
- "https://github.com/claudiosanches/woocommerce-extra-checkout-fields-for-"
400
- "brazil"
401
- msgstr ""
402
-
403
- #. Description of the plugin/theme
404
- msgid ""
405
- "Adds new checkout fields, field masks and other things necessary to "
406
- "properly work with WooCommerce on Brazil."
407
- msgstr ""
408
-
409
- #. Author of the plugin/theme
410
- msgid "Claudio Sanches"
411
- msgstr ""
412
-
413
- #. Author URI of the plugin/theme
414
- msgid "https://claudiosanches.com"
415
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/readme.txt DELETED
@@ -1,93 +0,0 @@
1
- === WooCommerce Extra Checkout Fields for Brazil ===
2
- Contributors: claudiosanches
3
- Donate link: http://claudiosmweb.com/doacoes/
4
- Tags: woocommerce, checkout, brazil, cpf, cpnj
5
- Requires at least: 3.5
6
- Tested up to: 4.9
7
- Stable tag: 3.6.1
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Adds Brazilian checkout fields in WooCommerce
12
-
13
- == Description ==
14
-
15
- Adiciona novos campos para Pessoa Física ou Jurídica, Data de Nascimento, Sexo, Número, Bairro e Celular. Além de máscaras em campos, aviso de e-mail incorreto e auto preenchimento dos campos de endereço pelo CEP.
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 3.0.x do WooCommerce.
22
-
23
- Funciona com os plugins:
24
-
25
- * [WooCommerce Bcash](http://wordpress.org/extend/plugins/woocommerce-bcash/) (adiciona as informações de **número**, **CPF**, **Razão Social** e **CNPJ**)
26
- * [WooCommerce Moip](http://wordpress.org/extend/plugins/woocommerce-moip/) (adiciona as informações de **bairro** e **número** e melhora o Checkout Transparente)
27
- * [WooCommerce PagSeguro](http://wordpress.org/extend/plugins/woocommerce-pagseguro/) (adiciona as informações de **bairro**, **CPF** e **número**)
28
-
29
- = Dúvidas? =
30
-
31
- Você pode esclarecer suas dúvidas usando:
32
-
33
- * Utilizando o nosso [fórum no Github](https://github.com/claudiosmweb/woocommerce-extra-checkout-fields-for-brazil/issues).
34
- * Criando um tópico no [fórum de ajuda do WordPress](https://wordpress.org/support/plugin/woocommerce-extra-checkout-fields-for-brazil).
35
-
36
- = Créditos =
37
-
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? =
51
-
52
- * Este plugin esta licenciado como GPL.
53
-
54
- = O que eu preciso para utilizar este plugin? =
55
-
56
- * Ter instalado o plugin WooCommerce.
57
-
58
- == Screenshots ==
59
-
60
- 1. Página de checkout usando o tema Storefront
61
- 2. Página de edição de endereço de entrega usando o tema Storefront
62
- 3. Página de dados do pedido
63
- 4. Configurações do plugin
64
- 5. Sugestão de e-mail
65
-
66
- == Changelog ==
67
-
68
- = 3.6.1 - 2018/05/24 =
69
-
70
- - Correção de mensagens dizendo que alguns campos eram opcionais, mesmo quando marcados como obrigatórios.
71
-
72
- = 3.6.0 - 2017/05/12 =
73
-
74
- - Modificada a posição de todos os campos do formulário para funcionar melhor com temas que ainda não são totalmente compatíveis com o WooCommerce 3.0.
75
-
76
- = 3.5.1 - 2017/04/26 =
77
-
78
- - Corrigido o posicionamento do campo de CEP.
79
- - Corrigida a validação de CPNJ.
80
-
81
- = 3.5.0 - 2017/03/04 =
82
-
83
- - Adicionado suporte ao WooCommerce 3.0.
84
- - 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)).
85
- - 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)).
86
- - 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)).
87
- - 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)).
88
-
89
- == Upgrade Notice ==
90
-
91
- = 3.6.1 =
92
-
93
- - Correção de mensagens dizendo que alguns campos eram opcionais, mesmo quando marcados como obrigatórios.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/uninstall.php DELETED
@@ -1,14 +0,0 @@
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();
11
- }
12
-
13
- delete_option( 'wcbcf_settings' );
14
- delete_option( 'wcbcf_version' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/woocommerce-extra-checkout-fields-for-brazil.php DELETED
@@ -1,157 +0,0 @@
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.6.1
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' ) ) {
31
- exit; // Exit if accessed directly.
32
- }
33
-
34
- if ( ! class_exists( 'Extra_Checkout_Fields_For_Brazil' ) ) :
35
-
36
- /**
37
- * Plugin main class.
38
- */
39
- class Extra_Checkout_Fields_For_Brazil {
40
-
41
- /**
42
- * Plugin version.
43
- *
44
- * @var string
45
- */
46
- const VERSION = '3.6.1';
47
-
48
- /**
49
- * Instance of this class.
50
- *
51
- * @var object
52
- */
53
- protected static $instance = null;
54
-
55
- /**
56
- * Initialize the plugin.
57
- *
58
- */
59
- private function __construct() {
60
- // Load plugin text domain.
61
- add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
62
-
63
- if ( class_exists( 'WooCommerce' ) ) {
64
- if ( is_admin() ) {
65
- $this->admin_includes();
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
- }
73
- }
74
-
75
- /**
76
- * Return an instance of this class.
77
- *
78
- * @return object A single instance of this class.
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
-
86
- return self::$instance;
87
- }
88
-
89
- /**
90
- * Get assets url.
91
- *
92
- * @return string
93
- */
94
- public static function get_assets_url() {
95
- return plugins_url( 'assets/', __FILE__ );
96
- }
97
-
98
- /**
99
- * Load the plugin text domain for translation.
100
- */
101
- public function load_plugin_textdomain() {
102
- $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-extra-checkout-fields-for-brazil' );
103
-
104
- load_textdomain( 'woocommerce-extra-checkout-fields-for-brazil', trailingslashit( WP_LANG_DIR ) . 'woocommerce-extra-checkout-fields-for-brazil/woocommerce-extra-checkout-fields-for-brazil-' . $locale . '.mo' );
105
- load_plugin_textdomain( 'woocommerce-extra-checkout-fields-for-brazil', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
106
- }
107
-
108
- /**
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
- /**
143
- * WooCommerce fallback notice.
144
- *
145
- * @return string Fallack notice.
146
- */
147
- public function woocommerce_fallback_notice() {
148
- echo '<div class="error"><p>' . sprintf( __( 'WooCommerce Extra Checkout Fields for Brazil depends on %s to work!', 'woocommerce-extra-checkout-fields-for-brazil' ), '<a href="http://wordpress.org/extend/plugins/woocommerce/">' . __( 'WooCommerce', 'woocommerce-extra-checkout-fields-for-brazil' ) . '</a>' ) . '</p></div>';
149
- }
150
- }
151
-
152
- /**
153
- * Initialize the plugin.
154
- */
155
- add_action( 'plugins_loaded', array( 'Extra_Checkout_Fields_For_Brazil', 'get_instance' ) );
156
-
157
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
woocommerce-extra-checkout-fields-for-brazil.php CHANGED
@@ -1,27 +1,27 @@
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.6.1
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
@@ -43,7 +43,7 @@ class Extra_Checkout_Fields_For_Brazil {
43
  *
44
  * @var string
45
  */
46
- const VERSION = '3.6.1';
47
 
48
  /**
49
  * Instance of this class.
@@ -145,7 +145,7 @@ class Extra_Checkout_Fields_For_Brazil {
145
  * @return string Fallack notice.
146
  */
147
  public function woocommerce_fallback_notice() {
148
- echo '<div class="error"><p>' . sprintf( __( 'WooCommerce Extra Checkout Fields for Brazil depends on %s to work!', 'woocommerce-extra-checkout-fields-for-brazil' ), '<a href="http://wordpress.org/extend/plugins/woocommerce/">' . __( 'WooCommerce', 'woocommerce-extra-checkout-fields-for-brazil' ) . '</a>' ) . '</p></div>';
149
  }
150
  }
151
 
1
  <?php
2
  /**
3
+ * Plugin Name: Brazilian Market on WooCommerce
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.7.0
9
  * License: GPLv2 or later
10
  * Text Domain: woocommerce-extra-checkout-fields-for-brazil
11
  * Domain Path: /languages
12
  *
13
+ * Brazilian Market on WooCommerce 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
+ * Brazilian Market on WooCommerce 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 Brazilian Market on WooCommerce. If not, see
25
  * <https://www.gnu.org/licenses/gpl-2.0.txt>.
26
  *
27
  * @package Extra_Checkout_Fields_For_Brazil
43
  *
44
  * @var string
45
  */
46
+ const VERSION = '3.7.0';
47
 
48
  /**
49
  * Instance of this class.
145
  * @return string Fallack notice.
146
  */
147
  public function woocommerce_fallback_notice() {
148
+ echo '<div class="error"><p>' . sprintf( __( 'Brazilian Market on WooCommerce depends on %s to work!', 'woocommerce-extra-checkout-fields-for-brazil' ), '<a href="http://wordpress.org/extend/plugins/woocommerce/">' . __( 'WooCommerce', 'woocommerce-extra-checkout-fields-for-brazil' ) . '</a>' ) . '</p></div>';
149
  }
150
  }
151