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

Check error with duplicate cart #943

Merged
merged 6 commits into from
Aug 24, 2023
Merged

Conversation

matheusgnreis
Copy link
Member

Checklist

  • I've read and understood contributing guidelines;
  • If changing UI, I've tested on most common viewports, desktop and mobile devices;

Carrinho duplicado ao criar o pedido por um usuário não cadastrado.
Quando é criado o pedido, a função upsertCart é acionada no mesmo instante duas vezes. Em um primeiro momento, o completed e orders é undefined na rota confirmation. E ai cria um carrinho com completed false. No momento tempo, tem outro upsertCart com completed true e order. Dai cria o carrinho completed true, ficando 2 carrinhos criados, um como "abandonado" e outro como "convertido".
duplicated-cart

Como é na rota de criar o pedido de fato, não precisa criar um carrinho completado false.

image

@@ -82,6 +82,9 @@ const prepareCart = cart => {
} else {
url = '/carts.json'
method = 'POST'
if (window.storefrontApp && window.storefrontApp.router && window.storefrontApp.router.currentRoute && window.storefrontApp.router.currentRoute.name === 'confirmation' && completed === undefined && orders === undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

Essa linha aqui não tem como 🙃

Copy link
Member

Choose a reason for hiding this comment

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

Aliás o router tá aí https://github.com/ecomplus/storefront/blob/475b2957e5c67a17bb2392f9aaad52209a206578/%40ecomplus/storefront-app/src/router/index.js , você pode importá-lo, window.storefrontApp.** é pra ser usado pra fora dessa lib

Copy link
Member

Choose a reason for hiding this comment

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

Também não precisava checar esse && orders === undefined

@ecomplus/storefront-app/src/lib/sync-cart-to-api.js Outdated Show resolved Hide resolved
@leomp12 leomp12 merged commit d88825c into master Aug 24, 2023
5 of 6 checks passed
@leomp12 leomp12 deleted the check-error-with-duplicate-cart branch August 24, 2023 22:35
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