Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- take control over default broswer behavior and use saved category page size to load prev products - @gibkigonzo (#4201)
- update getCurrentCartHash after add/remove coupon - @gibkigonzo (#4220)
- update replaceNumberToString, so it will change ONLY numbers to string - @gibkigonzo (#4217)
- allow empty shipping methods in checkout - @gibkigozno (#4192)

## [1.11.2] - 2020.03.10

Expand Down
8 changes: 4 additions & 4 deletions core/modules/cart/store/actions/methodsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ const methodsActions = {
}
},
async updateShippingMethods ({ dispatch }, { shippingMethods }) {
if (shippingMethods.length > 0) {
const newShippingMethods = shippingMethods.map(method => ({ ...method, is_server_method: true }))
await dispatch('checkout/replaceShippingMethods', newShippingMethods, { root: true })
}
const newShippingMethods = shippingMethods
.map(method => ({ ...method, is_server_method: true }))
.filter(method => !method.hasOwnProperty('available') || method.available)
await dispatch('checkout/replaceShippingMethods', newShippingMethods, { root: true })
},
async syncShippingMethods ({ getters, rootGetters, dispatch }, { forceServerSync = false }) {
if (getters.canUpdateMethods && (getters.isTotalsSyncRequired || forceServerSync)) {
Expand Down
6 changes: 6 additions & 0 deletions core/modules/cart/test/unit/store/methodsActions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,10 @@ describe('Cart methodsActions', () => {
await (cartActions as any).updateShippingMethods(contextMock, { shippingMethods: [{ method: 1 }] });
expect(contextMock.dispatch).toBeCalledWith('checkout/replaceShippingMethods', [{ is_server_method: true, method: 1 }], { root: true })
})

it('doesn\'t add not available method', async () => {
const contextMock = createContextMock()
await (cartActions as any).updateShippingMethods(contextMock, { shippingMethods: [{ method: 1, available: false }] });
expect(contextMock.dispatch).toBeCalledWith('checkout/replaceShippingMethods', [], { root: true })
})
});