From c85813de37c82fac700b3784ecd109c39d0b2d18 Mon Sep 17 00:00:00 2001 From: "shubhammehrotra.symfony@webkul.com" Date: Thu, 13 Feb 2020 15:29:33 +0530 Subject: [PATCH] checkout updates --- .../views/shop/checkout/onepage.blade.php | 41 +++++++++++-------- .../checkout/onepage/customer-info.blade.php | 1 + .../onepage/customer-new-form.blade.php | 10 +++-- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php index 0c7f3769d..abb6f5544 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage.blade.php @@ -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() { diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage/customer-info.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage/customer-info.blade.php index da977fa6c..00181df37 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage/customer-info.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage/customer-info.blade.php @@ -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" /> diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage/customer-new-form.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage/customer-new-form.blade.php index 686fa8bb2..f82596ebc 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage/customer-new-form.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/checkout/onepage/customer-new-form.blade.php @@ -4,14 +4,13 @@ @if (isset($shipping) && $shipping)
-