[B2BTEAM-3732] Forward priceToken on addToCart (Pricing Fallback V2) - #185
Draft
wender wants to merge 1 commit into
Draft
[B2BTEAM-3732] Forward priceToken on addToCart (Pricing Fallback V2)#185wender wants to merge 1 commit into
wender wants to merge 1 commit into
Conversation
Pricing Fallback V2: fetch the signed price (commertialOffer.PriceToken) in the search-graphql product queries and forward it as priceToken in the addToCart payload, so the Checkout can close the cart while the Pricing is unavailable. Covers AutocompleteBlock and CategoryBlock. TextAreaBlock and UploadBlock resolve SKUs through the app's own skuFromRefIds resolver, which has no access to the token, and are left for a follow-up. The token is only added to the payload when the search actually returns one, keeping the payload unchanged while the field is not exposed yet. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖 Please select which version do you want to release:
And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.
|
|
Beep boop 🤖 I noticed you didn't make any changes at the
In order to keep track, I'll create an issue if you decide now is not a good time
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do? *
Pricing Fallback V2 (B2BTEAM-3732): captures the signed price returned by the search (
items[].sellers[].commertialOffer.PriceToken) and forwards it aspriceTokenin theaddToCartpayload, so the Checkout can close the cart with that price even while the Pricing is unavailable.react/queries/product.gqlandreact/queries/productsByCategory.gqlnow requestcommertialOffer { PriceToken }undersellers.AutocompleteBlockcaptures the token of the default seller both ononSelect(single-SKU product) and onselectSku(SKU switch), and sends it oncallAddUnitToCart.CategoryBlockkeeps apriceTokensmap by SKU, filled when the quantity is set, and sends it oncallAddToCart.Two deliberate choices:
CategoryBlockthe seller sent to the cart may be thesellerDefaultor the first one in the list (pre-existing fallback), so the token is looked up by the already resolvedsellerIdinstead of assuming the default — otherwise we could sign the price of a different seller than the one added to the cart.priceTokenis only added to the payload when the search returns one (conditional spread). While the field is not exposed, the payload is exactly the same as today, and the same applies ifItemInputonvtex.checkout-graphqldoes not acceptpriceTokenyet.How to test it? *
Requires an account where
CommertialOffer.PriceTokenis exposed byvtex.search-graphqland the feature flag is enabled (e.g.storeframework).vtex linkthe app and open a page withquickorder.autocomplete.productquery response —sellers[].commertialOffer.PriceTokenshould be present.addToCartmutation payload — the item should carrypriceTokenalongsideid,quantityandseller.quickorder.category, including a product whose seller comes from the fallback (nosellerDefault), and confirm the token matches the seller that was sent.priceTokenin the payload.Describe alternatives you've considered, if any. *
Related to / Depends on *
Blocked — do not merge yet.
CommertialOffer.PriceTokenis not exposed onsearch-resolver/search-graphqlyet. Since the field is requested directly in the queries, on any account where it is missing the GraphQL validation rejects the whole document and the product lookup ofAutocompleteBlock/CategoryBlockstops working. This can only be merged once the field is exposed.Out of scope, to be handled in a follow-up:
TextAreaBlockandUploadBlockresolve SKUs through this app's ownskuFromRefIdsresolver (node/resolvers/search/index.ts), which relies onstockkeepingunitidsbyrefids+ Checkout simulation — neither returnsPriceToken. Covering them needs a Catalog Search API call innode, a new field onItemsSeller(graphql/types/Refids.graphql), a newoutbound-accesspolicy and propagation throughReviewBlock.Open question for the Checkout team: the token is valid for 30 minutes and cannot be renewed. In
CategoryBlockit is captured when the category is opened, so a user browsing for a long time may send an expired token. Worth confirming whether an expired token is ignored (falling back to the Pricing) or returns an error — in the latter case the search would have to be repeated before adding to the cart.