mirror of
https://github.com/vercel/commerce.git
synced 2025-07-03 19:51:22 +00:00
Allow guests to add to wishlist
This commit is contained in:
parent
bc15597be9
commit
9feeb87b8b
@ -37,6 +37,8 @@ const ProductCard: FC<Props> = ({
|
||||
className
|
||||
)
|
||||
|
||||
console.log(process.env.COMMERCE_PROVIDER)
|
||||
|
||||
return (
|
||||
<Link href={`/product/${product.slug}`}>
|
||||
<a className={rootClassName}>
|
||||
|
@ -41,7 +41,7 @@ const WishlistButton: FC<Props> = ({
|
||||
if (loading) return
|
||||
|
||||
// A login is required before adding an item to the wishlist
|
||||
if (!customer && process.env.COMMERCE_PROVIDER !== 'shopify') {
|
||||
if (!customer && !process.env.COMMERCE_WISHLISTFORGUESTS_ENABLED) {
|
||||
setModalView('LOGIN_VIEW')
|
||||
return openModal()
|
||||
}
|
||||
@ -57,7 +57,6 @@ const WishlistButton: FC<Props> = ({
|
||||
variantId: variant?.id!,
|
||||
})
|
||||
}
|
||||
|
||||
setLoading(false)
|
||||
} catch (err) {
|
||||
setLoading(false)
|
||||
|
@ -36,7 +36,6 @@ const WishlistCard: FC<Props> = ({ product }) => {
|
||||
|
||||
const handleRemove = async () => {
|
||||
setRemoving(true)
|
||||
|
||||
try {
|
||||
// If this action succeeds then there's no need to do `setRemoving(true)`
|
||||
// because the component will be removed from the view
|
||||
|
@ -2,15 +2,9 @@ import { useMemo } from 'react'
|
||||
import useCommerceCart, { UseCart } from '@commerce/cart/use-cart'
|
||||
|
||||
import { SWRHook } from '@commerce/utils/types'
|
||||
import getCartQuery from '../utils/queries/get-cart-query'
|
||||
import { GetCartHook } from '../types/cart'
|
||||
import {
|
||||
GetCartQuery,
|
||||
GetCartQueryVariables,
|
||||
QueryRoot,
|
||||
} from '@framework/schema'
|
||||
import { normalizeCart } from '@framework/utils'
|
||||
import setCheckoutUrlCookie from '@framework/utils/set-checkout-url-cookie'
|
||||
import { GetCartQueryVariables, QueryRoot } from '../schema'
|
||||
import { normalizeCart, getCartQuery, setCheckoutUrlCookie } from '../utils'
|
||||
|
||||
export default useCommerceCart as UseCart<typeof handler>
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
"provider": "shopify",
|
||||
"features": {
|
||||
"wishlist": true,
|
||||
"wishlistForGuests": true,
|
||||
"customerAuth": true,
|
||||
"search": true
|
||||
}
|
||||
|
@ -7,9 +7,6 @@ export function getError(errors: any[] | null, status: number) {
|
||||
|
||||
export async function getAsyncError(res: Response) {
|
||||
const data = await res.json()
|
||||
|
||||
console.log(data)
|
||||
|
||||
return getError(data.errors, res.status)
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ export { default as handleLogin, handleAutomaticLogin } from './handle-login'
|
||||
export { default as handleAccountActivation } from './handle-account-activation'
|
||||
export { default as throwUserErrors } from './throw-user-errors'
|
||||
export { default as getWishlistId } from './get-wisthlist-id'
|
||||
export { default as setCheckoutUrlCookie } from './set-checkout-url-cookie'
|
||||
|
||||
export * from './queries'
|
||||
export * from './mutations'
|
||||
|
@ -204,6 +204,7 @@ export function normalizeWishlist(
|
||||
variant?.image?.originalSrc || '/product-img-placeholder.svg',
|
||||
},
|
||||
],
|
||||
id,
|
||||
variants: variant?.id ? [{ id: variant?.id }] : [],
|
||||
amount: +variant?.priceV2?.amount,
|
||||
baseAmount: +variant?.compareAtPriceV2?.amount,
|
||||
|
Loading…
x
Reference in New Issue
Block a user