• Resolved bartskol

    (@bartskol)


    Hi!
    I had read a lot of post about it but i lack php knowledge.
    Could you, awesome support please help me with adding “Numer NIP:” Text to my invoice?
    I did manage to get custom field printed on invoice, but it just display the value, and not the text before it that I would like (“Numer NIP:” which you could translate to “company tax number”).

    I had put this code into invoice.php in custom template:
    <?php echo implode(', ', (array) $this->order->get_meta('_billing_numer_nip_') ); ?>

    This is what I added to function.php:
    Function.php code
    And this is how it looks like on the invoice (it is this number “7441666507” on the left):
    Invoice

    Love your plugin and will rate it 10 out of 5

    • This topic was modified 5 years, 6 months ago by bartskol.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor kluver

    (@kluver)

    Hi @bartskol,

    The NIP number you are seeing on your invoice right now is not coming from your code snippet. The code snippet you’ve sent would print the NIP number in the order data (column on the right). But you are checking if the template type is ‘nummer-nip’ which is it isn’t. The available template types are ‘invoice’ and ‘packing-slip’ (for the free version). So the snippet won’t print anything in the order data column.

    To print the NIP number in the order data column try this:

    add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_nip_number', 10, 2 );
    function wpo_wcpdf_nip_number ( $template_type, $order ) {
    	if ( $template_type == 'invoice' && !empty( $order->get_meta('_billing_numer_nip_') ) ) {
    		?>
    		<tr class="nip-number">
    			<th><?php _e( 'Numer NIP:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
    			<td><?php echo $order->get_meta('_billing_numer_nip_'); ?></td>
    		</tr>
    		<?php 
    	}
    }

    This code snippet should go in the functions.php of your child theme.

    The NIP number right now is added to the billing address. So if you want to remove it there please read the following guide: Changing the address format

    Thread Starter bartskol

    (@bartskol)

    Hi!
    Thanks for the answer.
    How could I place it under customer Phone number?

    Plugin Contributor kluver

    (@kluver)

    Hi @bartskol,

    The customer’s phone number is also part of the billing address so you will have to customize the address format: Changing the address format

    Thread Starter bartskol

    (@bartskol)

    So how could i change it with woocommerce wide?

    • This reply was modified 5 years, 6 months ago by bartskol.
    Plugin Contributor Ewout

    (@pomegranate)

    This is explained on that same documentation page michael linked to: Changing the address format – WooCommerce wide

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom filed added’ is closed to new replies.