From 01023fc6accb42f54315b2f1c8ff9eac9ad0eb3a Mon Sep 17 00:00:00 2001 From: Luke Romanowicz Date: Tue, 16 Apr 2019 15:15:23 +0200 Subject: [PATCH] Fix handling same address checkbox in checkout - closes #2730 --- core/modules/checkout/components/Payment.ts | 19 ++++++++++++------- .../core/blocks/Checkout/Payment.vue | 1 - 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/modules/checkout/components/Payment.ts b/core/modules/checkout/components/Payment.ts index 68ca7b658d..d0eccdd81b 100644 --- a/core/modules/checkout/components/Payment.ts +++ b/core/modules/checkout/components/Payment.ts @@ -1,7 +1,7 @@ import { mapState, mapGetters } from 'vuex' import RootState from '@vue-storefront/core/types/RootState' -const Countries = require('@vue-storefront/i18n/resource/countries.json') import toString from 'lodash-es/toString' +const Countries = require('@vue-storefront/i18n/resource/countries.json') export const Payment = { name: 'Payment', @@ -37,7 +37,7 @@ export const Payment = { } }, mounted () { - if (!!this.payment.firstName) { + if (this.payment.firstName) { this.initializeBillingAddress() } else { if (this.payment.company) { @@ -46,14 +46,19 @@ export const Payment = { } this.changePaymentMethod() }, - watch:{ - shippingDetails:{ + watch: { + shippingDetails: { handler () { if (this.sendToShippingAddress) { - this.copyShippingToBillingAddress(); + this.copyShippingToBillingAddress() } }, deep: true + }, + sendToShippingAddress: { + handler () { + this.useShippingAddress() + } } }, methods: { @@ -123,7 +128,7 @@ export const Payment = { }, useShippingAddress () { if (this.sendToShippingAddress) { - this.copyShippingToBillingAddress(); + this.copyShippingToBillingAddress() this.sendToBillingAddress = false this.generateInvoice = false } else { @@ -131,7 +136,7 @@ export const Payment = { this.generateInvoice = false } }, - copyShippingToBillingAddress(){ + copyShippingToBillingAddress () { this.payment = { firstName: this.shippingDetails.firstName, lastName: this.shippingDetails.lastName, diff --git a/src/themes/default/components/core/blocks/Checkout/Payment.vue b/src/themes/default/components/core/blocks/Checkout/Payment.vue index 645d6e3a7c..d7e053e84b 100644 --- a/src/themes/default/components/core/blocks/Checkout/Payment.vue +++ b/src/themes/default/components/core/blocks/Checkout/Payment.vue @@ -37,7 +37,6 @@ class="col-xs-12 mb15" id="sendToShippingAddressCheckbox" v-model="sendToShippingAddress" - @click="useShippingAddress" v-if="!isVirtualCart" > {{ $t('Copy address data from shipping') }}