diff --git a/mixins/cartMixins.js b/mixins/cartMixins.js index 1495dc0..92e1b7c 100644 --- a/mixins/cartMixins.js +++ b/mixins/cartMixins.js @@ -1,16 +1,24 @@ export default { + computed: { + checkout () { + return this.$store.state.checkout + }, + cart () { + return this.$store.state.cart + } + }, methods: { addToCart (product, checkout) { // add to cart this.$store.dispatch('addItemToCart', product).then((item) => { - // eslint-disable-next-line no-console - console.log('item : ', item) const lineItemsToAdd = { variantId: item.variants[0].id, - quantity: item.count + quantity: 1 } // Add an item to the checkout - this.$shopify.checkout.addLineItems(checkout.id, lineItemsToAdd) + this.$shopify.checkout.addLineItems(checkout.id, lineItemsToAdd).then((checkout) => { + this.$store.commit('setCheckout', checkout) + }) this.$buefy.toast.open({ message: 'Product added', type: 'is-success' diff --git a/package-lock.json b/package-lock.json index d2aa0cc..98d2928 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11470,8 +11470,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -11508,8 +11507,7 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", @@ -11518,8 +11516,7 @@ }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -11622,8 +11619,7 @@ }, "inherits": { "version": "2.0.4", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -11633,7 +11629,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -11659,7 +11654,6 @@ "minipass": { "version": "2.9.0", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -11676,7 +11670,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -11757,8 +11750,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -11768,7 +11760,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -11844,8 +11835,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -11875,7 +11865,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -11893,7 +11882,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -11932,13 +11920,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.1.1", - "bundled": true, - "optional": true + "bundled": true } } }, diff --git a/pages/basket/index.vue b/pages/basket/index.vue index caeaad9..f9233ca 100644 --- a/pages/basket/index.vue +++ b/pages/basket/index.vue @@ -1,6 +1,40 @@