Hello @ahranalytics
The easy way is using our Premium Templates extension by adding those custom field names to a custom block.
Alternatively you can also display those using a code snippet. Please read this documentation page: How to display a custom field
@alexmigf
I am always keen to buy the premiumship but I want to analyze first if this plugin really helps me in terms of technicalities before buying it.
Thank you though for sending the link for customization, however none of the code is working for me. See my code below:
add_action( ‘wpo_wcpdf_after_order_data’, ‘wpo_wcpdf_billing_viber’, 10, 2 );
function wpo_wcpdf_billing_viber ($template_type, $order) {
if ($template_type == ‘packing-slip’) {
$document = wcpdf_get_document( $template_type, $order );
?>
<tr class=”billing_viber”>
<th>Viber:</th>
<td><?php $document->custom_field(‘billing_viber’); ?></td>
</tr>
<?php
}
}
I am trying to put the billing_viber data to the PDF invoice.
Hi @ahranalytics
Try this instead:
add_action( 'wpo_wcpdf_after_order_data', function( $document_type, $order ) {
if ( ! empty($order) && $document_type == 'packing-slip' ) {
?>
<tr class="billing_viber">
<th>Viber:</th>
<td><?= $order->get_meta('billing_viber'); ?></td>
</tr>
<?php
}
}, 10, 2 );
If you never worked with actions/filters, please read this documentation page: How to use filters
Hi @alexmigf
Thanks! Not what I want but I found a way transferring the data to PDF Invoice not in the packing slips.
Last one before I mark this as resolved, I want to add a phone number as well but it is not working and the phone number I input didnt reflected on the PDF Invoice, see my code:
//Viber
add_action( 'wpo_wcpdf_after_order_data', function( $document_type, $order ) {
if ( ! empty($order) && $document_type == 'invoice' ) {
?>
<tr class="billing_viber">
<th>Viber:</th>
<td><?= $order->get_meta('billing_viber'); ?></td>
</tr>
<?php
}
}, 10, 2 );
//Phone
add_action( 'wpo_wcpdf_after_order_data', function( $document_type, $order ) {
if ( ! empty($order) && $document_type == 'invoice' ) {
?>
<tr class="billing_phone">
<th>Contact no:</th>
<td><?= $order->get_meta('billing_phone'); ?></td>
</tr>
<?php
}
}, 10, 2 );
Screenshot:https://imgur.com/TFnare0
Hi @ahranalytics
I set it to ‘packing-slip’ because your example here had it.
I believe the phone meta key is: _billing_phone