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

Using Blocks API to handle ECE cart requests #3780

Merged
merged 29 commits into from
Feb 4, 2025

Conversation

wjrosa
Copy link
Contributor

@wjrosa wjrosa commented Jan 28, 2025

Changes proposed in this Pull Request:

This PR expands the usage of the Blocks API (Cart API) to requests related to the cart itself: when adding items to the cart, retrieving items, removing, emptying, etc.

Testing instructions

  • Checkout and build this branch on your test environment (tweak/using-blocks-api-to-process-cart-requests)
  • Connect your Stripe account
  • Enable express payment methods (Google Pay, Apple Pay, Link)
  • As a shopper, purchase any products using the multiple ways available: product page, cart page (shortcode and block), checkout (shortcode and block), pay for order.
  • Confirm all flows are still working correctly

  • 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

@wjrosa wjrosa self-assigned this Jan 28, 2025
@wjrosa wjrosa marked this pull request as ready for review January 28, 2025 18:33
@wjrosa wjrosa requested review from a team and annemirasol and removed request for a team January 28, 2025 18:33
Copy link
Contributor

@annemirasol annemirasol left a comment

Choose a reason for hiding this comment

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

Great work! Found a shipping rates-related bug in shortcode cart/checkout:

  1. Clear your cookies.
  2. A a guest shopper, add a shippable product to cart.
  3. Go to shortcode cart or shortcode checkout, and click Google Pay.
  4. You will see this console error:
v3/?ver=3.0:1 Uncaught (in promise) IntegrationError: When `shippingAddressRequired` is true, you must specify `shippingRates`.

@wjrosa
Copy link
Contributor Author

wjrosa commented Jan 29, 2025

Great work! Found a shipping rates-related bug in shortcode cart/checkout:

  1. Clear your cookies.
  2. A a guest shopper, add a shippable product to cart.
  3. Go to shortcode cart or shortcode checkout, and click Google Pay.
  4. You will see this console error:
v3/?ver=3.0:1 Uncaught (in promise) IntegrationError: When `shippingAddressRequired` is true, you must specify `shippingRates`.

Good catch, Anne! I fixed it in 2af80a8 . Also added support for discounts.

@wjrosa wjrosa requested a review from annemirasol January 29, 2025 19:51
@annemirasol
Copy link
Contributor

Good catch, Anne! I fixed it in 2af80a8 . Also added support for discounts.

@wjrosa Weird, I am still getting the same error. I pulled the latest commits and re-built the source.

@wjrosa
Copy link
Contributor Author

wjrosa commented Jan 30, 2025

Good catch, Anne! I fixed it in 2af80a8 . Also added support for discounts.

@wjrosa Weird, I am still getting the same error. I pulled the latest commits and re-built the source.

Yeah, that's strange. I just tested again using the checkout, product, and cart pages. Anonymous and when logged in 🤔 . Did you try anything different from the steps you shared above?

@annemirasol
Copy link
Contributor

Good catch, Anne! I fixed it in 2af80a8 . Also added support for discounts.

@wjrosa Weird, I am still getting the same error. I pulled the latest commits and re-built the source.

Yeah, that's strange. I just tested again using the checkout, product, and cart pages. Anonymous and when logged in 🤔 . Did you try anything different from the steps you shared above?

Same steps.

Do you have shipping zones defined? I have this:

Screenshot 2025-01-30 at 10 06 43 AM

@wjrosa
Copy link
Contributor Author

wjrosa commented Jan 31, 2025

f4c102a

Right! The issue was specific to free shipping. I was able to reproduce it using your setup and fixed it in f4c102a

@annemirasol
Copy link
Contributor

annemirasol commented Jan 31, 2025

f4c102a

Right! The issue was specific to free shipping. I was able to reproduce it using your setup and fixed it in f4c102a

Fix verified! Thanks!

Found a different issue, this time with variable products.

  1. Go to the product page of a variable product, e.g. https://my-test-store.com/product/hoodie/
  2. Select a variation, e.g. for Hoodie, "Yes" or "No" for the Logo variation.
  3. Click Google Pay.
  4. See console errors, and notice how the Google Pay modal no longer lets you choose any address.

Note that there is a PHP notice seen when loading a variable product page. I've filed the issue in #3815. This notice is also present in develop and does not seem to be affecting ability to purchase the item via express payment.

Edited to include screenshot of console errors:
Screenshot 2025-01-31 at 10 27 45 AM

@wjrosa
Copy link
Contributor Author

wjrosa commented Feb 3, 2025

f4c102a

Right! The issue was specific to free shipping. I was able to reproduce it using your setup and fixed it in f4c102a

Fix verified! Thanks!

Found a different issue, this time with variable products.

  1. Go to the product page of a variable product, e.g. https://my-test-store.com/product/hoodie/
  2. Select a variation, e.g. for Hoodie, "Yes" or "No" for the Logo variation.
  3. Click Google Pay.
  4. See console errors, and notice how the Google Pay modal no longer lets you choose any address.

Note that there is a PHP notice seen when loading a variable product page. I've filed the issue in #3815. This notice is also present in develop and does not seem to be affecting ability to purchase the item via express payment.

Edited to include screenshot of console errors: Screenshot 2025-01-31 at 10 27 45 AM

Another great catch, Anne! 👍 Fixed it in 57a8a79. But it will just work with WC 9.7.0 since this part of the code was fixed here. So, upon merging this PR we may need to update the min. required WC version 🤔 (after waiting for the release).

@wjrosa
Copy link
Contributor Author

wjrosa commented Feb 4, 2025

@annemirasol to avoid blocking this PR, I decided to support the legacy version when variations are present in e123a0c. Let me know what you think 👀

Copy link
Contributor

@annemirasol annemirasol left a comment

Choose a reason for hiding this comment

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

to avoid blocking this PR, I decided to support the legacy version when variations are present in e123a0c. Let me know what you think 👀

Makes sense to me!

LGTM, no regression detected -- can complete purchases across different pages and using different payment methods! 🚢

@wjrosa wjrosa merged commit 6e1c603 into develop Feb 4, 2025
37 checks passed
@wjrosa wjrosa deleted the tweak/using-blocks-api-to-process-cart-requests branch February 4, 2025 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants