|
|
|
$name ) {
if ( ! isset( $account_names[ $i ] ) ) {
continue;
}
$accounts[] = array(
'account_name' => $account_names[ $i ],
'account_number' => $account_numbers[ $i ],
'bank_name' => $bank_names[ $i ],
'sort_code' => $sort_codes[ $i ],
'iban' => $ibans[ $i ],
'bic' => $bics[ $i ],
);
}
}
// phpcs:enable
do_action( 'woocommerce_update_option', array( 'id' => 'woocommerce_bacs_accounts' ) );
update_option( 'woocommerce_bacs_accounts', $accounts );
}
/**
* Output for the order received page.
*
* @param int $order_id Order ID.
*/
public function thankyou_page( $order_id ) {
if ( $this->instructions ) {
echo wp_kses_post( wpautop( wptexturize( wp_kses_post( $this->instructions ) ) ) );
}
$this->bank_details( $order_id );
}
/**
* Add content to the WC emails.
*
* @param WC_Order $order Order object.
* @param bool $sent_to_admin Sent to admin.
* @param bool $plain_text Email format: plain text or HTML.
*/
public function email_instructions( $order, $sent_to_admin, $plain_text = false ) {
if ( ! $sent_to_admin && self::ID === $order->get_payment_method() ) {
/**
* Filter the email instructions order status.
*
* @since 7.4
*
* @param string $terms The order status.
* @param object $order The order object.
*/
$instructions_order_status = apply_filters( 'woocommerce_bacs_email_instructions_order_status', OrderStatus::ON_HOLD, $order );
if ( $order->has_status( $instructions_order_status ) ) {
if ( $this->instructions ) {
echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
}
$this->bank_details( $order->get_id() );
}
}
}
/**
* Get bank details and place into a list format.
*
* @param int $order_id Order ID.
*/
private function bank_details( $order_id = '' ) {
if ( empty( $this->account_details ) ) {
return;
}
// Get order and store in $order.
$order = wc_get_order( $order_id );
// Get the order country and country $locale.
$country = $order->get_billing_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' );
$bacs_accounts = apply_filters( 'woocommerce_bacs_accounts', $this->account_details, $order_id );
if ( ! empty( $bacs_accounts ) ) {
$account_html = '';
$has_details = false;
foreach ( $bacs_accounts as $bacs_account ) {
$bacs_account = (object) $bacs_account;
if ( $bacs_account->account_name ) {
$account_html .= '