Merge pull request #2460 from shubhwebkul/velocity-updated
WIP: misc. updates
This commit is contained in:
commit
5b032c2f5e
|
|
@ -201,35 +201,7 @@
|
||||||
var isManualValidationFail = false;
|
var isManualValidationFail = false;
|
||||||
|
|
||||||
if (scope == 'address-form') {
|
if (scope == 'address-form') {
|
||||||
let form = $(document).find('form[data-vv-scope=address-form]');
|
isManualValidationFail = this.validateAddressForm();
|
||||||
|
|
||||||
// validate that if all the field contains some value
|
|
||||||
if (form) {
|
|
||||||
form.find(':input').each((index, element) => {
|
|
||||||
let value = $(element).val();
|
|
||||||
let elementId = element.id;
|
|
||||||
|
|
||||||
if (value == ""
|
|
||||||
&& element.id != 'billing[company_name]'
|
|
||||||
&& element.id != 'shipping[company_name]'
|
|
||||||
) {
|
|
||||||
if (elementId.match('address_field_')) {
|
|
||||||
if (elementId == 'address_field_0') {
|
|
||||||
isManualValidationFail = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
isManualValidationFail = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// validate that if customer wants to use different shipping address
|
|
||||||
if (! this.address.billing.use_for_shipping) {
|
|
||||||
if (! this.address.shipping.address_id && ! this.new_shipping_address) {
|
|
||||||
isManualValidationFail = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isManualValidationFail) {
|
if (!isManualValidationFail) {
|
||||||
|
|
@ -237,17 +209,29 @@
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result) {
|
if (result) {
|
||||||
document.body.style.cursor = 'wait';
|
document.body.style.cursor = 'wait';
|
||||||
if (scope == 'address-form') {
|
|
||||||
this.saveAddress();
|
switch (scope) {
|
||||||
document.body.style.cursor = 'default';
|
case 'address-form':
|
||||||
} else if (scope == 'shipping-form') {
|
this.saveAddress();
|
||||||
document.body.style.cursor = 'wait';
|
document.body.style.cursor = 'default';
|
||||||
this.saveShipping();
|
break;
|
||||||
} else if (scope == 'payment-form') {
|
|
||||||
document.body.style.cursor = 'wait';
|
case 'shipping-form':
|
||||||
this.savePayment();
|
document.body.style.cursor = 'wait';
|
||||||
|
this.saveShipping();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'payment-form':
|
||||||
|
document.body.style.cursor = 'wait';
|
||||||
|
this.savePayment();
|
||||||
|
|
||||||
|
this.isPlaceOrderEnabled = ! this.validateAddressForm();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
this.isPlaceOrderEnabled = true;
|
|
||||||
} else {
|
} else {
|
||||||
this.isPlaceOrderEnabled = false;
|
this.isPlaceOrderEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
@ -257,6 +241,48 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
validateAddressForm: function () {
|
||||||
|
var isManualValidationFail = false;
|
||||||
|
|
||||||
|
let form = $(document).find('form[data-vv-scope=address-form]');
|
||||||
|
|
||||||
|
// validate that if all the field contains some value
|
||||||
|
if (form) {
|
||||||
|
form.find(':input').each((index, element) => {
|
||||||
|
let value = $(element).val();
|
||||||
|
let elementId = element.id;
|
||||||
|
|
||||||
|
if (value == ""
|
||||||
|
&& element.id != 'billing[company_name]'
|
||||||
|
&& element.id != 'shipping[company_name]'
|
||||||
|
) {
|
||||||
|
// check for multiple line address
|
||||||
|
if (elementId.match('billing_address_')
|
||||||
|
|| elementId.match('shipping_address_')
|
||||||
|
) {
|
||||||
|
// only first line address is required
|
||||||
|
if (elementId == 'billing_address_0'
|
||||||
|
|| elementId == 'shipping_address_0'
|
||||||
|
) {
|
||||||
|
isManualValidationFail = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isManualValidationFail = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate that if customer wants to use different shipping address
|
||||||
|
if (! this.address.billing.use_for_shipping) {
|
||||||
|
if (! this.address.shipping.address_id && ! this.new_shipping_address) {
|
||||||
|
isManualValidationFail = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return isManualValidationFail;
|
||||||
|
},
|
||||||
|
|
||||||
isCustomerExist: function() {
|
isCustomerExist: function() {
|
||||||
this.$validator.attach('email', 'required|email');
|
this.$validator.attach('email', 'required|email');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@
|
||||||
class="control"
|
class="control"
|
||||||
id="shipping_address_{{ $i }}"
|
id="shipping_address_{{ $i }}"
|
||||||
name="shipping[address1][{{ $i }}]"
|
name="shipping[address1][{{ $i }}]"
|
||||||
|
@change="validateForm('address-form')"
|
||||||
v-model="address.shipping.address1[{{$i}}]" />
|
v-model="address.shipping.address1[{{$i}}]" />
|
||||||
</div>
|
</div>
|
||||||
@endfor
|
@endfor
|
||||||
|
|
@ -513,8 +514,8 @@
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="billing[use_for_shipping]"
|
id="billing[use_for_shipping]"
|
||||||
name="billing[use_for_shipping]"
|
name="billing[use_for_shipping]"
|
||||||
@change="validateForm('address-form')"
|
v-model="address.billing.use_for_shipping"
|
||||||
v-model="address.billing.use_for_shipping" />
|
@change="setTimeout(() => validateForm('address-form'), 0)" />
|
||||||
|
|
||||||
<span class="ml-5">
|
<span class="ml-5">
|
||||||
{{ __('shop::app.checkout.onepage.use_for_shipping') }}
|
{{ __('shop::app.checkout.onepage.use_for_shipping') }}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue