mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 15:36:58 +00:00
fix: Wishlist flow
This commit is contained in:
parent
5ce768866d
commit
6c060582ec
@ -6,11 +6,11 @@ export function emptyHook() {
|
|||||||
const localWishlist = localStorage.getItem('wishlist')
|
const localWishlist = localStorage.getItem('wishlist')
|
||||||
if (localWishlist) {
|
if (localWishlist) {
|
||||||
wishlist = JSON.parse(localWishlist)
|
wishlist = JSON.parse(localWishlist)
|
||||||
if (!wishlist.includes(options.variantId)) {
|
if (!wishlist.includes(options.productId)) {
|
||||||
wishlist.push(options.variantId)
|
wishlist.push(options.productId)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wishlist.push(options.variantId)
|
wishlist.push(options.productId)
|
||||||
}
|
}
|
||||||
localStorage.setItem('wishlist', JSON.stringify(wishlist))
|
localStorage.setItem('wishlist', JSON.stringify(wishlist))
|
||||||
return wishlist
|
return wishlist
|
||||||
|
@ -11,7 +11,7 @@ export function emptyHook(options?: Options) {
|
|||||||
wishlist = wishlist.filter((p: string) => p !== id)
|
wishlist = wishlist.filter((p: string) => p !== id)
|
||||||
}
|
}
|
||||||
localStorage.setItem('wishlist', JSON.stringify(wishlist))
|
localStorage.setItem('wishlist', JSON.stringify(wishlist))
|
||||||
return Promise.resolve()
|
return wishlist
|
||||||
}
|
}
|
||||||
|
|
||||||
return useEmptyHook
|
return useEmptyHook
|
||||||
|
@ -41,8 +41,9 @@ export function extendHook(
|
|||||||
const wishlist = JSON.parse(getWishlist)
|
const wishlist = JSON.parse(getWishlist)
|
||||||
const items = wishlist.map((wishlist: string) => {
|
const items = wishlist.map((wishlist: string) => {
|
||||||
const [product] = data.products.filter((p) => p.id === wishlist) as any
|
const [product] = data.products.filter((p) => p.id === wishlist) as any
|
||||||
|
const [variant] = product.variants
|
||||||
return {
|
return {
|
||||||
variant_id: wishlist,
|
variant_id: variant.id,
|
||||||
product_id: wishlist,
|
product_id: wishlist,
|
||||||
id: wishlist,
|
id: wishlist,
|
||||||
product,
|
product,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user