add product to checkout when added to cart

This commit is contained in:
thomas
2020-02-24 20:08:56 +01:00
parent 5ea6dcfaa1
commit ef8c22855f
6 changed files with 75 additions and 63 deletions
+5 -5
View File
@@ -5,7 +5,7 @@
<b-button
icon-left="cart"
class="mx-2"
@click="addToCart(product)"
@click="addToCart(product, checkout)"
>
Ajouter
</b-button>
@@ -20,14 +20,14 @@ export default {
mixins: [
cartMixins
],
async asyncData ({ params, $shopify }) {
const product = await $shopify.product.fetchByHandle(params.handle)
return { product }
},
data () {
return {
product: {}
}
},
async asyncData ({ params, $shopify }) {
const product = await $shopify.product.fetchByHandle(params.handle)
return { product }
}
}
</script>
+5 -7
View File
@@ -30,7 +30,7 @@
<b-button
type="is-primary"
icon-left="cart"
@click="addToCart(product)"
@click="addToCart(product, checkout)"
>
Buy
</b-button>
@@ -49,16 +49,14 @@ export default {
mixins: [
cartMixins
],
async asyncData ({ $shopify, store }) {
const products = await $shopify.product.fetchAll()
store.commit('setProducts', products)
},
computed: {
products () {
return this.$store.state.products
}
},
async asyncData ({ $shopify, store }) {
const products = await $shopify.product.fetchAll()
// eslint-disable-next-line no-console
console.log(products)
store.commit('setProducts', products)
}
}
</script>