自定义结帐表单-login.php 模板不显示按钮文本
Customizing checkout form-login.php template does not display button text
我想通过回显在 php 中显示 link 但问题是只有 class
和 id
来自我的 <a>
标签显示但 data-toggle
是没有显示在网站上,link 没有这个属性就不能工作。
这是模板文件摘录中的样子:
if ( is_user_logged_in() || 'no' === get_option( 'woocommerce_enable_checkout_login_reminder' ) ) {
return;
}
$info_message = apply_filters( 'woocommerce_checkout_login_message', __( 'Returning customer?', 'woocommerce' ) );
$info_message .= " <a href=\"#modal-login\" class=\"login\" data-toggle=\"ml-modal\">" . __( 'Click here to login', 'woocommerce' ) . "</a>";
wc_print_notice( $info_message, 'notice' );
这是在我的浏览器中输出的源代码:
<a href="#modal-login" class="login">Klicke hier, um dich anzumelden.</a>
有人知道原因吗?
我在 Internet 上搜索了解决方案,但似乎只有我遇到这个问题。
谢谢。
It seems that you are trying to customize the code of checkout/form-login.php
WooCommerce template via your active theme (This are the official related docs: Template Structure + Overriding Templates via a Theme).
简而言之(如果尚未完成),您需要从 woocommerce 插件文件夹复制一个名为 templates
的子文件夹到您的活动 child 主题(或主题)并将其重命名为 woocommerce
。之后,您会在 woocommerce
子文件夹中的 woocommerce
子文件夹中找到一个名为 form-login.php
.
这是模板的完整代码,在您尝试执行此操作时重新访问了功能自定义。 Open/edit form-login.php
模板并将代码替换为:
<?php
/**
* Checkout login form
*
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-login.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( is_user_logged_in() || 'no' === get_option( 'woocommerce_enable_checkout_login_reminder' ) ) {
return;
}
$info_message = apply_filters( 'woocommerce_checkout_login_message', __( 'Returning customer?', 'woocommerce' ) );
//////////////// HERE IS YOUR CUSTOMIZATION ///////////////
$info_message .= ' <a href="#modal-login" class="login" data-toggle="ml-modal">' . __( 'Click here to login', 'woocommerce' ) . '</a>';
wc_print_notice( $info_message, 'notice' );
?>
<?php
woocommerce_login_form(
array(
'message' => __( 'If you have shopped with us before, please enter your details in the boxes below. If you are a new customer, please proceed to the Billing & Shipping section.', 'woocommerce' ),
'redirect' => wc_get_page_permalink( 'checkout' ),
'hidden' => true
)
);
?>
然后保存。这次输出应该按预期工作。
我想通过回显在 php 中显示 link 但问题是只有 class
和 id
来自我的 <a>
标签显示但 data-toggle
是没有显示在网站上,link 没有这个属性就不能工作。
这是模板文件摘录中的样子:
if ( is_user_logged_in() || 'no' === get_option( 'woocommerce_enable_checkout_login_reminder' ) ) {
return;
}
$info_message = apply_filters( 'woocommerce_checkout_login_message', __( 'Returning customer?', 'woocommerce' ) );
$info_message .= " <a href=\"#modal-login\" class=\"login\" data-toggle=\"ml-modal\">" . __( 'Click here to login', 'woocommerce' ) . "</a>";
wc_print_notice( $info_message, 'notice' );
这是在我的浏览器中输出的源代码:
<a href="#modal-login" class="login">Klicke hier, um dich anzumelden.</a>
有人知道原因吗?
我在 Internet 上搜索了解决方案,但似乎只有我遇到这个问题。
谢谢。
It seems that you are trying to customize the code of
checkout/form-login.php
WooCommerce template via your active theme (This are the official related docs: Template Structure + Overriding Templates via a Theme).
简而言之(如果尚未完成),您需要从 woocommerce 插件文件夹复制一个名为 templates
的子文件夹到您的活动 child 主题(或主题)并将其重命名为 woocommerce
。之后,您会在 woocommerce
子文件夹中的 woocommerce
子文件夹中找到一个名为 form-login.php
.
这是模板的完整代码,在您尝试执行此操作时重新访问了功能自定义。 Open/edit form-login.php
模板并将代码替换为:
<?php
/**
* Checkout login form
*
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-login.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( is_user_logged_in() || 'no' === get_option( 'woocommerce_enable_checkout_login_reminder' ) ) {
return;
}
$info_message = apply_filters( 'woocommerce_checkout_login_message', __( 'Returning customer?', 'woocommerce' ) );
//////////////// HERE IS YOUR CUSTOMIZATION ///////////////
$info_message .= ' <a href="#modal-login" class="login" data-toggle="ml-modal">' . __( 'Click here to login', 'woocommerce' ) . '</a>';
wc_print_notice( $info_message, 'notice' );
?>
<?php
woocommerce_login_form(
array(
'message' => __( 'If you have shopped with us before, please enter your details in the boxes below. If you are a new customer, please proceed to the Billing & Shipping section.', 'woocommerce' ),
'redirect' => wc_get_page_permalink( 'checkout' ),
'hidden' => true
)
);
?>
然后保存。这次输出应该按预期工作。