php - 在账单地址 WooCommerce 结帐字段下添加一个段落

标签 php html wordpress woocommerce checkout

我正在尝试添加 HTML 标签 <p>Billing_Address_2下 field 。我阅读了一些文档并尝试了这段代码:

function red_text() {
    echo '<p class="red_text" style="color:red;float:left;display:none">Hello World</p>';
}
add_action( 'woocommerce_after_billing_address_2_field', 'red_text' );

但是,当我将它放入我的 function.php 主题中时,它并没有添加标签。还有另一种方法可以在结帐页面中添加 html 标签吗?如果不是,是不是我的代码错了?

最佳答案

/**
 * Add HTML to the checkout page after order notes
 */
add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );

function my_custom_checkout_field( $checkout ) {

    echo '<p class="red_text" style="color:red;">Hello World</p>';

}

enter image description here

关于php - 在账单地址 WooCommerce 结帐字段下添加一个段落,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43245126/

相关文章:

php - $_POST 在 wordpress 中提交表单时返回空

javascript - CSS 显示属性未通过 JS 做出相应响应

html - Mac OSX 上的 Electron 应用程序,用于文件选择的输入

javascript - What happens to an HTML5 web worker thread when the tab is closed while it's running?

wordpress - 未加载所有图像时停止 Masonry 重新调整大小

php - 如何改进缓慢的自定义查询? (子查询+带有自定义字段的内连接)

php - 正则表达式匹配以 %% 开头和结尾的字符串

php - 如何使用 mysqli 计算同一数据库中的 2 行

PHP,Mysql : Get hour, 分钟并存储在变量中

css - 在子菜单中永久激活的菜单颜色