WooCommerce: Account Password Field in Checkout page

杀马特。学长 韩版系。学妹 提交于 2019-12-22 13:01:55

问题


My main goal is to change the "create an account" checkout to register the email as a username. The easy way I thought of was changing "Account Password" from password to email to override user_login.

However, I can't seem to find where the "Password" text box is coming from. I know that this the code I needed under form-billing.php, but I am unsure how only password is showing considering there's a for-loop.

<?php foreach ( $checkout->checkout_fields['account'] as $key => $field ) : ?>

    <?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>

<?php endforeach; ?>

Any advice is appreciated.


回答1:


here is file directory path of password and code:--

plugins\woocommerce\includes\class-wc-checkout.php

if ( get_option( 'woocommerce_registration_generate_password' ) == 'no' ) {
            $this->checkout_fields['account']['account_password'] = array(
                'type'              => 'password',
                'label'             => __( 'Account password', 'woocommerce' ),
                'required'          => true,
                'placeholder'       => _x( 'Password', 'placeholder', 'woocommerce' )
            );
        }



回答2:


Or you can put this code in your function.php this way, an update doesn't overide it :

add_filter( 'woocommerce_checkout_fields' , 'custom_wc_checkout_fields' );

function custom_wc_checkout_fields( $fields ) {
  $fields['account']['account_password']['placeholder'] = '';
  return $fields;
}


来源:https://stackoverflow.com/questions/38071216/woocommerce-account-password-field-in-checkout-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!