Skip to content

Commit

Permalink
Fix handling same address checkbox in checkout - closes vuestorefront…
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeromanowicz committed Apr 16, 2019
1 parent 1272e64 commit 01023fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
19 changes: 12 additions & 7 deletions core/modules/checkout/components/Payment.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -37,7 +37,7 @@ export const Payment = {
}
},
mounted () {
if (!!this.payment.firstName) {
if (this.payment.firstName) {
this.initializeBillingAddress()
} else {
if (this.payment.company) {
Expand All @@ -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: {
Expand Down Expand Up @@ -123,15 +128,15 @@ export const Payment = {
},
useShippingAddress () {
if (this.sendToShippingAddress) {
this.copyShippingToBillingAddress();
this.copyShippingToBillingAddress()
this.sendToBillingAddress = false
this.generateInvoice = false
} else {
this.payment = this.$store.state.checkout.paymentDetails
this.generateInvoice = false
}
},
copyShippingToBillingAddress(){
copyShippingToBillingAddress () {
this.payment = {
firstName: this.shippingDetails.firstName,
lastName: this.shippingDetails.lastName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down

0 comments on commit 01023fc

Please sign in to comment.