Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Created September 12, 2013 06:39

Revisions

  1. ChromeOrange created this gist Sep 12, 2013.
    54 changes: 54 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    /**
    * 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;

    }