In Woocommerce I am using a plugin called YITH WooCommerce PDF Invoice and Shipping List and I would like to add customer note to the PDF invoice.
I would like to add it after the first span line in the code below:
<span class="notes-title"><?php _e( "Notes", "yith-woocommerce-pdf-invoice" ); ?></span>
<div class="notes">
<span><?php echo nl2br( $notes ); ?></span>
<?php do_action( 'yith_ywpi_after_document_notes', $document );?>
</div>
</div>
<?php
But i can't figure out how to get the customer note from $document
variable.
I have tried to use this answer thread: "Display Customer order comments (customer note) in Woocommerce" which looks pretty much like the same problem but still could'nt figure it out as $document->order->customer_message;
doesn't work.
Any help is appreciated.
Since Woocommerce 3 you can't access anymore properties From the
WC_Order
object. You need to use theWC_Order
method [get_customer_note()
][1].So from the
$document
(YITH global object) you will use:To add customer notes to YITH invoice you can choose between 2 ways:
1) Using the available
yith_ywpi_after_document_notes
action hook:Code goes in function.php file of your active child theme (or active theme). Untested (as I dont have the premium version of the plugin) but it should work normally (depending on the plugin settings).
2) Overriding templates (in your provided code):
It should work.
$document
.So you will be able to use the following code in
templates/invoice/invoice-footer.php
template: