Plugin Contributor
Ewout
(@pomegranate)
Hi Paul,
Billing last name is not in the default functions, so you first have to get that from the order meta:
<?php
$billing_last_name = get_post_meta($wpo_wcpdf->export->order->id,'_billing_last_name',true);
if (isset($billing_last_name)) {
echo $billing_last_name;
}
?>
Of course, you can replace “billing” with “shipping” for the packing slip.
Thread Starter
Paul
(@paul-wolters)
Thank you, Ewout! It works!
To whom it may concern. I tweaked this plugin to show the VAT which is essential in the Italian tax system.
I am using the following plugin to add VAT but I renamed the variable of VAT to campo_cf_piva: http://www.netstarsolution.net/woocommerce-partita-iva-e-codice-fiscale-free/
So I added the following code to the Woocommerce pdf invoices packing slips template:
<div class="recipient-address">Codice fiscale: <?php
$campo_cf_piva = get_post_meta($wpo_wcpdf->export->order->id,'campo_cf_piva',true);
if (isset($campo_cf_piva)) {
echo $campo_cf_piva;
}
?></div>
I hope I made myself understood.
Plugin Contributor
Ewout
(@pomegranate)
Hello Rosella,
Thanks for sharing!
Newer versions of the plugin make this much simpler (see the FAQ):
<div class="recipient-address">
<?php $wpo_wcpdf->custom_field('campo_cf_piva', 'Codice fiscale:'); ?>
</div>
For displaying the last name (original question), the code would be:
<?php $wpo_wcpdf->custom_field('_billing_last_name', ''); ?>
Have a great day!
Ewout