• Boa noite a todos
    Estou usando Dokan com Woocomerce PDF invoices e packing slips, porém, n?o estou conseguindo inserir o campo CPF na fatura.
    E seria necessário para o lojista emitir a nota fiscal.
    Alguém sabe como resolver ?
    Valeu galera

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 24 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hello @thiagopereira,

    This is certainly possible, thanks to the template action hooks.

    Please try using this code snippet:

    add_action('wpo_wcpdf_after_billing_address', function($template_type, $order){
      if($template_type = 'invoice'){
        $invoice = wcpdf_get_document( 'invoice', $order );
        if($cpf = $invoice->get_custom_field('customer_cpf')){
          echo '<br>CPF: '.$cpf;
        }
      }
    }, 10, 2);

    You should to replace customer_cpf with the field name you’re using to collect the CPF number.

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    You can also do so, even easier, using the address customization settings from our Professional extension

    Let me know if it works!

    Thread Starter thiagopereira

    (@thiagopereira)

    Thank you so much !!! It worked out !!!
    I just had another question. If it is a company that makes the purchase, with that the cnpj would have to appear for the buyer to issue the invoice.
    Following the same reasoning, I inserted it to appear before the billing information:
    add_action (‘wpo_wcpdf_before_billing_address’, function ($ template_type, $ order) {
    if ($ template_type = ‘invoice’) {
    $ invoice = wcpdf_get_document (‘invoice’, $ order);
    if ($ cnpj = $ invoice-> get_custom_field (‘billing_cnpj’)) {
    echo ‘<br> CNPJ:’. $ cnpj;
    }
    }
    }, 10, 2);

    but it didn’t work, what can i do to insert a cnpj or cpf? or display the cpf and cnpj?
    Thanks

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hello @thiagopereira,

    Try using this code snippet:

    add_action ('wpo_wcpdf_before_billing_address', function ($template_type, $order) {
      if ($template_type == 'invoice') {
        $invoice = wcpdf_get_document ('invoice', $order);
        if ($cnpj = $invoice-> get_custom_field ('billing_cnpj')) {
          echo '<br>CNPJ: ' . $cnpj;
        }
      }
    }, 10, 2);

    Let me know if it works! ??

    Thread Starter thiagopereira

    (@thiagopereira)

    Perfect !!!
    Thank you so much !!!
    Just one more piece of information. In the invoice that the company bought, the cnpj and cpf appeared. To appear only the cnpj and when it is not cpnj, appear cpf. Can you do that?
    Thank you very much

    Plugin Contributor Darren Peyou

    (@dpeyou)

    Oi @thiagopereira,

    Eu acho que você tá procurando algo assim:

    add_action ('wpo_wcpdf_before_billing_address', function ($template_type, $order) {
      if ($template_type == 'invoice') {
        $invoice = wcpdf_get_document ('invoice', $order);
        // if cnpj exists, show it
        if ( !empty($invoice-> get_custom_field ('billing_cnpj') ) {
          echo '<br>CNPJ: ' . $invoice-> get_custom_field ('billing_cnpj');
    
        // otherwise, show the cpf
        } else {
          echo '<br>CPF: '. $invoice-> get_custom_field ('billing_cpf');
        }
      }
    }, 10, 2);
    Thread Starter thiagopereira

    (@thiagopereira)

    Obrigado Darren Peyou (@dpeyou) !!!

    Thread Starter thiagopereira

    (@thiagopereira)

    bom dia, tudo bem ?
    Mais uma duvida sobre a fatura.
    Na fatura aparece como o metodo de pagamento a empresa do cart?o de crédito.
    Teria como fazer para aparecer se a compra foi em uma vez, em tres vezes, se foi feita por boleto bancário ?
    Obrigado novamente

    good morning, how are you ?
    One more question about the invoice.
    The credit card company is shown as the method of payment on the invoice.
    Would it be possible to appear if the purchase was made once, in three times, if it was made by bank slip?
    Thank you again
    Plugin Contributor Darren Peyou

    (@dpeyou)

    Oi @thiagopereira,

    …se a compra foi em uma vez, em três vezes, se foi feita por boleto bancário ?
    Desculpe, eu n?o tenho muita certeza do que você quer dizer com isso, especialmente falando de “um em três vezes”. Pode explicar o processo que precisa desta modifica??o?

    Thread Starter thiagopereira

    (@thiagopereira)

    Bom dia Darren, tudo bem ?
    Na fatura que chega para o cliente, somente aparece o método de pagamento, e aparece a empresa que fez o pagamento, mas n?o aparece como o cliente fez o pagamento, se foi com cart?o de crédito, se foi com cart?o de crédito em duas vezes, se foi boleto bancário. Queria saber se existe a op??o de aparecer isso na fatura, qual a forma que o comprador fez a compra, qual a forma de pagamento.
    Obrigado

    Plugin Contributor kluver

    (@kluver)

    Hi @thiagopereira,

    That depends on if that information is saved in the order. You can check if you see this anywhere in the order meta by installing the WooCommerce Store Toolkit. If this data is present in the order you can add it to your invoice by following this guide: Displaying a custom field

    williandimas

    (@williandimas)

    ola, pessoal qual o local que eu adiciono esse codigo para o plugn pegar o CPF?
    eu sou meio leigo nessa parte e nao to conseguindo configurar isso

    Plugin Contributor kluver

    (@kluver)

    @williandimas Custom code like the code snippets above should be be added to the functions.php of your child theme or via plugin like Code Snippets. If you haven’t worked with functions.php or code snippets before please read this: How to use filters

    Please, I would like add function in packing-slip too. How can i do it?

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @filiperjbr,

    You just need to remove the document type check. Here’s an improved version of my code snippet above:

    /**
     * Display CPF after the billing address
     */
    add_action('wpo_wcpdf_after_billing_address', function( $template_type, $order ){	
    	if( $cpf = $order->get_meta('customer_cpf') ){
    		echo 'CPF: '.$cpf;
    	}
    }, 10, 2);

    but if my client has CNPJ ? and Thank you so much ….

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘CPF na Fatura’ is closed to new replies.