gpt4 book ai didi

php - WooCommerce:在结帐时更改账单字段的 HTML 结构

转载 作者:行者123 更新时间:2023-12-04 10:11:29 25 4
gpt4 key购买 nike

我想为帐单字段使用 float 标签。因此我需要放置 <label> <input> 之后的元素HTML 结构中的字段。

目前我的结构是这样的:

<p class="form-row form-row-first validate-required" id="billing_first_name_field" data-priority="10">
<label for="billing_first_name" class="">First Name&nbsp;<abbr class="required" title="required">*</abbr></label>
<span class="woocommerce-input-wrapper">
<input type="text" class="input-text form-control" name="billing_first_name" id="billing_first_name" placeholder="" value="First Name" autocomplete="given-name">
</span>
</p>

我想要 input/span 元素之后的标签,像这样:

<p class="form-row form-row-first validate-required" id="billing_first_name_field" data-priority="10">
<span class="woocommerce-input-wrapper">
<input type="text" class="input-text form-control" name="billing_first_name" id="billing_first_name" placeholder="" value="First Name" autocomplete="given-name">
</span>
<label for="billing_first_name" class="">First Name&nbsp;<abbr class="required" title="required">*</abbr></label>
</p>

有什么办法可以改变字段的输出吗?

我发现了一些钩子(Hook)来改变字段的一些元素:https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/

但这都与元素的内容有关。不是 HTML 结构本身。这可能吗?

最佳答案

$field contains the complete <p>...</p> output. So you can completely adjust the output. To keep it dynamic you can use the values ​​from $args


See: https://github.com/woocommerce/woocommerce/blob/master/includes/wc-template-functions.php#L2830 and accompanying code, how to do this

function change_woocommerce_field_markup($field, $key, $args, $value) {
if( $key === 'billing_first_name') {
$field = 'my html';
}
return $field;
}

add_filter("woocommerce_form_field_text","change_woocommerce_field_markup", 10, 4);

关于php - WooCommerce:在结帐时更改账单字段的 HTML 结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61319230/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com