fix: explain consent-suppressed attribution in Woo order lookup (1.8.16) - #65
Merged
Conversation
The Order Lookup diagnostics tool showed empty first_touch/last_touch with no explanation when marketing consent had been denied at checkout -- correct behavior by design, but self-diagnosing nothing. It now reads the order's checkout-time consent snapshot and surfaces an inline notice when that's why attribution is empty. Closes #44.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #44 by making the Order Lookup diagnostics tool self-diagnosing for the exact case that issue reported: an order with empty
first_touch/last_touchbecause marketing consent was denied when the event fired.includes/admin/traits/trait-admin-diagnostics-ajax.php(ajax_lookup_woo_order_trace()): reads the order's checkout-time consent snapshot (WooCommerce::CONSENT_META_KEY) and passes it through aslookup.consent_marketing(bool ornullif no snapshot was ever recorded, e.g. pre-consent-tracking orders).includes/admin/traits/trait-admin-pages.php(render_woo_order_lookup_results()): when a trace'sattribution.first_touch/attribution.last_touchare both empty andconsent_marketing === false, shows an inline notice explaining why, pointing at Settings → Delivery → Privacy & consent.Why the order-level consent meta and not the trace's own
payload.consent:build_trace_snapshot()doesn't passconsentinto the translator, so it falls back toConsent::get_state()— read from the current request's cookie at snapshot-build time. That's accurate for the purchase trace (built in the customer's own request — issue #44's case), but milestone traces built frommaybe_dispatch_order_milestone()can fire from wp-admin, cron, or REST, where there's no consent cookie at all, and a no-cookie read also resolves tomarketing: false. Keying the notice off that would false-positive on ordinary direct-traffic orders with consent granted. The order-level snapshot (_clicutcl_consent, written once at checkout insave_order_attribution()) is the actual buyer consent and doesn't have that failure mode.This is a read-only diagnostics change — no consent or attribution capture logic was touched.
Version bumped to 1.8.16 (
clicutcl.phpVersion header +CLICUTCL_VERSION), changelog entries added tochangelog.txtandreadme.txt.Stable taginreadme.txtintentionally left at 1.8.13 per the existing 3-version WordPress.org buffer policy — this ships to GitHub only for now.Draft comment for issue #44 (not posted — for Hugo to review/post after merge)
Test plan
ajax_lookup_woo_order_traceagainst an order with denied marketing consent at checkout and confirm the notice renders.🤖 Generated with Claude Code