Displaying product purchase notes

If you have set up purchase notes for your products, there’s two ways of displaying them: in a custom template (for full control over the exact position), or by adding some code (an action) to your themes functions.php

First, you need to create a custom template by following instructions here: Creating a custom PDF template.

Then place the following snippet where you would like the purchase notes to appear. Note that this has to be in the order items table!

<?php
if ( $purchase_note = get_post_meta( $item['product']->id, '_purchase_note', true ) ) {
	echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) );
}
?>

It is also possible to display purchase notes without creating a custom template, by using one the template action hooks (before or after the item meta) and adding it to your themes functions.php:

add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_show_purchase_notes', 10, 3 );
function wpo_wcpdf_show_purchase_notes ( $template_type, $item, $order ) {
	if ( $purchase_note = get_post_meta( $item['product']->id, '_purchase_note', true ) ) {
		echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) );
	}
}

or limited to the packing slip:

add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_show_purchase_notes', 10, 3 );
function wpo_wcpdf_show_purchase_notes ( $template_type, $item, $order ) {
	if ($template_type == 'packing-slip') {
		if ( $purchase_note = get_post_meta( $item['product']->id, '_purchase_note', true ) ) {
			echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) );
		}
	}
}