Set email when creating order for express payment #2577
Merged
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.
Looks like the email was not set in
WooCommerceOrderCreator
, so for guest orders via express checkout with disabled confirmation it was remaining empty (for logged in customers it was setting email to the WP user email if empty during saving).So now setting the order email to the email from
WC()->customer
(retrievingemail
instead ofbilling_email
because it seems to be the WC behavior) , or to the PayPal payer email if empty.Steps to Test
GIVEN the PayPal shipping callback is enabled
AND the customer is a guest user
WHEN completing a PayPal express payment
THEN the WooCommerce order displays the buyer's PayPal email address in both the regular Email and PayPal Email fields
GIVEN the PayPal shipping callback is enabled
AND the customer is a logged-in user with a saved email address in their profile
WHEN completing a PayPal express payment
THEN the WooCommerce order displays the email address from the buyer's WooCommerce profile in the regular Email field
AND the PayPal account email address in the PayPal Email field