【发布时间】:2017-09-04 23:48:39
【问题描述】:
我正在尝试在我的 WooCommerce 结帐字段上应用 autocomplete="off",但它不起作用。
有没有办法为结帐表单做到这一点?
我查看了文档,但那里没有可用的内容。我也尝试将默认值设置为空,但它也不起作用。这当然是用户没有登录的时候。
更新:
我按照@smvax 的建议尝试了unset,但效果不佳。
add_filter('woocommerce_checkout_fields', 'default_values_checkout_fields');
function default_values_checkout_fields($fields) {
if (!is_user_logged_in()) {
unset($fields['billing_city']);
unset($fields['billing_first_name']);
unset($fields['billing_last_name']);
unset($fields['billing_company']);
unset($fields['billing_address_1']);
unset($fields['billing_address_2']);
unset($fields['billing_city']);
unset($fields['billing_postcode']);
unset($fields['billing_country']);
unset($fields['billing_state']);
unset($fields['billing_email']);
unset($fields['billing_phone']);
unset($fields['shipping_city']);
unset($fields['shipping_first_name']);
unset($fields['shipping_last_name']);
unset($fields['shipping_company']);
unset($fields['shipping_address_1']);
unset($fields['shipping_address_2']);
unset($fields['shipping_postcode']);
unset($fields['shipping_country']);
unset($fields['shipping_state']);
return $fields;
}
}
我也尝试了答案here,但效果不佳。
谢谢
【问题讨论】:
-
Nkatry ka na nito jeepers? :) stackoverflow.com/questions/36694355/…
-
@smzvax 我刚试过
unset,整个表格都不见了。 -
如何添加 ['clear'] 如下所示:surpriseazwebservices.com/edit-woocommerce-checkout-fields
-
@jeepers_creepers,你在哪里添加
AUTOCOMPLETE = "off"属性? -
@MayankRaj 在
<form>
标签: php wordpress woocommerce checkout hook-woocommerce