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

Cart count issue #61

Open
Murodjon000 opened this issue Jul 12, 2021 · 0 comments
Open

Cart count issue #61

Murodjon000 opened this issue Jul 12, 2021 · 0 comments

Comments

@Murodjon000
Copy link

Hi Sarah. While I was playing with your deployed site. I came across a little bug with the cart item count. If you add the item to your cart and if it is one try to decrease it then it disappears but when you add another item and in the cart page you will see the removed item which has a count of 0 but not disappearing. Here is the image screenshot https://res.cloudinary.com/dflkwvvnz/image/upload/v1626101578/scrnli_7_12_2021_7-52-44_PM_cikgtc.png
And I tried to fix it. Changing one line of code worked.

removeOneFromCart: (state, payload) => {
    const index = state.cart.findIndex((el) => el.id === payload.id)
    if (state.cart[index].count) {
      state.cart[index].count--
    }
    if (state.cart[index].count === 0) {
      state.cart.splice(index, 1)
    }
  },
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

No branches or pull requests

1 participant