Fix addon checkout item field parsing#3106
Merged
Saksham-Sirohi merged 2 commits intofossasia:devfrom Mar 31, 2026
Merged
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts add-on checkout parsing to support both new item POST field names and legacy product names when extracting quantity and price for non-variation add-ons. Sequence diagram for updated add-on item field parsingsequenceDiagram
participant Request
participant AddOnsStep
participant POSTData
Request->>AddOnsStep: call _clean_category(form, category)
loop non_variation_addon_items
AddOnsStep->>AddOnsStep: build item_key
AddOnsStep->>AddOnsStep: build legacy_product_key
AddOnsStep->>POSTData: get item_key
POSTData-->>AddOnsStep: quantity_or_none
AddOnsStep->>POSTData: get legacy_product_key (fallback)
POSTData-->>AddOnsStep: legacy_quantity_or_none
AddOnsStep->>AddOnsStep: val = int(item_quantity or legacy_quantity or 0)
AddOnsStep->>POSTData: get item_key_price
POSTData-->>AddOnsStep: price_or_none
AddOnsStep->>POSTData: get legacy_product_key_price (fallback)
POSTData-->>AddOnsStep: legacy_price_or_none
AddOnsStep->>AddOnsStep: price = item_price or legacy_price or 0
AddOnsStep->>AddOnsStep: if val > 0: selected[i, None] = (val, price)
end
AddOnsStep-->>Request: cleaned category selections
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider extracting the repeated POST key lookup logic for
valandpriceinto a small helper to reduce duplication and make the precedence between_item_and_product_keys clearer. - It might be worth adding a brief code comment explaining that
_item_is the new format and_product_is kept for backward compatibility, so future maintainers understand why both are checked.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the repeated POST key lookup logic for `val` and `price` into a small helper to reduce duplication and make the precedence between `_item_` and `_product_` keys clearer.
- It might be worth adding a brief code comment explaining that `_item_` is the new format and `_product_` is kept for backward compatibility, so future maintainers understand why both are checked.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a mismatch between the add-on checkout form field names and the backend parsing logic in the presale checkout flow, so selected add-ons without variations are correctly recognized during checkout.
Changes:
- Update add-on quantity parsing to read
cp_<cartpos>_item_<item_id>(current template/test format). - Add backward-compatible fallback to the legacy
cp_<cartpos>_product_<item_id>field name for both quantity and free-price fields.
Sak1012
approved these changes
Mar 31, 2026
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 by Sourcery
Bug Fixes:
_item_and legacy_product_POST parameter formats for quantities and prices.