Change BACS Payment Details Layout in Thank You Message and Email

We needed to reorder the BACS (online banking) details on the “Thank You” page and the email sent to the customer so that they made more sense to New Zealand customers by combining the sort code and the account number.

This was achieved by adding the following to THEME/functions.php

// change BACS fields
//original fields from plugins/woocommerce/includes/gateways/bacs/class-wc-gateway-bacs.php

add_filter('woocommerce_bacs_account_fields','custom_bacs_fields');

function custom_bacs_fields() {
	global $wpdb;
	$account_details = get_option( 'woocommerce_bacs_accounts',
				array(
					array(
						'account_name'   => get_option( 'account_name' ),
						'account_number' => get_option( 'account_number' ),
						'sort_code'      => get_option( 'sort_code' ),
						'bank_name'      => get_option( 'bank_name' ),
						'iban'           => get_option( 'iban' ),
						'bic'            => get_option( 'bic' )
					)
				)

			);


	$account_fields = array(
		'bank_name'      => array(
			'label' => 'Bank',
			'value' => $account_details[0]['bank_name']
		),
		'account_name'   => array(
			'label' => 'Account Name',
			'value' => $account_details[0]['account_name']
		),
		'account_number' => array(
			'label' => __( 'Account Number', 'woocommerce' ),
			'value' => $account_details[0]['sort_code'].' '.$account_details[0]['account_number']
		),
		'bic'            => array(
			'label' => __( 'BIC', 'woocommerce' ),
			'value' => $account_details[0]['bic']
		)
	);

	return $account_fields;


}

 

Removing the “Name Bank” from theĀ  page (ie. Joe Smith ANZ) was more complex and the result is a bit dirty but can be achieved by adding this to THEME/style.css

.woocommerce-order-received .woocommerce h3:first-of-type {
  display: none;
}