Sign in to follow this  

Adicionando CPF e RG no PDF do WooCommerce Print Invoice & Delivery Note


Description

Uma dica ótima para facilitar seu dia a dia.

Hoje uma cliente me pediu para adicionar o campo CPF e RG no PDF do pedido do Woocommerce. A ideia é ajudar ela a emitir as notas fiscais. Para fazer isso é simples, basta copiar e colar esse código no FUNCTIONS.PHP do seu tema. Lembre-se que precisa ter o WooCommerce Print Invoice & Delivery Note instalado.

function example_custom_order_fields( $fields, $order ) {
    $new_fields = array();

    if( get_post_meta( $order->get_id(), '_billing_cpf', true ) ) {
        $new_fields['_billing_cpf'] = array( 
            'label' => 'CPF',
            'value' => get_post_meta( $order->get_id(), '_billing_cpf', true )
        );
    }
	    if( get_post_meta( $order->get_id(), '_billing_rg', true ) ) {
        $new_fields['_billing_rg'] = array( 
            'label' => 'RG',
            'value' => get_post_meta( $order->get_id(), '_billing_rg', true )
        );
    }
    return array_merge( $fields, $new_fields );
	
}
add_filter( 'wcdn_order_info_fields', 'example_custom_order_fields', 10, 2 );

Segue resultado final.

image.png

  • Curtir (+1) 1


Recommended Comments

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Add a Comment

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.