gpt4 book ai didi

php - Woocommerce 默认占位符未在结帐表单中消失

转载 作者:搜寻专家 更新时间:2023-10-31 21:08:43 26 4
gpt4 key购买 nike

我正在使用 woocommerce_checkout_fields 来更改标签和字段。下面是我的代码

function custom_override_checkout_fields($fields) {


$fields['billing']['billing_first_name'] = array(
'label' => '',
'placeholder' => _x('First Name*', 'placeholder', 'woocommerce'),
'required' => true,
'class' => array('checkout-billing-first-name')
);
$fields['billing']['billing_last_name'] = array(
'label' => '',
'placeholder' => _x('last Name*', 'placeholder', 'woocommerce'),
'required' => true,
'class' => array('checkout-billing-last-name')
);
$fields['billing']['billing_company'] = array(
'label' => '',
'placeholder' => _x('Company Name', 'placeholder', 'woocommerce'),
'required' => false,
'class' => array('checkout-billing-company')
);
$fields['billing']['billing_address_1'] = array(
'label' => '',
'placeholder' => _x('Address(Line 1)*', 'placeholder', 'woocommerce'),
'required' => true,
'class' => array('checkout-billing-addressL1')
);
$fields['billing']['billing_address_2'] = array(
'label' => '',
'placeholder' => _x('Address(Line 2)*', 'placeholder', 'woocommerce'),
'required' => false,
'class' => array('checkout-billing-addressL2')
);

return $fields;
}

add_filter('woocommerce_checkout_fields', 'custom_override_checkout_fields');

一切正常,但帐单地址 1 和帐单地址 2 的占位符仅更改为在加载中,即在页面加载后显示默认占位符。

最佳答案

尝试使用过滤器 woocommerce_default_address_fields。

例如:

function pawelprotas_wc_default_address_fields($fields){
$fields['address_1']['placeholder'] = __('Street address *', 'loft');
$fields['address_2']['placeholder'] = __('Apartment, suite, unit etc.', 'loft');

return $fields;
}

add_filter('woocommerce_default_address_fields', 'pawelprotas_wc_default_address_fields');

关于php - Woocommerce 默认占位符未在结帐表单中消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27033534/

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