This page's content:

Starting from 01/01/2020, the Brazilian Tax Authorities will require all imported packages to document the Brazilian customer identification number: CPF, for natural persons, or CNPJ, for legal persons. 

To be in compliance with this new regulation,  you must include a field for the CPF (format: 000.000.000-00) or CNPJ (format: 00.000.000/0000-00) number in your checkout’s shipping information section and print it on the package’s label.

Below there is a quick guide on how to add a field on your checkout.

Go to Appearance, Theme Editor and search for functions.php on the files at the right of your screen and add the code below and save it:

add_filter( 'woocommerce_billing_fields', 'add_brazilian_recipient_document' );
function add_brazilian_recipient_document( $fields ) {
    $fields['billing_recipient_document']   = array(
        'label'        => 'Recipient CPF/CNPJ Document',
        'required'     => true,
        'class'        => array( 'form-row-wide', 'brazilian_recipient_document' ),
        'priority'     => 120,
        'placeholder'  => 'Recipient CPF or CPNJ',
    );
    return $fields;
}
add_action( 'woocommerce_admin_order_data_after_shipping_address', 'add_brazilian_recipient_document_to_order', 10, 1 );
function add_brazilian_recipient_document_to_order($order){
    global $post_id;
    $order = new WC_Order( $post_id );
    echo '<p><strong>'.__('Recipient CPF').':</strong> ' . get_post_meta($order->get_id(), '_billing_recipient_document', true ) . '</p>';
}

Go to Appearance, Theme Editor again and now search for header.php on the files at the right and paste the code below:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
  (function($){
    $(function(){
      var $billing_country = $('#billing_country');
      var $billing_recipient_document = $('input[name=billing_recipient_document]').parents('.form-row')
      $billing_country.on('change',function() {
        if ($billing_country.val() === 'BR'){
          $billing_recipient_document.show().find('input').val('');
        } else {
          $billing_recipient_document.hide().find('input').val('0');
        }
      })
      $billing_country.change()
    });
  })(jQuery);
</script>

If you have any questions please send an email to integration@ebanx.com