-
Notifications
You must be signed in to change notification settings - Fork 22
Implement missing fields for priceFromDraft function #310
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 06da874 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
src/repositories/product/helpers.ts
Outdated
: undefined, | ||
validFrom: draft.validFrom, | ||
validUntil: draft.validUntil, | ||
discounted: draft.discounted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Is this available on the draft? I think it is calculated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right! The discounted
field should be calculated by the platform when ProductDiscounts are applied, not directly mapped from the draft. I've removed this field mapping from the priceFromDraft
function. Commit: 4c83c8b
bd7421b
to
8f943fc
Compare
@copilot see my comment, and add a missing changeset file please |
Addressed the discounted field issue and added the missing changeset file. Commit: 4c83c8b |
@copilot that changelog item does not make sense |
You're right! Fixed the changeset to properly describe the main feature - implementing missing fields for the priceFromDraft function rather than just mentioning the discounted field removal. Commit: ca9c8f7 |
…ntil, discounted, tiers, custom Co-authored-by: mvantellingen <[email protected]>
…alculated Co-authored-by: mvantellingen <[email protected]>
Co-authored-by: mvantellingen <[email protected]>
7a0afce
to
06da874
Compare
The
priceFromDraft
function insrc/repositories/product/helpers.ts
was missing several important fields when converting aPriceDraft
to aPrice
object. This caused incomplete price objects to be created, missing key functionality like customer group targeting, validity periods, discounts, tiered pricing, and custom fields.Changes Made
CustomerGroupResourceIdentifier
toCustomerGroupReference
using the existinggetReferenceFromResourceIdentifier
helperDiscountedPriceDraft
toDiscountedPrice
with proper value conversion and ProductDiscount reference handlingPriceTierDraft[]
toPriceTier[]
with value conversion for quantity-based pricingCustomFieldsDraft
toCustomFields
using the existingcreateCustomFields
helperTesting
Added comprehensive unit tests in
src/repositories/product/helpers.test.ts
that verify:All existing tests continue to pass, ensuring no regressions.
Example Usage
Fixes #283.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.