Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Created January 7, 2014 17:29
Show Gist options
  • Save ChromeOrange/8302996 to your computer and use it in GitHub Desktop.
Save ChromeOrange/8302996 to your computer and use it in GitHub Desktop.
Add a custom field from an order to the PDF invoice
/**
* Adding a custom field to the invoice
*
* Uses template tag [[CUSTOMFIELD]]
*
* custom field name : childname
*
* 1 - Edit template.php and add the tag in the desired place
* 2 - add code to the theme functions.php file
*/
add_filter ( 'pdf_content_additional_content' , 'pdf_additional_content_terms',10 ,2 );
function pdf_additional_content_terms( $content, $order_id ) {
global $woocommerce;
if ( isset( $order_id ) ) :
$content = str_replace( '[[CUSTOMFIELD]]', get_postmeta( $order_id, 'childname', TRUE ) , $content );
endif;
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment