使用Wordpress进行Woocommerce - 在结帐页面上更改用于创建密码的文本

问题描述 投票:-2回答:4

在使用Wordpress的Woocommerce上,当有人在结帐页面上时,我在更改帐户密码上方的文本时遇到了困难。

请看下面的截图,它以红色框突出显示。

我相信一种方法可以通过网站服务器上的.php文件,但我已经在网站的文件中尝试了my-account.php和checkout-form.php,我看不到文字到重命名这部分。

php wordpress woocommerce
4个回答
1
投票

如果可以,最好使用内置的挂钩和操作来更改内容,否则如果插件中的核心模板发生更改,则主题模板中的副本将变得过时。

您突出显示的文本段落在模板中,因此要更改您需要更改模板的文本,但另一个选项是简单地用CSS隐藏它,然后更改它下面的“帐户密码”标签来说出你的内容想。

将其放入functions.php文件中以更改该标签,而无需主题模板覆盖:

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
    $fields['account']['account_password']['label'] = 'Your new message here';
    return $fields;
}

如果需要,您还可以使用相同的功能更改其他标签。


1
投票

我将以下内容添加到我的孩子主题的functions.php中,将“返回客户”更改为“返回学生”:

//Change the Create Account checkout text
function wc_create_account_field_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Create an account by entering the information below. If you are a returning customer please login at the top of the page.' :
$translated_text = __( 'Create an account by entering the information below. If you are a returning student please login at the top of the page.', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'wc_create_account_field_strings', 20, 3 );

0
投票

此文本位于您的主题文件夹中,大约:woocommerce/templates/checkout/form-billing.php~line:53。

寻找:

<p><?php _e( 'Create an account by entering the information below. If you are a returning customer please login at the top of the page.', 'woocommerce' ); ?></p>

还要查看https://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/对实际表单元素的任何更改。

希望这可以帮助。


0
投票

在项目中找到template-hook和template-tags文件夹。我在wp-content / themes / theme_name / inc / woocommerce找到了。

并且消息由template-tags文件夹中的文件组成,但您必须首先知道钩子名称。

© www.soinside.com 2019 - 2024. All rights reserved.