mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
update get product hook
This commit is contained in:
@@ -4,26 +4,27 @@ import {
|
||||
SHOPIFY_COOKIE_EXPIRE,
|
||||
} from '../../const'
|
||||
|
||||
import checkoutCreateMutation from '../../utils/mutations/checkout-create'
|
||||
// import checkoutCreateMutation from '../../utils/mutations/checkout-create'
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
export const checkoutCreate = async (fetch: any) => {
|
||||
const data = await fetch({
|
||||
query: checkoutCreateMutation,
|
||||
const cart = await fetch({
|
||||
query: 'cart',
|
||||
method: 'get',
|
||||
})
|
||||
|
||||
const checkout = data.checkoutCreate?.checkout
|
||||
const checkoutId = checkout?.id
|
||||
// const checkout = data.checkoutCreate?.checkout
|
||||
const checkoutId = cart?.id
|
||||
|
||||
if (checkoutId) {
|
||||
const options = {
|
||||
expires: SHOPIFY_COOKIE_EXPIRE,
|
||||
}
|
||||
Cookies.set(SHOPIFY_CHECKOUT_ID_COOKIE, checkoutId, options)
|
||||
Cookies.set(SHOPIFY_CHECKOUT_URL_COOKIE, checkout?.webUrl, options)
|
||||
}
|
||||
// if (checkoutId) {
|
||||
// const options = {
|
||||
// expires: SHOPIFY_COOKIE_EXPIRE,
|
||||
// }
|
||||
// Cookies.set(SHOPIFY_CHECKOUT_ID_COOKIE, checkoutId, options)
|
||||
// Cookies.set(SHOPIFY_CHECKOUT_URL_COOKIE, checkout?.webUrl, options)
|
||||
// }
|
||||
|
||||
return checkout
|
||||
return cart
|
||||
}
|
||||
|
||||
export default checkoutCreate
|
||||
|
Reference in New Issue
Block a user