Created
January 7, 2014 17:29
-
-
Save ChromeOrange/8302996 to your computer and use it in GitHub Desktop.
Add a custom field from an order to the PDF invoice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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