Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit bad3108

Browse files
committed
Hotfix #2405
1 parent d7fc2d9 commit bad3108

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

core/modules/checkout/components/Payment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const Payment = {
3232
},
3333
created () {
3434
if (!this.payment.paymentMethod || this.notInMethods(this.payment.paymentMethod)) {
35-
this.payment.paymentMethod = this.paymentMethods[0].code
35+
this.payment.paymentMethod = this.paymentMethods.length > 0 ? this.paymentMethods[0].code : 'cashondelivery'
3636
}
3737
},
3838
mounted () {

core/modules/checkout/store/payment/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import rootStore from '@vue-storefront/store'
66
export const paymentModule: Module<PaymentState, RootState> = {
77
namespaced: true,
88
state: {
9-
methods: [{"code":"cashondelivery","title":"Cash On Delivery","is_server_method":true}]
9+
methods: [{"code":"cashondelivery","title":"Cash On Delivery","is_server_method":false}]
1010
},
1111
mutations: {
1212
addMethod (state, paymentMethod) {

src/modules/payment-backend-methods/hooks/afterRegistration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function afterRegistration({ Vue, config, store, isServer }) {
2222
// Mount the info component when required.
2323
Vue.prototype.$bus.$on('checkout-payment-method-changed', (paymentMethodCode) => {
2424
let methods = store.state['payment-backend-methods'].methods
25-
if (methods !== null && methods.find(item => item.code === paymentMethodCode)) {
25+
if (methods !== null && methods.find(item => (item.code === paymentMethodCode && item.is_server_method === true))) {
2626
correctPaymentMethod = true
2727
} else {
2828
correctPaymentMethod = false

src/modules/payment-cash-on-delivery/hooks/afterRegistration.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ export function afterRegistration({ Vue, config, store, isServer }) {
1515
'cost': 0,
1616
'costInclTax': 0,
1717
'default': true,
18-
'offline': true
18+
'offline': true,
19+
'is_server_method': false
1920
}
2021
rootStore.dispatch('payment/addMethod', paymentMethodConfig)
2122

2223
// Mount the info component when required.
2324
Vue.prototype.$bus.$on('checkout-payment-method-changed', (paymentMethodCode) => {
24-
if (paymentMethodCode === 'cashondelivery') {
25+
let methods = store.state['payment-backend-methods'].methods
26+
let method = methods.find(item => (item.code === paymentMethodCode))
27+
if (paymentMethodCode === 'cashondelivery' && ((typeof method !== 'undefined' && !method.is_server_method) || typeof method === 'undefined') /* otherwise it could be a `payment-backend-methods` module */) {
2528
// Register the handler for what happens when they click the place order button.
2629
Vue.prototype.$bus.$on('checkout-before-placeOrder', placeOrder)
2730

0 commit comments

Comments
 (0)