Skip to content

Commit

Permalink
fix: Order does not include resources after updating/creating a coupon
Browse files Browse the repository at this point in the history
  • Loading branch information
acasazza committed Jan 28, 2022
1 parent 749a0b3 commit 6ff1460
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/components/OrderContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,15 @@ const OrderContainer: FunctionComponent<OrderContainerProps> = (props) => {
dispatch,
order: state.order,
config,
include: state.include,
}),
removeGiftCardOrCouponCode: ({ codeType }: { codeType: OrderCodeType }) =>
defaultOrderContext['removeGiftCardOrCouponCode']({
codeType,
dispatch,
order: state.order,
config,
include: state.include,
}),
addResourceToInclude: (args: AddResourceToInclude) =>
defaultOrderContext['addResourceToInclude']({
Expand Down
8 changes: 6 additions & 2 deletions src/reducers/OrderReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,15 @@ export type SetGiftCardOrCouponCode = (args: {
dispatch?: Dispatch<OrderActions>
config?: CommerceLayerConfig
order?: Order
include?: string[]
}) => Promise<{ success: boolean }>

export const setGiftCardOrCouponCode: SetGiftCardOrCouponCode = async ({
code,
dispatch,
config,
order,
include,
}) => {
try {
if (config && order && code && dispatch) {
Expand All @@ -483,7 +485,7 @@ export const setGiftCardOrCouponCode: SetGiftCardOrCouponCode = async ({
id: order.id,
gift_card_or_coupon_code: code,
}
const orderUpdated = await sdk.orders.update(attributes)
const orderUpdated = await sdk.orders.update(attributes, { include })
dispatch({
type: 'setErrors',
payload: {
Expand All @@ -509,13 +511,15 @@ export type RemoveGiftCardOrCouponCode = (args: {
dispatch?: Dispatch<OrderActions>
config?: CommerceLayerConfig
order?: Order
include?: string[]
}) => Promise<{ success: boolean }>

export const removeGiftCardOrCouponCode: RemoveGiftCardOrCouponCode = async ({
codeType,
dispatch,
config,
order,
include,
}) => {
try {
if (config && order && dispatch) {
Expand All @@ -524,7 +528,7 @@ export const removeGiftCardOrCouponCode: RemoveGiftCardOrCouponCode = async ({
id: order.id,
[codeType]: '',
}
const orderUpdated = await sdk.orders.update(attributes)
const orderUpdated = await sdk.orders.update(attributes, { include })
dispatch({
type: 'setErrors',
payload: {
Expand Down

0 comments on commit 6ff1460

Please sign in to comment.