diff --git a/framework/commercelayer/README.md b/framework/commercelayer/README.md index e77351a1d..dda2115e4 100644 --- a/framework/commercelayer/README.md +++ b/framework/commercelayer/README.md @@ -14,13 +14,17 @@ cp framework/commercelayer/.env.template .env.local Next, add the application credentials from your organization's application dashboard in `.env.local`. +## Content management + +Commerce Layer does not provide a collaborative environment to create and modify digital content but is CMS agnostic. It manages the transactional part of a sales channel and allows users to integrate with any CMS of their choice. This will enable businesses to utilize any content model, produce a better customer experience, outstand competition, and unleash creativity. For now, in this provider, we manage content locally, and in the future, you would be able to plug in any CMS of your choice instead. + ## Checkout -Demo checkout in this provider is powered by the open-sourced [Commmerce Layer Checkout](#) application that provides you with a PCI-compliant, PSD2-compliant, and production-ready checkout flow that lets you easily place orders through the Commerce Layer API. +Demo checkout in this provider is powered by the open-sourced [Commmerce Layer React Checkout](https://github.com/commercelayer/commercelayer-react-checkout) application that provides you with a PCI-compliant, PSD2-compliant, and production-ready checkout flow that lets you easily place orders through the Commerce Layer API. ## Future upgrades -For now, this provider supports a single market. In the future, we would add multi-market support by default so you can add more than one market from your organization to your application. Also, note that the demo is configured to serve a European market; hence you need to checkout with an address in Europe to get the available shipping methods. You can learn more about how to create markets in different categorized geographical regions for your organization [here](https://commercelayer.io/docs/data-model/markets-and-business-models). +For now, this provider supports a single market. In the future, we would add multi-market support by default so you can add more than one market from your organization to your application. Also, note that the demo is configured to serve a US market; hence you need to checkout with an address in the United States to get the available shipping methods. You can learn more about how to create markets in different categorized geographical regions for your organization [here](https://commercelayer.io/docs/data-model/markets-and-business-models). ## Contribute diff --git a/framework/commercelayer/api/endpoints/checkout/checkout.ts b/framework/commercelayer/api/endpoints/checkout/checkout.ts index 516909764..67d084952 100644 --- a/framework/commercelayer/api/endpoints/checkout/checkout.ts +++ b/framework/commercelayer/api/endpoints/checkout/checkout.ts @@ -8,11 +8,13 @@ const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({ }) => { let { orderId, accessToken } = req.query - const name = 'CL_TOKEN' + "="; - const cookiesArr = decodeURIComponent(accessToken = typeof accessToken === 'string' ? accessToken : '').split('; '); - cookiesArr.forEach(val => { - if (val.indexOf(name) === 0) accessToken = val.substring(name.length) - }) + const name = 'CL_TOKEN' + '=' + const cookiesArr = decodeURIComponent( + (accessToken = typeof accessToken === 'string' ? accessToken : '') + ).split('; ') + cookiesArr.forEach((val) => { + if (val.indexOf(name) === 0) accessToken = val.substring(name.length) + }) const { endpoint } = getCredentials() if (orderId && accessToken) { diff --git a/framework/commercelayer/api/endpoints/checkout/index.ts b/framework/commercelayer/api/endpoints/checkout/index.ts index 6ec2854bd..1edab2270 100644 --- a/framework/commercelayer/api/endpoints/checkout/index.ts +++ b/framework/commercelayer/api/endpoints/checkout/index.ts @@ -1,7 +1,6 @@ import { GetAPISchema, createEndpoint, CommerceAPI } from '@commerce/api' import checkoutEndpoint from '@commerce/api/endpoints/checkout' import type { CheckoutSchema } from '@commerce/types/checkout' -import type { CommercelayerAPI } from '../..' import checkout from './checkout' export const handlers: CheckoutEndpoint['handlers'] = { checkout } diff --git a/framework/commercelayer/api/operations/get-all-products.ts b/framework/commercelayer/api/operations/get-all-products.ts index c76fe0ff4..46d231dc3 100644 --- a/framework/commercelayer/api/operations/get-all-products.ts +++ b/framework/commercelayer/api/operations/get-all-products.ts @@ -53,4 +53,4 @@ export default function getAllProductsOperation({ } } return getAllProducts -} \ No newline at end of file +} diff --git a/framework/commercelayer/customer/use-customer.tsx b/framework/commercelayer/customer/use-customer.tsx index 14663c40a..79800b1df 100644 --- a/framework/commercelayer/customer/use-customer.tsx +++ b/framework/commercelayer/customer/use-customer.tsx @@ -8,7 +8,7 @@ export default useCustomer as UseCustomer export const handler: SWRHook = { fetchOptions: { - url: `${ENDPOINT}/api/customers/`, + url: `${ENDPOINT}/api/customers`, method: 'GET', }, async fetcher({ options, fetch }) { diff --git a/framework/commercelayer/index.tsx b/framework/commercelayer/index.tsx index 4df8e8786..f45f5411d 100644 --- a/framework/commercelayer/index.tsx +++ b/framework/commercelayer/index.tsx @@ -9,7 +9,7 @@ import { import useToken from './auth/use-token' export const commercelayerConfig: CommerceConfig = { - locale: 'en-us', + locale: 'en-US', cartCookie: 'session', } diff --git a/framework/commercelayer/provider.ts b/framework/commercelayer/provider.ts index 31f4a7534..436a10771 100644 --- a/framework/commercelayer/provider.ts +++ b/framework/commercelayer/provider.ts @@ -10,7 +10,7 @@ import { handler as useLogout } from './auth/use-logout' import { handler as useSignup } from './auth/use-signup' export const CommercelayerProvider = { - locale: 'en-us', + locale: 'en-US', cartCookie: 'session', fetcher: fetcher, token: '',