Merge pull request #2456 from shubhwebkul/velocity-updated

checkout misc. bug fixes
This commit is contained in:
Jitendra Singh 2020-02-13 15:57:34 +05:30 committed by GitHub
commit 5a6549f7ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 20 deletions

View File

@ -204,23 +204,32 @@
let form = $(document).find('form[data-vv-scope=address-form]');
// validate that if all the field contains some value
var requiredField = ['first_name', 'last_name', 'email', 'address1', 'city', 'state', 'postcode', 'phone', 'country'];
if (form) {
form.find(':input').each((index, element) => {
let value = $(element).val();
let elementId = element.id;
requiredField.forEach(field => {
if (! this.address.billing[field]) {
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 (this.address.billing.use_for_shipping) {
if (this.address.shipping.address_id) {
isManualValidationFail = true;
}
} else {
if (! this.address.shipping[field]) {
isManualValidationFail = true;
}
}
});
}
}
if (!isManualValidationFail) {
@ -228,7 +237,6 @@
.then(result => {
if (result) {
document.body.style.cursor = 'wait';
if (scope == 'address-form') {
this.saveAddress();
document.body.style.cursor = 'default';
@ -239,7 +247,6 @@
document.body.style.cursor = 'wait';
this.savePayment();
}
this.isPlaceOrderEnabled = true;
} else {
this.isPlaceOrderEnabled = false;
@ -439,11 +446,13 @@
newBillingAddress: function() {
this.new_billing_address = true;
this.isPlaceOrderEnabled = false;
this.address.shipping.address_id = null;
},
newShippingAddress: function() {
this.new_shipping_address = true;
this.isPlaceOrderEnabled = false;
this.address.shipping.address_id = null;
},
backToSavedBillingAddress: function() {

View File

@ -88,6 +88,7 @@
class="ml0"
id="billing[use_for_shipping]"
name="billing[use_for_shipping]"
@change="validateForm('address-form')"
v-model="address.billing.use_for_shipping" />
<span class="ml-5">

View File

@ -4,14 +4,13 @@
@if (isset($shipping) && $shipping)
<div :class="`col-12 form-field mb30 ${errors.has('address-form.shipping[first_name]') ? 'has-error' : ''}`">
<label for="shipping[first_name]" class="mandatory">
<label for="shipping[first_name]" class="mandatory" style="width: unset;">
{{ __('shop::app.checkout.onepage.first-name') }}
</label>
<input
type="text"
class="control"
style="width: unset;"
v-validate="'required'"
id="shipping[first_name]"
name="shipping[first_name]"
@ -157,7 +156,6 @@
{{ __('shop::app.checkout.onepage.state') }}
</label>
<input
type="text"
class="control"
@ -176,6 +174,7 @@
class="control styled-select"
v-if="haveStates('shipping')"
v-model="address.shipping.state"
@change="validateForm('address-form')"
data-vv-as="&quot;{{ __('shop::app.checkout.onepage.state') }}&quot;">
<option value="">{{ __('shop::app.checkout.onepage.select-state') }}</option>
@ -184,7 +183,10 @@
@{{ state.default_name }}
</option>
</select>
<i v-if="haveStates('shipping')" class="select-icon rango-arrow-down"></i>
<div class="select-icon-container" v-if="haveStates('shipping')">
<i class="select-icon rango-arrow-down"></i>
</div>
<span class="control-error" v-if="errors.has('address-form.shipping[state]')">
@{{ errors.first('address-form.shipping[state]') }}