gpt4 book ai didi

php - 删除 WooCommerce 结帐字段值

转载 作者:可可西里 更新时间:2023-11-01 13:12:59 25 4
gpt4 key购买 nike

我正在尝试在我的 WooCommerce 结帐字段上应用 autocomplete="off",但它不起作用。

有没有办法为结帐表单执行此操作?

我检查了文档,那里没有可用的内容。我也尝试将默认值设置为空,但它也不起作用。当然,这是用户未登录时的情况。

enter image description here

更新:

我按照@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 但效果不佳。

谢谢

最佳答案

您可以使用 Wordpress '__return_empty_string'woocommerce_checkout_get_value WooCommerce 过滤器 Hook 以这种方式简单地获取空值:

add_filter('woocommerce_checkout_get_value','__return_empty_string', 1, 1);

This will empty all checkout values, when checkout page is loaded.

代码位于您的事件子主题(或主题)的 functions.php 文件中或任何插件文件中。

此代码已经过测试并且可以工作。

You should reset all existing sessions in Woocommerce settings > System status > tools and also the cache if your e-commerce use any.
Also empty your browser cache and stored data.

相关:Clear only some checkout fields values in Woocommerce

关于php - 删除 WooCommerce 结帐字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43314610/

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