-
Notifications
You must be signed in to change notification settings - Fork 851
CRM customer email identification #46667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRM customer email identification #46667
Conversation
When a logged-in WooCommerce customer uses a different email address on their order (e.g., wordpressjentest+different@gmail.com instead of their account email wordpressjentest@gmail.com), the CRM Contact box on the order page would fail to identify the existing CRM contact. This fix adds a helper method get_contact_id_from_order() that: 1. First attempts to find the CRM contact by billing email 2. Falls back to looking up the contact by WordPress user ID if the order belongs to a logged-in customer This ensures that the CRM Contact column in the orders list and the CRM Contact metabox on the order edit page correctly identify existing contacts even when customers use alternative email addresses. Fixes: JETCRM-62 Co-authored-by: adnan007.id <adnan007.id@gmail.com>
|
Cursor Agent can help with this pull request. Just |
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
…ling email Per Mike's recommendation: - First check if order has a WordPress customer (logged-in user) - If yes, use their account to find CRM contact (by WP user ID link, then by WP user email) - Only for guest orders, fall back to billing email This ensures logged-in customers are always identified by their account, even if they use a different billing email on their order. Co-authored-by: adnan007.id <adnan007.id@gmail.com>
Code Coverage SummaryCoverage changed in 1 file.
Coverage check overridden by
I don't care about code coverage for this PR
|
Simplify changelog entry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes an issue in WooSync where CRM contacts were not being correctly identified for orders when logged-in customers used a different billing email address than their WordPress account email.
Changes:
- Introduced a new helper method
get_contact_id_from_order()that prioritizes WordPress user ID over billing email for contact identification - Updated order list column and metabox rendering to use the new identification logic
- Added user-friendly UI feedback when no CRM contact is found
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| projects/plugins/crm/modules/woo-sync/includes/class-woo-sync-woo-admin-integration.php | Refactored contact identification logic to prioritize WordPress user account over billing email, and added a new helper method with comprehensive fallback logic |
| projects/plugins/crm/changelog/fix-woosync-contact-identification-by-wp-user | Added changelog entry documenting the bug fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4cf9d4511a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| $billing_email = $order->get_billing_email(); | ||
|
|
||
| // No billing email found, so render message and return. | ||
| if ( empty( $email ) ) { | ||
| if ( empty( $billing_email ) ) { | ||
| ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid early return for logged-in orders missing billing email
The metabox now uses get_contact_id_from_order(), but it still returns early when billing_email is empty. For logged‑in customers (or admin‑created orders) where the billing email is blank, the helper could still find the CRM contact via the WP user, yet this early return prevents it and shows the “save order to a customer with a billing email” message. This means the new identification logic won’t run in that scenario, so the metabox still fails to show the existing contact; consider only showing this message when there is no WP user and no billing email, or moving the billing‑email check into the guest‑order fallback.
Useful? React with 👍 / 👎.
manzoorwanijk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how CRM works, so I haven't tested the changes but the code looks good to me.
Fixes JETCRM-62
Proposed changes:
Fix: WooSync contact identification for orders with alternative emails
To identify a lead
Other information:
Jetpack product discussion
None
Does this pull request change what data or activity we track or use?
None
Testing instructions: