✨ Add product to cart from anywhere
Make a global function that adds a product to the current cart
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { cartId } from '$utils/stores/shop'
|
||||
import { addToCart } from '$utils/functions/shop'
|
||||
// Components
|
||||
import Button from '$components/atoms/Button.svelte'
|
||||
import Image from '$components/atoms/Image.svelte'
|
||||
|
||||
export let product: any
|
||||
export let location: { name: string, slug: string }
|
||||
export let image: any
|
||||
</script>
|
||||
@@ -33,6 +37,7 @@
|
||||
text="Add to cart"
|
||||
color="pinklight"
|
||||
size="xsmall"
|
||||
on:click={() => addToCart($cartId, product)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user