Skip to content
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

Add WC Order Attribution data when processing Express Payment button requests #3107

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

james-allan
Copy link
Contributor

@james-allan james-allan commented May 1, 2024

Fixes #3022

Changes proposed in this Pull Request:

When a store has Order Attribution data enabled, payments via express payment buttons (Apple Pay, Google Pay etc) were missing this order attribution data.

This PR fixes that by:

  1. Including a <wc-order-attribution-inputs></wc-order-attribution-inputs> element where ever we include the express payment button.
    • This element will be automatically populated by WC core with the attribution data so we can stay at an arms length from the implementation layer.
  2. When we submit the AJAX request to process the express payment button, we submit whatever input elements were populated.
    • WC core will then pull the required fields out of the request and handle the attribution.

Testing instructions

  1. Enable Order attribution in WooCommerce → Settings → Advanced → Features

Screenshot 2024-05-01 at 10 53 20 AM

  1. Set up Stripe and enable Express Payment buttons. ⚠️ Remember you may need to add your domain to your stripe settings. See this doc: https://woocommerce.com/document/stripe/setup-and-configuration/express-checkouts/#apple-pay-requirements
  2. Purchase a product using Google Pay or Apple Pay.
  3. View the order in your admin dashboard and notice that there is no order attribution data.
Screenshot 2024-05-01 at 10 58 00 AM Screenshot 2024-05-01 at 10 58 27 AM
  1. Checkout this branch (fix/3022-order-attribution-express-buttons).
  2. Purchase a product using Apple Pay or Google Pay again.
  3. View the order in the dashboard. This time it should have attribution data.
Screenshot 2024-05-01 at 11 03 54 AM Screenshot 2024-05-01 at 11 03 28 AM

  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge

@james-allan james-allan marked this pull request as ready for review May 1, 2024 01:06
@james-allan james-allan requested review from a team and Mayisha and removed request for a team May 1, 2024 01:06
Copy link
Contributor

@Mayisha Mayisha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @james-allan 👋
Thanks for working on this.

The fix is working for shortcode cart and checkout, order attribution data is set properly.
But order attribution data is not set and still showing Unknown when I purchase from block cart or block checkout. I have used Google Pay for testing.

In the screenshot below, the second order is placed from shortcode checkout which has the origin Direct and the first order with origin Unknown is placed from block checkout.

2 orders

I think we need to make similar changes in https://github.com/woocommerce/woocommerce-gateway-stripe/blob/fix/3022-order-attribution-express-buttons/client/api/blocks.js#L68 to add the attribution data when using block cart/checkout.

@james-allan
Copy link
Contributor Author

The fix is working for shortcode cart and checkout, order attribution data is set properly.
But order attribution data is not set and still showing Unknown when I purchase from block cart or block checkout.

Good callout @Mayisha. I've tried to get the block checkout and cart to correctly include order attribution data, however, I'm not sure how to get WC core to either populate the <wc-order-attribution-inputs> elements. I've asked the WC Core folks if they are aware of ways to fix it in this block context. You can find that comment here: woocommerce/woocommerce#46309 (comment)

I'm going to put this one on hold for now until we can resolve that.

@james-allan james-allan added status: blocked The issue is blocked from progressing, waiting for another piece of work to be done. status: on hold The issue is currently not prioritized. labels May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: blocked The issue is blocked from progressing, waiting for another piece of work to be done. status: on hold The issue is currently not prioritized.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Express Checkouts break order attribution metadata
2 participants