Skip to content

feat: Shipping methods integration #2847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: feat/delivery-promise-1.2
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/api/src/platforms/vtex/clients/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const POLICY_KEY = 'trade-policy'
const REGION_KEY = 'region-id'
const FUZZY_KEY = 'fuzzy'
const OPERATOR_KEY = 'operator'
const SHIPPING_KEY = 'shipping'

const EXTRA_FACETS_KEYS = new Set([
POLICY_KEY,
Expand Down Expand Up @@ -148,6 +149,8 @@ export const IntelligentSearch = (
const regionFacet =
facets.find(({ key }) => key === REGION_KEY) ?? getRegionFacet()

const shippingFacet = facets.find(({ key }) => key === SHIPPING_KEY)

if (policyFacet !== null) {
withDefaultFacets.push(policyFacet)
}
Expand All @@ -156,6 +159,20 @@ export const IntelligentSearch = (
withDefaultFacets.push(regionFacet)
}

if (shippingFacet) {
const isPickupInPoint = shippingFacet.value === 'pickup-in-point'

if (isPickupInPoint) {
// Required additional parameter for the pickup-in-point method
withDefaultFacets.push({
...shippingFacet,
value: `${shippingFacet.value}/pickupPoint`,
})
} else {
withDefaultFacets.push(shippingFacet)
}
}

return withDefaultFacets
}

Expand Down
Loading