I am looking to add custom meta after the order data in WooCommerce PDF Invoices & Packing Slips. If a Custom Field is present on a WooCommerce order,
In my code my custom field name is wholesale_order
.
For this I make use of:
add_action( 'wpo_wcpdf_after_order_data', 'add_due_date', 10, 2 );
function add_due_date() {
$order_data = get_post_meta( $post->ID, 'wholesale_order', true );
if( $order_data ) {
// Do stuff
}
}
Unfortunately without the desired result, I think the $post->ID
is incorrect and probably the get_post_meta
.
What am I missing?
2
Answers
Declare
global $post
before$order_data
variable.First try:
If that works you can expand your code to something like:
Action hook:
wpo_wcpdf_after_order_data
has 2 arguments$template_type
&$order
.