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

shop cart error #13

Open
sleemy1997 opened this issue Jul 30, 2018 · 1 comment
Open

shop cart error #13

sleemy1997 opened this issue Jul 30, 2018 · 1 comment

Comments

@sleemy1997
Copy link

first of all nice work.
after successful payment cart is cleared up but if you add new item than last bought item is in cart as well, every time you add new item in cart all last bought items stay there

@pburdette
Copy link

@sleemy1997 you can fix it by reworking the store a bit to use an array for the cart data structure vs an object.

Not sure where all she is referencing an object that will need to be replaced. But I have something like this in my store and it's working good. This has been a great resource, I'd be happy to rework the data structure and the components if @sdras would like.

    addItem(state, payload) {
      state.cartTotal+= payload.qty
      state.cart.push(payload)
    },

    removeCartItem(state, payload) {
      state.cartTotal-= payload.qty
      const cartItemPostion = state.cart.indexOf(payload)
      state.cart.splice(cartItemPostion, 1)
    },

    clearCartCount(state) {
      state.cartTotal = 0
    },

    clearCartContents(state) {
      state.cart = []
    }

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

2 participants