Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Created September 12, 2013 06:39
Show Gist options
  • Save ChromeOrange/6533713 to your computer and use it in GitHub Desktop.
Save ChromeOrange/6533713 to your computer and use it in GitHub Desktop.
Add Bank Details under notes section from WooCommerce BACS settings in WooCommerce PDF Invoice
/**
* Add Bank Details under notes section from WooCommerce BACS settings
*
* Uses template tag [[PDFBANKDETAILS]]
*
* 1 - Add the template tag to template.php
* 2 - Add this code to the theme functions.php
* 3 - check invoice layout and modify CSS in template.php as necessary
*/
add_filter ( 'pdf_content_additional_content' , 'pdf_additional_content_bank_details' );
function pdf_additional_content_bank_details( $content ) {
$woocommerce_bacs_settings = get_option( 'woocommerce_bacs_settings' );
$pdfbankdetails = '<h2>Bank Details</h2>';
$pdfbankdetails .= '<table width="100%">';
if( $woocommerce_bacs_settings['account_name'] ) :
$pdfbankdetails.= '<tr>';
$pdfbankdetails.= '<td width="50%">Account Name</td><td width="50%">' .$woocommerce_bacs_settings['account_name']. '</td>';
$pdfbankdetails.= '</tr>';
endif;
if( $woocommerce_bacs_settings['account_number'] ) :
$pdfbankdetails.= '<tr>';
$pdfbankdetails.= '<td width="50%">Account Number</td><td width="50%">' .$woocommerce_bacs_settings['account_number']. '</td>';
$pdfbankdetails.= '</tr>';
endif;
if( $woocommerce_bacs_settings['sort_code'] ) :
$pdfbankdetails.= '<tr>';
$pdfbankdetails.= '<td width="50%">Sort Code</td><td width="50%">' .$woocommerce_bacs_settings['sort_code']. '</td>';
$pdfbankdetails.= '</tr>';
endif;
if( $woocommerce_bacs_settings['bank_name'] ) :
$pdfbankdetails.= '<tr>';
$pdfbankdetails.= '<td width="50%">Bank Name</td><td width="50%">' .$woocommerce_bacs_settings['bank_name']. '</td>';
$pdfbankdetails.= '</tr>';
endif;
if( $woocommerce_bacs_settings['iban'] ) :
$pdfbankdetails.= '<tr>';
$pdfbankdetails.= '<td width="50%">IBAN</td><td width="50%">' .$woocommerce_bacs_settings['iban']. '</td>';
$pdfbankdetails.= '</tr>';
endif;
if( $woocommerce_bacs_settings['bic'] ) :
$pdfbankdetails.= '<tr>';
$pdfbankdetails.= '<td width="50%">BIC</td><td width="50%">' .$woocommerce_bacs_settings['bic']. '</td>';
$pdfbankdetails.= '</tr>';
endif;
$pdfbankdetails.= '</table>';
$content = str_replace( '[[PDFBANKDETAILS]]', $pdfbankdetails, $content );
return $content;
}
@famorga
Copy link

famorga commented Jul 10, 2014

Hello,
I'm new in WC and I'm just user, not developer. I'm not familiar with the terms but I try to follow the logic to set up my own web. I'm about to implement the above code. I have copied the code to functions.php. What I really don't know is on how to PDFBANKDETAILS template tag to template.php. I have found template.php. I really need advice the syntax to add template tag of PDFBANKDETAILS. Tx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment