product page and cart finished

This commit is contained in:
thomas
2020-02-25 20:14:23 +01:00
parent ef8c22855f
commit bbca265dea
12 changed files with 198 additions and 115 deletions
+17 -15
View File
@@ -8,21 +8,23 @@ export default {
}
},
methods: {
addToCart (product, checkout) {
// add to cart
this.$store.dispatch('addItemToCart', product).then((item) => {
const lineItemsToAdd = {
variantId: item.variants[0].id,
quantity: 1
}
// Add an item to the checkout
this.$shopify.checkout.addLineItems(checkout.id, lineItemsToAdd).then((checkout) => {
this.$store.commit('setCheckout', checkout)
})
this.$buefy.toast.open({
message: 'Product added',
type: 'is-success'
})
addToCart (id, quantity) {
const lineItemsToAdd = {
variantId: id,
quantity
}
// Add an item to the checkout
this.$shopify.checkout.addLineItems(this.checkout.id, lineItemsToAdd).then((checkout) => {
this.$store.commit('setCheckout', checkout)
})
this.$buefy.toast.open({
message: 'Product added',
type: 'is-success'
})
},
deleteItem (id) {
this.$shopify.checkout.removeLineItems(this.checkout.id, id).then((checkout) => {
this.$store.commit('setCheckout', checkout)
})
}
}