commerce/framework/shopify/utils/set-checkout-url-cookie.ts
2021-08-10 14:41:56 +03:00

17 lines
444 B
TypeScript

import Cookies from 'js-cookie'
import { SHOPIFY_CART_URL_COOKIE, SHOPIFY_COOKIE_EXPIRE } from '../const'
export const setCheckoutUrlCookie = (checkoutUrl: string) => {
if (checkoutUrl) {
const oldCookie = Cookies.get(SHOPIFY_CART_URL_COOKIE)
if (oldCookie !== checkoutUrl) {
Cookies.set(SHOPIFY_CART_URL_COOKIE, checkoutUrl, {
expires: SHOPIFY_COOKIE_EXPIRE,
})
}
}
}
export default setCheckoutUrlCookie