简体   繁体   English

WooCommerce:如何更改“我们的银行详细信息”标题?

[英]WooCommerce: How to change "Our Bank Details" heading?

In the email WooCommerce sends to customers if they ordered a product and picked bank transfer (BACS) as payment method, by default there is an h2 heading: "Our bank details".WooCommerce发送给客户的电子邮件中,如果他们订购了产品并选择银行转账 (BACS) 作为付款方式,默认情况下会有一个h2标题:“我们的银行详细信息”。 I want to change this wording.我想改变这个措辞。

在此处输入图片说明

I figure I best do this via functions.php , but I am not sure how to address this.我想我最好通过functions.php做到这一点,但我不知道如何解决这个问题。 Could someone please help me?有人可以帮我吗?

Alternative approaches to solve this problem are welcome, too.解决这个问题的替代方法也是受欢迎的。

The line I want to change is in this if-statement in class-wc-gateways-bacs.php :我想更改的行在class-wc-gateways-bacs.php if 语句中:

if ( $has_details ) { echo '<section class="woocommerce-bacs-bank-details"><h2 class="wc-bacs-bank-details-heading">' . esc_html__( 'Our bank details', 'woocommerce' ) . '</h2>' . wp_kses_post( PHP_EOL . $account_html ) . '</section>';

Here is the complete function from within the class WC_Gateway_BACS extends WC_Payment_Gateway :这是class WC_Gateway_BACS extends WC_Payment_Gateway的完整函数:

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 .= '<h3 class="wc-bacs-bank-details-account-name">' . wp_kses_post( wp_unslash( $bacs_account->account_name ) ) . ':</h3>' . PHP_EOL;
            }

            $account_html .= '<ul class="wc-bacs-bank-details order_details bacs_details">' . PHP_EOL;

            // BACS account fields shown on the thanks page and in emails.
            $account_fields = apply_filters(
                'woocommerce_bacs_account_fields',
                array(
                    'bank_name'      => array(
                        'label' => __( 'Bank', 'woocommerce' ),
                        'value' => $bacs_account->bank_name,
                    ),
                    'account_number' => array(
                        'label' => __( 'Account number', 'woocommerce' ),
                        'value' => $bacs_account->account_number,
                    ),
                    'sort_code'      => array(
                        'label' => $sortcode,
                        'value' => $bacs_account->sort_code,
                    ),
                    'iban'           => array(
                        'label' => __( 'IBAN', 'woocommerce' ),
                        'value' => $bacs_account->iban,
                    ),
                    'bic'            => array(
                        'label' => __( 'BIC', 'woocommerce' ),
                        'value' => $bacs_account->bic,
                    ),
                ),
                $order_id
            );

            foreach ( $account_fields as $field_key => $field ) {
                if ( ! empty( $field['value'] ) ) {
                    $account_html .= '<li class="' . esc_attr( $field_key ) . '">' . wp_kses_post( $field['label'] ) . ': <strong>' . wp_kses_post( wptexturize( $field['value'] ) ) . '</strong></li>' . PHP_EOL;
                    $has_details   = true;
                }
            }

            $account_html .= '</ul>';
        }

        if ( $has_details ) {
            echo '<section class="woocommerce-bacs-bank-details"><h2 class="wc-bacs-bank-details-heading">' . esc_html__( 'Our bank details', 'woocommerce' ) . '</h2>' . wp_kses_post( PHP_EOL . $account_html ) . '</section>';
        }
    }

}

Please try this请试试这个

function update_bank_details_heading($translated_text, $text, $domain) {

    if ( did_action('woocommerce_email_before_order_table') ) {

        switch ( $translated_text ) {

            case 'Our Bank Details' :

                $translated_text = __( 'Bank Details Are...', 'woocommerce' );
                break;

        }

    }

    return $translated_text;
}

add_filter( 'gettext', 'update_bank_details_heading', 20, 3 );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在WooCommerce电子邮件中设置银行详细信息的样式? - How to stylize bank details in WooCommerce email? 在 WooCommerce 电子邮件中的客户详细信息之后移动 BACS 银行详细信息 - Move BACS bank details after customer details in WooCommerce emails 如何更改电子邮件中的woocommerce客户详细信息标签? - How to change woocommerce customer details labels in email? 如何更改 WooCommerce“我的帐户”订单表中的列标题 - How to change column heading in WooCommerce "My account" orders table 从WooCommerce中的新订单电子邮件中删除银行帐户详细信息 - Remove bank account details from new order email in WooCommerce 更改默认选项卡标题文本 | WordPress WooCommerce - Change Default Tab Heading Text | Wordpress WooCommerce 如何使用挂钩更改 WooCommerce 结帐页面上的“账单明细”标题 - How to change "Billing details" title on WooCommerce checkout page with a hook WooCommerce:更改相关产品标题并删除/更改<h2> - WooCommerce: Change related products heading and remove/change <h2> 如何在 Woocommerce 中的 woocommerce-account-fields 上方添加标题 - How to add a heading above woocommerce-account-fields in Woocommerce 如何从Click Bank API和XML中列出产品详细信息? - How to list out product details from click bank API and XML?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM