Skip to content

Cart count issue #61

Open
Open
@Murodjon000

Description

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)
    }
  },

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions