Answer the question
In order to leave comments, you need to log in
How to add a product to the cart in VUEX NUXT.JS, while adding a unique article to it?
PROBLEM: When adding a product to the cart, through mutation, I add the value *** to the product array in the "code" key - the generated article consisting of numbers. The article carries the model of the product and its color and size. That is, when choosing the same product but with a different color or size, the article changes. This is how it all happens, the article is generated when you click "ADD TO CART" and, together with the product itself, goes to the VUEX mutation, where it adds "article" to "code": "article", but if you stay on the page, and for example, twist the parameters of the same product further (well, for example, I want a sweatshirt in two sizes), then the article will change for the first one.
Here is the mutation code:
ADD_TO_CART(state, {post1, genCode}) {
post1.code = genCode
state.cart.push(post1)
},
this.$store.commit('cart/ADD_TO_CART', {post1, genCode})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question