product page and cart finished
This commit is contained in:
+17
-15
@@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user