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

feat: Consider order number from Checkout cookie #2592

Merged
merged 3 commits into from
Jan 13, 2025
Merged

Conversation

lucasfp13
Copy link
Contributor

@lucasfp13 lucasfp13 commented Dec 12, 2024

What's the purpose of this pull request?

This PR intends to change how we set the order number value on @faststore/api.

How it works?

Currently, we set the orderNumber value as the one we receive from client-side's storage context. After the order placed, Checkout generates a new order number (a new cart) and send it through the checkout.vtex.com cookie, but we do not update this value in the client-side's storage context until the validateCart resolver is executed (in the next ValidateCartMutation request). At the resolver, we always consider the order number's default value as being the one from client-side's storage context, not the updated one incoming from Checkout cookie.

So with this change we will consider the order number value from the checkout.vtex.com cookie as the default one, and change the other to be the fallback case.

How to test it?

The following store was created to validate the scenario with both storefront and checkout integrated on the same domain: https://teste.paladino.co/

Perform the entire checkout flow. The payment type should be with "money". After the order placed, check the orderFormId in checkout.vtex.com cookie, it should be a new one. When returning to the store also check the orderFormId from storage context, it should be the same as the cookie one. The cart should be empty too.

We need to check if, aside from the order placed flow, everything is working properly on a current store (use the starter.store preview, with the secure subdomain), add/remove items in the cart, clear the cart, go to checkout etc.

Starters Deploy Preview

vtex-sites/starter.store#647

@lucasfp13 lucasfp13 added the don't merge Blocked by some reason - - Please mention the reason label Dec 12, 2024
@lucasfp13 lucasfp13 self-assigned this Dec 12, 2024
Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
faststore-site ✅ Ready (Inspect) Visit Preview Jan 10, 2025 4:47pm

Copy link

codesandbox-ci bot commented Dec 12, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@lucasfp13 lucasfp13 changed the title [DO NOT MERGE] test: Order form ID from cookie feat: Consider orderFormId from Checkout cookie Jan 8, 2025
@lucasfp13 lucasfp13 changed the title feat: Consider orderFormId from Checkout cookie feat: Consider order number from Checkout cookie Jan 8, 2025
@lucasfp13 lucasfp13 removed the don't merge Blocked by some reason - - Please mention the reason label Jan 8, 2025
@lucasfp13 lucasfp13 marked this pull request as ready for review January 8, 2025 19:48
@lucasfp13 lucasfp13 requested a review from a team as a code owner January 8, 2025 19:48
@lucasfp13 lucasfp13 requested review from lariciamota and pedromtec and removed request for a team January 8, 2025 19:48
@lucasfp13 lucasfp13 force-pushed the test/ofid-from-cookie branch from ba6ccba to 5c99afb Compare January 8, 2025 20:05
Copy link
Contributor

@lariciamota lariciamota left a comment

Choose a reason for hiding this comment

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

LGTM!
Tested the checkout placing an order using https://teste.paladino.co/ and also tested the minicart and the navigation to checkout page using the preview https://sfj-1573732--starter.preview.vtex.app/

@lucasfp13 lucasfp13 merged commit b1198db into main Jan 13, 2025
9 checks passed
@lucasfp13 lucasfp13 deleted the test/ofid-from-cookie branch January 13, 2025 18:21
eduardoformiga pushed a commit that referenced this pull request Jan 15, 2025
## What's the purpose of this pull request?

This PR intends to change how we set the order number value on
`@faststore/api`.

## How it works?

Currently, we set the `orderNumber` value as the one we receive from
client-side's storage context. After the order placed, Checkout
generates a new order number (a new cart) and send it through the
`checkout.vtex.com` cookie, but we do not update this value in the
client-side's storage context until the `validateCart` resolver is
executed (in the next `ValidateCartMutation` request). At the resolver,
we always consider the order number's default value as being the one
from client-side's storage context, not the updated one incoming from
Checkout cookie.

So with this change we will consider the order number value from the
`checkout.vtex.com` cookie as the default one, and change the other to
be the fallback case.

## How to test it?

The following store was created to validate the scenario with both
storefront and checkout integrated on the same domain:
https://teste.paladino.co/

Perform the entire checkout flow. The payment type should be with
"money". After the order placed, check the `orderFormId` in
`checkout.vtex.com` cookie, it should be a new one. When returning to
the store also check the `orderFormId` from storage context, it should
be the same as the cookie one. The cart should be empty too.

We need to check if, aside from the order placed flow, everything is
working properly on a current store (use the `starter.store` preview,
with the secure subdomain), add/remove items in the cart, clear the
cart, go to checkout etc.

### Starters Deploy Preview

vtex-sites/starter.store#647

---------

Co-authored-by: Emerson Laurentino <[email protected]>
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.

4 participants