删除WooCommerce结帐字段值 [英] Remove WooCommerce checkout fields values

查看:72
本文介绍了删除WooCommerce结帐字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的WooCommerce结帐字段上应用 autocomplete = off ,但这是行不通的。

I'm trying to apply autocomplete="off" on my WooCommerce checkout fields but it just doesn't work.

是否有一种方法可以结帐?

Is there a way to do that for the checkout form?

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

I checked the docs and there's nothing available there. I also tried setting the default value to empty but it doesn't work either. This is when the user is not logged in of course.

更新:

我按照@smvax的建议尝试了未设置,但它

I tried unset as suggested by @smvax but it did not work as well.

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;
  }
}

我也尝试了答案 此处 ,但效果不佳。

I also tried the answer here but it's not working as well.

谢谢

推荐答案

您可以使用Wordpress '__ return_empty_string' > woocommerce_checkout_get_value WooCommerce过滤器钩子就是这样简单地获取空值的:

You can use Wordpress '__return_empty_string' with woocommerce_checkout_get_value WooCommerce filter hook to get empty values simply this way:

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




加载结帐页面时,这将清空所有结帐值。 / p>

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

该代码位于您的活动子主题(或主题)的functions.php文件中,或者在任何插件文件中。 / em>

The Code goes in functions.php file of your active child theme (or theme) or also in any plugin file.

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

This code is tested and works.


您应该重置Woocommerce设置>系统状态>工具中的所有现有会话,如果您的电子商务使用了缓存,还包括缓存。

还清空浏览器缓存和存储的数据。

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.

相关:仅清除Woocommerce中的某些结帐字段值

这篇关于删除WooCommerce结帐字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆