-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat(core-flows, dashboard, fulfillment, fulfillment-manual, utils, types): create shipping options with calculated prices #10495
Merged
+253
−53
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c8375ae
feat: create shipping options with calculated prices
fPolic 62d758e
feat: manual provider methods
fPolic 314a020
Merge branch 'develop' into feat/create-so-calculated-prices
fPolic a39291c
feat: handel update SO validation
fPolic a5d0eaf
feat: allow updating of shipping option price_type
fPolic a40db45
feat: admin disable SO price edit if calcualted type
fPolic 55e4f20
fix: remove log
fPolic 415841f
refactor: cleanup, add comment
fPolic f4cf11f
chore: add todo
fPolic a9cd404
Merge branch 'develop' into feat/create-so-calculated-prices
fPolic 69142c6
feat: remove prices if option is set to calculated
fPolic efc1750
Merge branch 'develop' into feat/create-so-calculated-prices
fPolic 7c572fd
Merge branch 'develop' into feat/create-so-calculated-prices
fPolic 1821b26
fix: typo
fPolic 2e2de63
Merge branch 'develop' into feat/create-so-calculated-prices
fPolic 174d2e2
fix: address feedback
fPolic bb3667c
Merge branch 'develop' into feat/create-so-calculated-prices
fPolic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
79 changes: 69 additions & 10 deletions
79
packages/core/core-flows/src/fulfillment/steps/validate-shipping-option-prices.ts
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
38 changes: 25 additions & 13 deletions
38
packages/core/types/src/workflow/fulfillment/create-shipping-options.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,45 @@ | ||
import { ShippingOptionDTO, ShippingOptionPriceType } from "../../fulfillment" | ||
import { ShippingOptionDTO } from "../../fulfillment" | ||
import { RuleOperatorType } from "../../common" | ||
|
||
export interface CreateShippingOptionsWorkflowInput { | ||
type CreateFlatRateShippingOptionPriceRecord = | ||
| { | ||
currency_code: string | ||
amount: number | ||
} | ||
| { | ||
region_id: string | ||
amount: number | ||
} | ||
|
||
type CreateFlatShippingOptionInputBase = { | ||
name: string | ||
service_zone_id: string | ||
shipping_profile_id: string | ||
data?: Record<string, unknown> | ||
price_type: ShippingOptionPriceType | ||
provider_id: string | ||
type: { | ||
label: string | ||
description: string | ||
code: string | ||
} | ||
prices: ( | ||
| { | ||
currency_code: string | ||
amount: number | ||
} | ||
| { | ||
region_id: string | ||
amount: number | ||
} | ||
)[] | ||
rules?: { | ||
attribute: string | ||
operator: RuleOperatorType | ||
value: string | string[] | ||
}[] | ||
} | ||
|
||
type CreateFlatRateShippingOptionInput = CreateFlatShippingOptionInputBase & { | ||
price_type: "flat" | ||
prices: CreateFlatRateShippingOptionPriceRecord[] | ||
} | ||
|
||
type CreateCalculatedShippingOptionInput = CreateFlatShippingOptionInputBase & { | ||
price_type: "calculated" | ||
} | ||
|
||
export type CreateShippingOptionsWorkflowInput = | ||
| CreateFlatRateShippingOptionInput | ||
| CreateCalculatedShippingOptionInput | ||
|
||
export type CreateShippingOptionsWorkflowOutput = ShippingOptionDTO[] |
47 changes: 30 additions & 17 deletions
47
packages/core/types/src/workflow/fulfillment/update-shipping-options.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,54 @@ | ||
import { RuleOperatorType } from "../../common" | ||
import { ShippingOptionPriceType } from "../../fulfillment" | ||
import { PriceRule } from "../../pricing" | ||
|
||
export interface UpdateShippingOptionsWorkflowInput { | ||
type UpdateFlatShippingOptionInputBase = { | ||
id: string | ||
name?: string | ||
service_zone_id?: string | ||
shipping_profile_id?: string | ||
data?: Record<string, unknown> | ||
price_type?: ShippingOptionPriceType | ||
provider_id?: string | ||
type?: { | ||
label: string | ||
description: string | ||
code: string | ||
} | ||
prices?: ( | ||
| { | ||
id?: string | ||
currency_code?: string | ||
amount?: number | ||
rules?: PriceRule[] | ||
} | ||
| { | ||
id?: string | ||
region_id?: string | ||
amount?: number | ||
rules?: PriceRule[] | ||
} | ||
)[] | ||
rules?: { | ||
attribute: string | ||
operator: RuleOperatorType | ||
value: string | string[] | ||
}[] | ||
} | ||
|
||
export type UpdateShippingOptionPriceRecord = | ||
| { | ||
id?: string | ||
currency_code?: string | ||
amount?: number | ||
rules?: PriceRule[] | ||
} | ||
| { | ||
id?: string | ||
region_id?: string | ||
amount?: number | ||
rules?: PriceRule[] | ||
} | ||
|
||
export type UpdateCalculatedShippingOptionInput = | ||
UpdateFlatShippingOptionInputBase & { | ||
price_type?: "calculated" | ||
} | ||
|
||
export type UpdateFlatRateShippingOptionInput = | ||
UpdateFlatShippingOptionInputBase & { | ||
price_type?: "flat" | ||
prices?: UpdateShippingOptionPriceRecord[] | ||
} | ||
|
||
export type UpdateShippingOptionsWorkflowInput = | ||
| UpdateFlatRateShippingOptionInput | ||
| UpdateCalculatedShippingOptionInput | ||
|
||
export type UpdateShippingOptionsWorkflowOutput = { | ||
id: string | ||
}[] |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
comment: we always create associated price set for a shipping option, both calculated and flat rate, to make the implementation of create and update flows simpler and more unified (e.g. we don't have to duplicate the logic of price set creation in the update flow if the option price type changes to "flat rate")