WooCommerce 订单元数据出现两次,一次带有下划线

WooCommerce Order meta data appears twice, once with underscore

我继承了一个基于 Woo-Commerce 的网站,我正在帮助一个非营利组织。它有一些我一直在修复的问题,但在他们编辑订单时发现了一些奇怪的错误。

好像所有的订单账单元数据标签都出现了两次,一次有下划线,一次没有,比如:

它们都包含客户在下订单时输入的值,但是如果您使用管理仪表板编辑帐单信息,下划线版本将被编辑,非下划线版本显示在自定义字段下。

这引起了一些混乱,我进行了相当多的搜索,但没有弄清楚原因。

如果有人有任何提示,请提前致谢,否则我将深入研究代码。

This is completely normal (and is not a bug).

由于 woocommerce 是一个 Wordpress 插件,它使用经典的用户数据 tables。但是 Orders 是一种自定义 post 类型,用于存储它们自己的用户数据。

In woocommerce as you can buy optionally without being registered, in that case the user data is only located on the Order postmeta data.

非注册用户首次购买(同时注册)数据保存在wp_usermeta ] 和 wp_postmeta tables.

当用户在购买任何东西之前注册时,数据将只注册在wp_usermeta table.


出于所有这些原因,用户数据有 2 个位置:

1) billing_first_name - 用户数据存储在 wp_usermeta table 和它是来自用户我的帐户页面(或来自用户编辑页面的后端)的 editable。

2) _billing_first_name (以下划线开头) - [=36=中存储的订单客户数据]wp_postmeta table 并且它只是 editable 通过管理员和商店经理的后端订单编辑页面。此数据显示在各地的订单和电子邮件通知中...
开头的下划线是避免此数据显示在自定义字段 Meta BOX(在订单编辑页面中)。

因此,订单可以具有与用户元数据中不同的帐单或运输字段,因为客户可以根据需要使用不同的 billing/shipping 数据。

Woocommerce needs both of them.
You should not make any change related to this, because it will be a real nightmare for you