Define account fields once, and pass order ID during filter. Closes #3201

This commit is contained in:
Mike Jolley 2013-05-22 12:20:47 +01:00
parent 8c7277bf9c
commit 45732d49d0
1 changed files with 13 additions and 17 deletions

View File

@ -41,6 +41,16 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
$this->iban = $this->get_option( 'iban' ); $this->iban = $this->get_option( 'iban' );
$this->bic = $this->get_option( 'bic' ); $this->bic = $this->get_option( 'bic' );
// BACS account fields shown on the thanks page and in emails
$this->account_fields = array(
'account_name' => __( 'Account Name', 'woocommerce' ),
'account_number'=> __( 'Account Number', 'woocommerce' ),
'sort_code' => __( 'Sort Code', 'woocommerce' ),
'bank_name' => __( 'Bank Name', 'woocommerce' ),
'iban' => __( 'IBAN', 'woocommerce' ),
'bic' => __( 'BIC', 'woocommerce' )
);
// Actions // Actions
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
add_action( 'woocommerce_thankyou_bacs', array( $this, 'thankyou_page' ) ); add_action( 'woocommerce_thankyou_bacs', array( $this, 'thankyou_page' ) );
@ -151,7 +161,7 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
* @access public * @access public
* @return void * @return void
*/ */
function thankyou_page() { function thankyou_page( $order_id ) {
if ( $description = $this->get_description() ) if ( $description = $this->get_description() )
echo wpautop( wptexturize( wp_kses_post( $description ) ) ); echo wpautop( wptexturize( wp_kses_post( $description ) ) );
@ -159,14 +169,7 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
echo '<ul class="order_details bacs_details">'; echo '<ul class="order_details bacs_details">';
$fields = apply_filters('woocommerce_bacs_fields', array( $fields = apply_filters( 'woocommerce_bacs_fields', $this->account_fields, $order_id );
'account_name' => __( 'Account Name', 'woocommerce' ),
'account_number'=> __( 'Account Number', 'woocommerce' ),
'sort_code' => __( 'Sort Code', 'woocommerce' ),
'bank_name' => __( 'Bank Name', 'woocommerce' ),
'iban' => __( 'IBAN', 'woocommerce' ),
'bic' => __( 'BIC', 'woocommerce' )
));
foreach ( $fields as $key=>$value ) { foreach ( $fields as $key=>$value ) {
if ( ! empty( $this->$key ) ) { if ( ! empty( $this->$key ) ) {
@ -199,14 +202,7 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
?><h2><?php _e( 'Our Details', 'woocommerce' ) ?></h2><ul class="order_details bacs_details"><?php ?><h2><?php _e( 'Our Details', 'woocommerce' ) ?></h2><ul class="order_details bacs_details"><?php
$fields = apply_filters('woocommerce_bacs_fields', array( $fields = apply_filters( 'woocommerce_bacs_fields', $this->account_fields, $order->id );
'account_name' => __( 'Account Name', 'woocommerce' ),
'account_number'=> __( 'Account Number', 'woocommerce' ),
'sort_code' => __( 'Sort Code', 'woocommerce' ),
'bank_name' => __( 'Bank Name', 'woocommerce' ),
'iban' => __( 'IBAN', 'woocommerce' ),
'bic' => __( 'BIC', 'woocommerce' )
));
foreach ($fields as $key=>$value) : foreach ($fields as $key=>$value) :
if(!empty($this->$key)) : if(!empty($this->$key)) :