Created
September 12, 2013 06:15
-
-
Save ChromeOrange/6533569 to your computer and use it in GitHub Desktop.
Add Terms section to WooCommerce 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 terms and conditions area to the invoice | |
* | |
* Uses template tag [[PDFTERMSCONDITIONS]] | |
* | |
* settings field name : woocommerce_pdf_invoice_settings[invoice_terms] | |
* | |
* 1 - Edit template.php and add the tag in the desired place | |
* 2 - add code to the theme functions.php file | |
* 3 - add text in PDF Invoice settings | |
*/ | |
add_action ( 'woocommerce_pdf_invoice_additional_fields_admin' , 'additional_fields_admin_terms' ); | |
function additional_fields_admin_terms() { | |
$woocommerce_pdf_invoice_options = get_option('woocommerce_pdf_invoice_settings'); | |
?> | |
<!-- Terms and Conditions --> | |
<tr valign="top"> | |
<th scope="row" class="titledesc"> | |
<label for="woocommerce_pdf_invoice_settings[invoice_terms]">Invoice Terms and Conditions</label> | |
<img class="help_tip" data-tip="Add some custom text to your invoice" src="<?php echo plugins_url( 'woocommerce/assets/images/help.png' );?>" height="16" width="16" /> | |
</th> | |
<td class="forminp forminp-number"> | |
<textarea id="woocommerce_pdf_invoice_settings[invoice_terms]" | |
name="woocommerce_pdf_invoice_settings[invoice_terms]" | |
value="" | |
placeholder="" style="width: 350px;"/><?php if ( isset($woocommerce_pdf_invoice_options['invoice_terms']) ) { echo $woocommerce_pdf_invoice_options['invoice_terms']; }?></textarea> | |
</td> | |
</tr> | |
<?php | |
} | |
add_filter ( 'pdf_content_additional_content' , 'pdf_additional_content_terms' ); | |
function pdf_additional_content_terms( $content ) { | |
$woocommerce_pdf_invoice_options = get_option('woocommerce_pdf_invoice_settings'); | |
if ( isset($woocommerce_pdf_invoice_options['invoice_terms']) ) : | |
$content = str_replace( '[[PDFTERMSCONDITIONS]]', $woocommerce_pdf_invoice_options['invoice_terms'], $content ); | |
endif; | |
return $content; | |
} | |
/* Close terms and conditions */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment