feat(discount): add structured inapplicable discount codes#271
Open
tpindel wants to merge 1 commit intoUniversal-Commerce-Protocol:mainfrom
Open
feat(discount): add structured inapplicable discount codes#271tpindel wants to merge 1 commit intoUniversal-Commerce-Protocol:mainfrom
tpindel wants to merge 1 commit intoUniversal-Commerce-Protocol:mainfrom
Conversation
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.
Summary
Adds an
inapplicablearray to the discount extension'sdiscounts_object, providing structured rejection feedback when submitted discount codes cannot be applied.Currently, rejected codes are communicated via the generic
messages[]array. While functional, this requires platforms and agents to:messages[]to find discount-specific warningspathfield ($.discounts.codes[0]) to associate a rejection with a specific codeThe new
inapplicablearray provides a clean success/failure partition directly on the discounts object:Motivation
In agent-driven commerce, discount code application is a high-frequency operation. Agents try multiple codes, stack promotions, and negotiate on behalf of customers. They need programmatic, structured rejection feedback — not text parsing.
The current
messages[]model works well for human-facing warnings, but agents benefit from:applied[]for successes,inapplicable[]for failuresdiscount_code_*vocabularyThis is backward-compatible:
messages[]warnings for rejected codes continue to work.inapplicableis an additional, more structured channel.Design Details
New Type:
inapplicable_discount{ "code": "EXPIRED50", "reason": "discount_code_expired", "content": "Code 'EXPIRED50' expired on December 1st" }codereasoncontentReuses Existing Error Codes
The
reasonfield referenceserror_code.jsonand SHOULD use the standard discount error codes already documented in the spec:discount_code_expireddiscount_code_invaliddiscount_code_already_applieddiscount_code_combination_disalloweddiscount_code_user_not_logged_indiscount_code_user_ineligibleRelationship to messages[]
inapplicablecomplementsmessages[], it does not replace it:inapplicable[]entries ANDmessages[]warnings for rejected codes (for backward compatibility)inapplicablecan use it directly; older platforms continue usingmessages[]inapplicableis scoped to code-based rejections only; automatic discount issues remain inmessages[]Files
New Files (1)
inapplicable_discount.jsonsource/schemas/shopping/types/Modified Files (1)
discount.jsoninapplicablearray todiscounts_object, add$defsreferenceSpec Doc Update (1)
docs/specification/discount.mdType of change
Checklist