Plugin Contributor
dwpriv
(@dwpriv)
You could use an if statement to show the field if it is not empty
Thank you for your reply.
Yeas an If statement is possible. Just don’t know how to get that right.
The custom field is _billing_vat_number and generated by the plugin Woo EU VAT Number.
I have :
function cust_vat_number ($template_type, $order) {
if ($template_type == ‘invoice’) {
$document = wcpdf_get_document( $template_type, $order );
?>
Uw BTW nummer custom_field(‘_billing_vat_number’); ?>
<?php
}
}
$vat = get_post_meta( $post->ID, ‘_billing_vat_number’, true );
if( isset( $vat ) ){
add_action( ‘wpo_wcpdf_after_order_data’, ‘cust_vat_number’, 10, 2 );
}
But this shows the preceding text in all cases. So also when an VAT number is not entered.
Plugin Contributor
dwpriv
(@dwpriv)
Give this snippet a try
add_action( 'wpo_wcpdf_after_order_data', 'cust_vat_number', 10, 2 );
function cust_vat_number( $template_type, $order ) {
if ( $template_type == 'invoice' ) {
$custom_field = $order->get_meta( '_billing_vat_number' );
if ( ! empty( $custom_field ) ) {
?>
Uw BTW nummer <?php echo $custom_field; ?>
<?php
}
}
}
Hi,
Sorry, for the late reply. Totally missed your post.
Thank you, will try this.
Hi dwpriv
With a slight adjustment it works.
I had to replace
Uw BTW nummer <?php echo $custom_field; ?>
With
<tr class="vat-nummer">
<th>Uw BTW nummer</th>
<td><?php echo $custom_field; ?> </td>
</tr>
That did the trick.
Thank you for your help.
Plugin Contributor
dwpriv
(@dwpriv)
No problem, @kingbolo. I’ll mark this topic as resolved. Feel free to open another thread if you need help with something else.