Skip to content

Commit 3bf07e2

Browse files
committed
feat: display dynamic estimate tag only when the shipping method is "delivery" (#3041)
Display dynamic estimate tag only when the shipping method is "delivery". Now IS returns the shipping method information for the tags object, so we can take this into consideration when displaying tags. For now, the IS update is only in a workspace, so you'll have to test it locally. Make sure that the `gabiru` workspace (`vtex login vendemo -w gabiru`) has the app `vtex.intelligent-search-api` installed in the version `0.58.0-beta.999` (`vtex ls`). Then, make some changes in the `packages/core/discovery.config.default.js` and `packages/api/src/platforms/vtex/clients/search/index.ts`: - Use the `vendemo` account, `BRA` country and `pt-BR` locale. - Add the workspace to the `base` URL in `index.ts`, it should be: ``` const base = `https://gabiru--${account}.${environment}.com.br/api/io` ``` After setting a postal code, go to the Power tools category, see that the product `BLACK+DECKER 20V MAX 5-1/2-Inch Cordless Circular Saw, Tool Only (BDCCS20B)` doesn't have a tag associated. <img width="1501" height="792" alt="Screenshot 2025-09-17 at 14 58 02" src="https://github.com/user-attachments/assets/a2c91587-3957-46e7-87ec-36f5d7e978f0" /> In the case of this req to IS, this product has only the pickup dynamic estimate, so we don't display it. <img width="1001" height="639" alt="Screenshot 2025-09-17 at 15 16 32" src="https://github.com/user-attachments/assets/9f45ec28-710f-482b-9a9a-8d5597872eb8" /> The other products in this query have the `delivery` estimate for `next-day` only, so it displays `Receive tomorrow`. <img width="1038" height="650" alt="Screenshot 2025-09-17 at 15 17 35" src="https://github.com/user-attachments/assets/583e34c0-0ad5-4f47-9a44-a9c3fec5e354" /> You can compare how it was before this change using this preview https://vendemo-cm9sir9v900u7z6llkl62l70j-g96ol5wx6.b.vtex.app/ - ⚠️ note that it'll show "Receive today" because there is the "pickup-in-point" tag for `same-day` and we weren't checking the shipping method. <img width="1492" height="771" alt="Screenshot 2025-09-17 at 15 20 50" src="https://github.com/user-attachments/assets/7c4092b4-8127-400e-aab6-85a1029a7b83" /> - [Jira task](https://vtex-dev.atlassian.net/browse/SFS-2858) - [Slack thread](https://vtex.slack.com/archives/C08SZUBMFDK/p1758113222697079)
1 parent 85c6c59 commit 3bf07e2

File tree

7 files changed

+31
-10
lines changed

7 files changed

+31
-10
lines changed

packages/api/src/__generated__/schema.ts

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/api/src/typeDefs/tag.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ type Tag {
1414
Tag name.
1515
"""
1616
name: String
17+
"""
18+
Tag shipping methods - "delivery" and/or "pickup-in-point".
19+
"""
20+
shippingMethods: [String]
1721
}

packages/core/@generated/gql.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import * as types from './graphql'
1212
* Therefore it is highly recommended to use the babel or swc plugin for production.
1313
*/
1414
const documents = {
15-
'\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n\t\tunitMultiplier\n\n isVariantOf {\n productGroupID\n name\n\t\t\tskuVariants {\n\t\t\t\tallVariantsByName\n\t\t\t\tactiveVariations\n\t\t\t\tslugsMap\n\t\t\t\tavailableVariations\n\t\t\t}\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n priceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n hasSpecifications\n\n unitMultiplier\n\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n allVariantProducts {\n name\n productID\n }\n }\n }\n\n advertisement {\n adId\n adResponseId\n }\n\n deliveryPromiseBadges {\n typeName\n }\n\n tags {\n typeName\n value\n name\n }\n }\n':
15+
'\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n\t\tunitMultiplier\n\n isVariantOf {\n productGroupID\n name\n\t\t\tskuVariants {\n\t\t\t\tallVariantsByName\n\t\t\t\tactiveVariations\n\t\t\t\tslugsMap\n\t\t\t\tavailableVariations\n\t\t\t}\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n priceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n hasSpecifications\n\n unitMultiplier\n\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n allVariantProducts {\n name\n productID\n }\n }\n }\n\n advertisement {\n adId\n adResponseId\n }\n\n deliveryPromiseBadges {\n typeName\n }\n\n tags {\n typeName\n value\n name\n shippingMethods\n }\n }\n':
1616
types.ProductSummary_ProductFragmentDoc,
1717
'\n fragment Filter_facets on StoreFacet {\n ... on StoreFacetRange {\n key\n label\n\n min {\n selected\n absolute\n }\n\n max {\n selected\n absolute\n }\n\n __typename\n }\n ... on StoreFacetBoolean {\n key\n label\n values {\n label\n value\n selected\n quantity\n }\n\n __typename\n }\n }\n':
1818
types.Filter_FacetsFragmentDoc,
19-
'\n fragment ProductDetailsFragment_product on StoreProduct {\n id: productID\n sku\n name\n gtin\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n\t\t\tskuVariants {\n activeVariations\n slugsMap\n availableVariations\n allVariantProducts {\n name\n productID\n }\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n tags {\n typeName\n value\n name\n }\n\n # Contains necessary info to add this item to cart\n ...CartProductItem\n }\n':
19+
'\n fragment ProductDetailsFragment_product on StoreProduct {\n id: productID\n sku\n name\n gtin\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n\t\t\tskuVariants {\n activeVariations\n slugsMap\n availableVariations\n allVariantProducts {\n name\n productID\n }\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n tags {\n typeName\n value\n name\n shippingMethods\n }\n\n # Contains necessary info to add this item to cart\n ...CartProductItem\n }\n':
2020
types.ProductDetailsFragment_ProductFragmentDoc,
2121
'\n fragment ProductComparisonFragment_product on StoreProduct {\n id: productID\n sku\n slug\n name\n gtin\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n allVariantProducts {\n name\n productID\n }\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n priceWithTaxes\n listPrice\n quantity\n listPriceWithTaxes\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n advertisement {\n adId\n adResponseId\n }\n\n hasSpecifications\n\n skuSpecifications {\n field {\n id\n name\n originalName\n }\n values {\n name\n id\n fieldId\n originalName\n }\n }\n\n specificationGroups {\n name\n originalName\n specifications {\n name\n originalName\n values\n }\n }\n }\n':
2222
types.ProductComparisonFragment_ProductFragmentDoc,
@@ -98,7 +98,7 @@ const documents = {
9898
* The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
9999
*/
100100
export function gql(
101-
source: '\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n\t\tunitMultiplier\n\n isVariantOf {\n productGroupID\n name\n\t\t\tskuVariants {\n\t\t\t\tallVariantsByName\n\t\t\t\tactiveVariations\n\t\t\t\tslugsMap\n\t\t\t\tavailableVariations\n\t\t\t}\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n priceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n hasSpecifications\n\n unitMultiplier\n\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n allVariantProducts {\n name\n productID\n }\n }\n }\n\n advertisement {\n adId\n adResponseId\n }\n\n deliveryPromiseBadges {\n typeName\n }\n\n tags {\n typeName\n value\n name\n }\n }\n'
101+
source: '\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n\t\tunitMultiplier\n\n isVariantOf {\n productGroupID\n name\n\t\t\tskuVariants {\n\t\t\t\tallVariantsByName\n\t\t\t\tactiveVariations\n\t\t\t\tslugsMap\n\t\t\t\tavailableVariations\n\t\t\t}\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n priceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n hasSpecifications\n\n unitMultiplier\n\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n allVariantProducts {\n name\n productID\n }\n }\n }\n\n advertisement {\n adId\n adResponseId\n }\n\n deliveryPromiseBadges {\n typeName\n }\n\n tags {\n typeName\n value\n name\n shippingMethods\n }\n }\n'
102102
): typeof import('./graphql').ProductSummary_ProductFragmentDoc
103103
/**
104104
* The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
@@ -110,7 +110,7 @@ export function gql(
110110
* The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
111111
*/
112112
export function gql(
113-
source: '\n fragment ProductDetailsFragment_product on StoreProduct {\n id: productID\n sku\n name\n gtin\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n\t\t\tskuVariants {\n activeVariations\n slugsMap\n availableVariations\n allVariantProducts {\n name\n productID\n }\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n tags {\n typeName\n value\n name\n }\n\n # Contains necessary info to add this item to cart\n ...CartProductItem\n }\n'
113+
source: '\n fragment ProductDetailsFragment_product on StoreProduct {\n id: productID\n sku\n name\n gtin\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n\t\t\tskuVariants {\n activeVariations\n slugsMap\n availableVariations\n allVariantProducts {\n name\n productID\n }\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n tags {\n typeName\n value\n name\n shippingMethods\n }\n\n # Contains necessary info to add this item to cart\n ...CartProductItem\n }\n'
114114
): typeof import('./graphql').ProductDetailsFragment_ProductFragmentDoc
115115
/**
116116
* The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.

packages/core/@generated/graphql.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,8 @@ export type StoreUserDetails = {
16461646
export type Tag = {
16471647
/** Tag name. */
16481648
name: Maybe<Scalars['String']['output']>
1649+
/** Tag shipping methods - "delivery" and/or "pickup-in-point". */
1650+
shippingMethods: Maybe<Array<Maybe<Scalars['String']['output']>>>
16491651
/** Tag type. */
16501652
typeName: Maybe<Scalars['String']['output']>
16511653
/** Tag value. */
@@ -2466,6 +2468,7 @@ export type ProductSummary_ProductFragment = {
24662468
typeName: string | null
24672469
value: string | null
24682470
name: string | null
2471+
shippingMethods: Array<string | null> | null
24692472
} | null> | null
24702473
}
24712474

@@ -2534,6 +2537,7 @@ export type ProductDetailsFragment_ProductFragment = {
25342537
typeName: string | null
25352538
value: string | null
25362539
name: string | null
2540+
shippingMethods: Array<string | null> | null
25372541
} | null> | null
25382542
}
25392543

@@ -2744,6 +2748,7 @@ export type ServerProductQueryQuery = {
27442748
typeName: string | null
27452749
value: string | null
27462750
name: string | null
2751+
shippingMethods: Array<string | null> | null
27472752
} | null> | null
27482753
}
27492754
}
@@ -3340,6 +3345,7 @@ export type ClientManyProductsQueryQuery = {
33403345
typeName: string | null
33413346
value: string | null
33423347
name: string | null
3348+
shippingMethods: Array<string | null> | null
33433349
} | null> | null
33443350
}
33453351
}>
@@ -3439,6 +3445,7 @@ export type ClientProductQueryQuery = {
34393445
typeName: string | null
34403446
value: string | null
34413447
name: string | null
3448+
shippingMethods: Array<string | null> | null
34423449
} | null> | null
34433450
}
34443451
}
@@ -3583,6 +3590,7 @@ export type ClientSearchSuggestionsQueryQuery = {
35833590
typeName: string | null
35843591
value: string | null
35853592
name: string | null
3593+
shippingMethods: Array<string | null> | null
35863594
} | null> | null
35873595
}>
35883596
}
@@ -3749,6 +3757,7 @@ export type ServerManyProductsQueryQuery = {
37493757
typeName: string | null
37503758
value: string | null
37513759
name: string | null
3760+
shippingMethods: Array<string | null> | null
37523761
} | null> | null
37533762
}
37543763
}>
@@ -3851,6 +3860,7 @@ export const ProductSummary_ProductFragmentDoc = new TypedDocumentString(
38513860
typeName
38523861
value
38533862
name
3863+
shippingMethods
38543864
}
38553865
}
38563866
`,
@@ -3974,6 +3984,7 @@ export const ProductDetailsFragment_ProductFragmentDoc =
39743984
typeName
39753985
value
39763986
name
3987+
shippingMethods
39773988
}
39783989
...CartProductItem
39793990
}
@@ -4363,7 +4374,7 @@ export const ServerCollectionPageQueryDocument = {
43634374
export const ServerProductQueryDocument = {
43644375
__meta__: {
43654376
operationName: 'ServerProductQuery',
4366-
operationHash: 'e44b22c5f9d76e2a793c6b458e413df77cb994ca',
4377+
operationHash: '25c3171426d4198928987b353128e07b3b231e69',
43674378
},
43684379
} as unknown as TypedDocumentString<
43694380
ServerProductQueryQuery,
@@ -4489,7 +4500,7 @@ export const ClientAllVariantProductsQueryDocument = {
44894500
export const ClientManyProductsQueryDocument = {
44904501
__meta__: {
44914502
operationName: 'ClientManyProductsQuery',
4492-
operationHash: '98fd98aa8f01fec43caa38edb25acdb51a5e3284',
4503+
operationHash: '64176fdd7b1e40af7ab37aa524a02ee4b2e3416f',
44934504
},
44944505
} as unknown as TypedDocumentString<
44954506
ClientManyProductsQueryQuery,
@@ -4507,7 +4518,7 @@ export const ClientProductGalleryQueryDocument = {
45074518
export const ClientProductQueryDocument = {
45084519
__meta__: {
45094520
operationName: 'ClientProductQuery',
4510-
operationHash: 'f6ba376af21671bf335c0d29aafa4613eff64c22',
4521+
operationHash: '40c2764fc7d46e0bc69e15db97951344f0b226b8',
45114522
},
45124523
} as unknown as TypedDocumentString<
45134524
ClientProductQueryQuery,
@@ -4534,7 +4545,7 @@ export const ClientProfileQueryDocument = {
45344545
export const ClientSearchSuggestionsQueryDocument = {
45354546
__meta__: {
45364547
operationName: 'ClientSearchSuggestionsQuery',
4537-
operationHash: '6a86749413979c8d2b79596d1d591ddb7d45984c',
4548+
operationHash: '3e3ebc4d4e4f88233d6c259aaa80be7994ee0b30',
45384549
},
45394550
} as unknown as TypedDocumentString<
45404551
ClientSearchSuggestionsQueryQuery,
@@ -4570,7 +4581,7 @@ export const ClientShippingSimulationQueryDocument = {
45704581
export const ServerManyProductsQueryDocument = {
45714582
__meta__: {
45724583
operationName: 'ServerManyProductsQuery',
4573-
operationHash: 'fc42af39b9aa685c0d952c641fa4cbd2c4a11397',
4584+
operationHash: '8a13c3eaac063c2d88383e40a3b0b5c9894103cf',
45744585
},
45754586
} as unknown as TypedDocumentString<
45764587
ServerManyProductsQueryQuery,

packages/core/src/components/product/ProductCard/ProductCard.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ export const fragment = gql(`
286286
typeName
287287
value
288288
name
289+
shippingMethods
289290
}
290291
}
291292
`)

packages/core/src/components/sections/ProductDetails/ProductDetails.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ export const fragment = gql(`
413413
typeName
414414
value
415415
name
416+
shippingMethods
416417
}
417418
418419
# Contains necessary info to add this item to cart

packages/core/src/sdk/deliveryPromise/useDeliveryPromise.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,9 @@ export function useDeliveryPromise({
667667
: deliveryPromiseTag === 'dynamic_estimate'
668668
? getDynamicEstimateLabel(
669669
productTags?.find(
670-
({ typeName }) => typeName === DYNAMIC_ESTIMATE_FACET_KEY
670+
({ typeName, shippingMethods }) =>
671+
typeName === DYNAMIC_ESTIMATE_FACET_KEY &&
672+
shippingMethods?.includes(DELIVERY_TYPE_DELIVERY)
671673
)?.value
672674
)
673675
: undefined

0 commit comments

Comments
 (0)