mirror of
https://github.com/vercel/commerce.git
synced 2025-07-27 04:01:23 +00:00
Implement Shopify Provider
This commit is contained in:
20
framework/shopify/cart/utils/checkout-create.ts
Normal file
20
framework/shopify/cart/utils/checkout-create.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
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
|
Reference in New Issue
Block a user