4
0
forked from crowetic/commerce
commerce/framework/shopify/cart/utils/checkout-create.ts
2021-02-04 13:23:44 +02:00

21 lines
504 B
TypeScript

import { SHOPIFY_CHECKOUT_COOKIE } from '@framework'
import checkoutCreateMutation from '@framework/utils/mutations/checkout-create'
import Cookies from 'js-cookie'
export const createCheckout = async (fetch: any) => {
const data = await fetch({
query: checkoutCreateMutation,
})
const checkout = data?.checkoutCreate?.checkout
const checkoutId = checkout?.id
if (checkoutId) {
Cookies.set(SHOPIFY_CHECKOUT_COOKIE, checkoutId)
}
return checkout
}
export default createCheckout