feat(cart): Shipping method adjustments (#6119)
This commit is contained in:
@@ -40,11 +40,15 @@ export interface AdjustmentLineDTO {
|
||||
updated_at: Date | string
|
||||
}
|
||||
|
||||
export interface ShippingMethodAdjustmentLineDTO extends AdjustmentLineDTO {
|
||||
export interface ShippingMethodAdjustmentDTO extends AdjustmentLineDTO {
|
||||
/**
|
||||
* The associated shipping method
|
||||
*/
|
||||
shipping_method: CartShippingMethodDTO
|
||||
/**
|
||||
* The ID of the associated shipping method
|
||||
*/
|
||||
shipping_method_id: string
|
||||
}
|
||||
|
||||
export interface LineItemAdjustmentDTO extends AdjustmentLineDTO {
|
||||
@@ -227,7 +231,7 @@ export interface CartShippingMethodDTO {
|
||||
*
|
||||
* @expandable
|
||||
*/
|
||||
adjustments?: ShippingMethodAdjustmentLineDTO[]
|
||||
adjustments?: ShippingMethodAdjustmentDTO[]
|
||||
|
||||
/**
|
||||
* When the shipping method was created.
|
||||
@@ -518,6 +522,14 @@ export interface FilterableShippingMethodProps
|
||||
shipping_option_id?: string | string[]
|
||||
}
|
||||
|
||||
export interface FilterableShippingMethodAdjustmentProps
|
||||
extends BaseFilterable<FilterableShippingMethodAdjustmentProps> {
|
||||
id?: string | string[]
|
||||
shipping_method_id?: string | string[]
|
||||
promotion_id?: string | string[]
|
||||
provider_id?: string | string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Remove this in favor of CartDTO, when module is released
|
||||
* @deprecated Use CartDTO instead
|
||||
|
||||
@@ -208,4 +208,22 @@ export interface UpdateShippingMethodDTO {
|
||||
adjustments?: CreateAdjustmentDTO[] | UpdateAdjustmentDTO[]
|
||||
}
|
||||
|
||||
export interface CreateShippingMethodAdjustmentDTO {
|
||||
shipping_method_id: string
|
||||
code: string
|
||||
amount: number
|
||||
description?: string
|
||||
promotion_id?: string
|
||||
provider_id?: string
|
||||
}
|
||||
|
||||
export interface UpdateShippingMethodAdjustmentDTO {
|
||||
id: string
|
||||
code?: string
|
||||
amount?: number
|
||||
description?: string
|
||||
promotion_id?: string
|
||||
provider_id?: string
|
||||
}
|
||||
|
||||
/** SHIPPING METHODS END */
|
||||
|
||||
@@ -2,29 +2,34 @@ import { FindConfig } from "../common"
|
||||
import { IModuleService } from "../modules-sdk"
|
||||
import { Context } from "../shared-context"
|
||||
import {
|
||||
CartAddressDTO,
|
||||
CartDTO,
|
||||
CartLineItemDTO,
|
||||
CartShippingMethodDTO,
|
||||
FilterableAddressProps,
|
||||
FilterableCartProps,
|
||||
FilterableLineItemAdjustmentProps,
|
||||
FilterableLineItemProps,
|
||||
FilterableShippingMethodProps,
|
||||
LineItemAdjustmentDTO,
|
||||
CartAddressDTO,
|
||||
CartDTO,
|
||||
CartLineItemDTO,
|
||||
CartShippingMethodDTO,
|
||||
FilterableAddressProps,
|
||||
FilterableCartProps,
|
||||
FilterableLineItemAdjustmentProps,
|
||||
FilterableLineItemProps,
|
||||
FilterableShippingMethodAdjustmentProps,
|
||||
FilterableShippingMethodProps,
|
||||
LineItemAdjustmentDTO,
|
||||
ShippingMethodAdjustmentDTO,
|
||||
} from "./common"
|
||||
import {
|
||||
CreateAddressDTO,
|
||||
CreateAdjustmentDTO,
|
||||
CreateCartDTO,
|
||||
CreateLineItemDTO,
|
||||
CreateLineItemForCartDTO,
|
||||
CreateShippingMethodDTO,
|
||||
UpdateAddressDTO,
|
||||
UpdateCartDTO,
|
||||
UpdateLineItemDTO,
|
||||
UpdateLineItemWithSelectorDTO,
|
||||
UpsertLineItemAdjustmentDTO
|
||||
CreateAddressDTO,
|
||||
CreateAdjustmentDTO,
|
||||
CreateCartDTO,
|
||||
CreateLineItemDTO,
|
||||
CreateLineItemForCartDTO,
|
||||
CreateShippingMethodAdjustmentDTO,
|
||||
CreateShippingMethodDTO,
|
||||
CreateShippingMethodForSingleCartDTO,
|
||||
UpdateAddressDTO,
|
||||
UpdateCartDTO,
|
||||
UpdateLineItemDTO,
|
||||
UpdateLineItemWithSelectorDTO,
|
||||
UpdateShippingMethodAdjustmentDTO,
|
||||
UpsertLineItemAdjustmentDTO,
|
||||
} from "./mutations"
|
||||
|
||||
export interface ICartModuleService extends IModuleService {
|
||||
@@ -126,7 +131,7 @@ export interface ICartModuleService extends IModuleService {
|
||||
listShippingMethods(
|
||||
filters: FilterableShippingMethodProps,
|
||||
config: FindConfig<CartShippingMethodDTO>,
|
||||
sharedContext: Context
|
||||
sharedContext?: Context
|
||||
): Promise<CartShippingMethodDTO[]>
|
||||
|
||||
addShippingMethods(
|
||||
@@ -137,7 +142,7 @@ export interface ICartModuleService extends IModuleService {
|
||||
): Promise<CartShippingMethodDTO[]>
|
||||
addShippingMethods(
|
||||
cartId: string,
|
||||
methods: CreateShippingMethodDTO[],
|
||||
methods: CreateShippingMethodForSingleCartDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<CartShippingMethodDTO[]>
|
||||
|
||||
@@ -189,4 +194,44 @@ export interface ICartModuleService extends IModuleService {
|
||||
selector: Partial<LineItemAdjustmentDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
|
||||
listShippingMethodAdjustments(
|
||||
filters: FilterableShippingMethodAdjustmentProps,
|
||||
config?: FindConfig<ShippingMethodAdjustmentDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingMethodAdjustmentDTO[]>
|
||||
|
||||
addShippingMethodAdjustments(
|
||||
data: CreateShippingMethodAdjustmentDTO[]
|
||||
): Promise<ShippingMethodAdjustmentDTO[]>
|
||||
addShippingMethodAdjustments(
|
||||
data: CreateShippingMethodAdjustmentDTO
|
||||
): Promise<ShippingMethodAdjustmentDTO>
|
||||
addShippingMethodAdjustments(
|
||||
cartId: string,
|
||||
data: CreateShippingMethodAdjustmentDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingMethodAdjustmentDTO[]>
|
||||
|
||||
setShippingMethodAdjustments(
|
||||
cartId: string,
|
||||
data: (
|
||||
| CreateShippingMethodAdjustmentDTO
|
||||
| UpdateShippingMethodAdjustmentDTO
|
||||
)[],
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingMethodAdjustmentDTO[]>
|
||||
|
||||
removeShippingMethodAdjustments(
|
||||
adjustmentIds: string[],
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
removeShippingMethodAdjustments(
|
||||
adjustmentId: string,
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
removeShippingMethodAdjustments(
|
||||
selector: Partial<ShippingMethodAdjustmentDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user