|
@@ -17,7 +17,6 @@ const getters = {
|
|
|
|
|
|
const mutations = {
|
|
|
pushProducts(state, payload) {
|
|
|
- // console.log(payload)
|
|
|
state.products = [...payload.products]
|
|
|
},
|
|
|
setSelectedProduct(state, payload) {
|
|
@@ -36,10 +35,16 @@ const actions = {
|
|
|
console.log(error)
|
|
|
})
|
|
|
},
|
|
|
- selectProduct({ commit }, payload) {
|
|
|
- commit('setSelectedProduct', {
|
|
|
- product: payload.data
|
|
|
- })
|
|
|
+ selectProduct({ commit, dispatch }, payload) {
|
|
|
+ if (payload.data.variant_count > 1) {
|
|
|
+ commit('setSelectedProduct', {
|
|
|
+ product: payload.data
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ dispatch('addToCart', {
|
|
|
+ product: payload.data.variants[0]
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
selectVariant({ commit, dispatch }, payload) {
|
|
|
commit('setSelectedProduct', {
|