-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core-flows, dashboard, fulfillment, fulfillment-manual, utils, t…
…ypes): create shipping options with calculated prices (#10495) **What** - support creating SO with calculated price - support updating SO for both types of pricing - update `validateShippingOptionPricesStep` to handle both SO price_types - add the `validateShippingOptionsForPriceCalculation` method to `FulfillementModule` - add `canCalculate` and `calculatePrice` to fulfillment provider service service / interface / manual provider - disable SO pricing edit on Admin if SO price type is calculated --- CLOSES CMRC-776
- Loading branch information
Showing
13 changed files
with
253 additions
and
53 deletions.
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.