refactor: replace fetchShippingZones with supportedShippingDestinations#2370
Conversation
🦋 Changeset detectedLatest commit: 73d5e08 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Skipped Deployments
|
8d8c1dc to
5fa4b90
Compare
5fa4b90 to
73d5e08
Compare
| }); | ||
| }; | ||
|
|
||
| return data.site.settings?.shipping?.supportedShippingDestinations.countries ?? []; |
There was a problem hiding this comment.
Is this the right fallback (empty array)?
| export const getShippingCountries = cache(async () => { | ||
| const { data } = await client.fetch({ | ||
| document: SupportedShippingDestinationsQuery, | ||
| fetchOptions: { next: { revalidate } }, |
There was a problem hiding this comment.
Is this the right caching strategy? I wasn't sure if CAT influences the returned list of countries 🤔
There was a problem hiding this comment.
This look good to me IF customers don't have special shipping countries available to them (which I don't think so).
| export const getShippingCountries = cache(async () => { | ||
| const { data } = await client.fetch({ | ||
| document: SupportedShippingDestinationsQuery, | ||
| fetchOptions: { next: { revalidate } }, |
There was a problem hiding this comment.
This look good to me IF customers don't have special shipping countries available to them (which I don't think so).
| }); | ||
| }; | ||
|
|
||
| return data.site.settings?.shipping?.supportedShippingDestinations.countries ?? []; |
What/Why?
BIGCOMMERCE_ACCESS_TOKENenvironment variableTesting
Tested locally after changes:
supported-shipping-zones-after.mov
Migration
getShippingCountrieshas the same shape as theCountryBigCommerce GraphQL type, so you should be able to copy the graphql query fromcore/app/[locale]/(default)/cart/page-data.tsinto your project and replace the existinggetShippingCountriesmethod in there.data.geographyfrom thegetShippingCountriesinvocation incore/app/[locale]/(default)/cart/page.tsxcore/client/management/get-shipping-zones.tsassuming it is no longer referenced anywhere incore/@bigcommerce/catalyst-client@0.16.0or higher.xAuthTokenreferences inpackages/client/src/client.tsas well as thefetchShippingZonesmethod.xAuthTokenincore/client/index.ts