WC_Gateway_BACS::generate_account_details_html()publicWC 1.0

Generate account details html.

Method of the class: WC_Gateway_BACS{}

No Hooks.

Return

String.

Usage

$WC_Gateway_BACS = new WC_Gateway_BACS();
$WC_Gateway_BACS->generate_account_details_html();

WC_Gateway_BACS::generate_account_details_html() code WC 8.7.0

<?php
public function generate_account_details_html() {

	ob_start();

	$country = WC()->countries->get_base_country();
	$locale  = $this->get_country_locale();

	// Get sortcode label in the $locale array and use appropriate one.
	$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'woocommerce' );

	?>
	<tr valign="top">
		<th scope="row" class="titledesc">
			<label>
				<?php esc_html_e( 'Account details:', 'woocommerce' ); ?>
				<?php echo wp_kses_post( wc_help_tip( __( 'These account details will be displayed within the order thank you page and confirmation email.', 'woocommerce' ) ) ); ?>
			</label>
		</th>
		<td class="forminp" id="bacs_accounts">
			<div class="wc_input_table_wrapper">
				<table class="widefat wc_input_table sortable" cellspacing="0">
					<thead>
						<tr>
							<th class="sort">&nbsp;</th>
							<th><?php esc_html_e( 'Account name', 'woocommerce' ); ?></th>
							<th><?php esc_html_e( 'Account number', 'woocommerce' ); ?></th>
							<th><?php esc_html_e( 'Bank name', 'woocommerce' ); ?></th>
							<th><?php echo esc_html( $sortcode ); ?></th>
							<th><?php esc_html_e( 'IBAN', 'woocommerce' ); ?></th>
							<th><?php esc_html_e( 'BIC / Swift', 'woocommerce' ); ?></th>
						</tr>
					</thead>
					<tbody class="accounts">
						<?php
						$i = -1;
						if ( $this->account_details ) {
							foreach ( $this->account_details as $account ) {
								$i++;

								echo '<tr class="account">
									<td class="sort"></td>
									<td><input type="text" value="' . esc_attr( wp_unslash( $account['account_name'] ) ) . '" name="bacs_account_name[' . esc_attr( $i ) . ']" /></td>
									<td><input type="text" value="' . esc_attr( $account['account_number'] ) . '" name="bacs_account_number[' . esc_attr( $i ) . ']" /></td>
									<td><input type="text" value="' . esc_attr( wp_unslash( $account['bank_name'] ) ) . '" name="bacs_bank_name[' . esc_attr( $i ) . ']" /></td>
									<td><input type="text" value="' . esc_attr( $account['sort_code'] ) . '" name="bacs_sort_code[' . esc_attr( $i ) . ']" /></td>
									<td><input type="text" value="' . esc_attr( $account['iban'] ) . '" name="bacs_iban[' . esc_attr( $i ) . ']" /></td>
									<td><input type="text" value="' . esc_attr( $account['bic'] ) . '" name="bacs_bic[' . esc_attr( $i ) . ']" /></td>
								</tr>';
							}
						}
						?>
					</tbody>
					<tfoot>
						<tr>
							<th colspan="7"><a href="#" class="add button"><?php esc_html_e( '+ Add account', 'woocommerce' ); ?></a> <a href="#" class="remove_rows button"><?php esc_html_e( 'Remove selected account(s)', 'woocommerce' ); ?></a></th>
						</tr>
					</tfoot>
				</table>
			</div>
			<script type="text/javascript">
				jQuery(function() {
					jQuery('#bacs_accounts').on( 'click', 'a.add', function(){

						var size = jQuery('#bacs_accounts').find('tbody .account').length;

						jQuery('<tr class="account">\
								<td class="sort"></td>\
								<td><input type="text" name="bacs_account_name[' + size + ']" /></td>\
								<td><input type="text" name="bacs_account_number[' + size + ']" /></td>\
								<td><input type="text" name="bacs_bank_name[' + size + ']" /></td>\
								<td><input type="text" name="bacs_sort_code[' + size + ']" /></td>\
								<td><input type="text" name="bacs_iban[' + size + ']" /></td>\
								<td><input type="text" name="bacs_bic[' + size + ']" /></td>\
							</tr>').appendTo('#bacs_accounts table tbody');

						return false;
					});
				});
			</script>
		</td>
	</tr>
	<?php
	return ob_get_clean();

}