This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
export * from './useCart'
|
||||
export * from './useCurrentProduct'
|
||||
export * from './useProduct'
|
||||
export * from './useProductsList'
|
||||
|
||||
19
composables/useCart.ts
Normal file
19
composables/useCart.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export const useCart = () => {
|
||||
const addToCart = (item: any) => {
|
||||
if (process.client) {
|
||||
localStorage.setItem('cart', JSON.stringify(item))
|
||||
}
|
||||
}
|
||||
|
||||
const getCart = () => {
|
||||
if (process.client) {
|
||||
return localStorage.getItem('cart')
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
addToCart,
|
||||
getCart,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user