From 0118fc3a1a4aa9d32a9069529029b0e57c7b704d Mon Sep 17 00:00:00 2001 From: wpdev Date: Fri, 31 Jul 2026 10:18:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(fields):=20=E8=A3=9C=203=20=E5=80=8B=20WC?= =?UTF-8?q?=20runtime=20usermeta=20=E6=AC=84=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wc_last_active / wc_order_count_ / last_update 先前未註冊,會落回 wp_usermeta。三者皆由 WooCommerce 在 order/session 事件寫入,繁忙商店為高頻。 wc_order_count 走 Users::update_site_user_meta(),key 是 'wc_order_count' . '_' . rtrim( get_blog_prefix(), '_' );來源外掛寫死主站 形式 'wc_order_count_wp',multisite 子站(_wp_2)會漏接,這裡改用同一條運算式。 --- includes/class-tmdo-woocommerce.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/includes/class-tmdo-woocommerce.php b/includes/class-tmdo-woocommerce.php index e868a99..60df4df 100644 --- a/includes/class-tmdo-woocommerce.php +++ b/includes/class-tmdo-woocommerce.php @@ -583,6 +583,27 @@ final class TMDO_WooCommerce { 'type' => 'integer', 'label' => 'WC customer last order ID', ), + // WC runtime stats — written on order/session events, high-frequency + // on busy stores. Unregistered they land back in wp_usermeta. + array( + 'key' => 'wc_last_active', + 'type' => 'integer', + 'label' => 'WC last customer activity timestamp (Unix)', + ), + array( + // WooCommerce stores this per-site via Users::update_site_user_meta(), + // which appends the de-suffixed blog prefix ('wc_order_count' + '_wp' + // on the main site, '_wp_2' on a subsite). Compute it the same way + // rather than hardcoding the main-site form. + 'key' => 'wc_order_count_' . rtrim( $GLOBALS['wpdb']->get_blog_prefix(), '_' ), + 'type' => 'integer', + 'label' => 'WC order count for the current site (blog-aware key)', + ), + array( + 'key' => 'last_update', + 'type' => 'integer', + 'label' => 'WC customer last profile update timestamp (Unix)', + ), ) ); }