-
Notifications
You must be signed in to change notification settings - Fork 69
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
feat: tokenized cart PRBs on PDPs #8644
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: +12.5 kB (+1%) Total Size: 1.26 MB
ℹ️ View Unchanged
|
@FangedParakeet RE order attribution data - I was able to fix it for this PRBs implementation in b42101d 😁 |
c6ea531
to
de28d7f
Compare
3ce38af
to
86991a1
Compare
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'm approving this PR, so that we can unblock related work, but I want to raise two problems that I encountered that hopefully we can resolve in a separate issue.
Firstly, all of the Store API endpoints require nonces and we collect the nonce to use in successive requests from the response header of our first request to create an anonymous cart. However, if we trigger the request to add an item to the cart before the request to create the anonymous cart has returned with the nonce, there is consequently no nonce in the request to add the product to the cart, this request fails, and--while the PRB still opens--you are prevented from completing the checkout, presumably because the cart is empty.
Thinking on this further, I am wondering if we just need to add an await
over here, to ensure that we have the nonce prior to continuing with the initialisation of the button. Thoughts?
Secondly, while testing on a blocks theme (I'm unsure if this is relevant), I was unable to complete a checkout, because I kept receiving the following error, originating from this line, where we add an item to the cart inside getCartData()
.
{
"code": "woocommerce_rest_invalid_nonce",
"message": "Nonce is invalid.",
"data": {
"status": 403
}
}
I found this more perplexing and don't really have an explanation for this one, since we do have a nonce in this request, it is generated immediately prior in the previous request, but for some reason, despite using the same credentials, the Store API is still unhappy.
Let's try to investigate and resolve these problems in a new issue, which might involve some sort of refactor of the PaymentRequestCartApi
and its usage. @frosso, if you wouldn't mind, please just link the new issue somewhere in this PR or the original issue and we can move on and continue with the other integrations in parallel. ✌️
Yes, I think that's the proper solution 👍 I didn't want to add the
Yeah, that's another weird quirk - I'll take a look 👍 |
@FangedParakeet found a solution here: #8840 (with explanation) |
Fixes #8526
Changes proposed in this Pull Request
Implementing the tokenized cart on PDPs, as a first step.
This is behind the
_wcpay_feature_tokenized_cart_prb
feature flag. Enable it in yourwp_options
.There are a few
TODO
s that have been inherited from the previous implementation or that will be useful for the future implementations.Testing instructions
Screen.Recording.2024-05-02.at.6.24.18.PM.mov
npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge