Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Checkout - billing address validation

DanielŻuławskida18483722c6
diff --git a/src/Web/Grand.Web/Views/Checkout/Start.cshtml b/src/Web/Grand.Web/Views/Checkout/Start.cshtml
index 402fad473..fc2279363 100644
--- a/src/Web/Grand.Web/Views/Checkout/Start.cshtml
+++ b/src/Web/Grand.Web/Views/Checkout/Start.cshtml
@@ -92,14 +92,14 @@
<b-collapse id="opc-billing" @if (!Model.ShippingRequired) { <text> visible </text> } accordion="my-accordion" role="tabpanel" appear>
<div class="card-body">
<validation-observer v-slot="{ handleSubmit }">
- <form id="co-billing-form" action="" v-on:submit.prevent="handleSubmit()">
+ <form id="co-billing-form" action="" v-on:submit.prevent="handleSubmit(vmorder.formCheckoutSubmit)">
<div id="checkout-billing-load">
@if (Model.ShippingRequired)
{
<partial name="_BillingAddress" model="Model" />
}
else
- {
+ {
<partial name="_BillingWithoutShipping" model="Model.BillingAddress" />
}
</div>
@@ -108,7 +108,7 @@
</validation-observer>
<div class="col-12 buttons py-1 mt-3 px-0" id="billing-buttons-container">
<a class="btn btn-secondary" id="back-billing" href="#" onclick="vmorder.Checkout.back(); return false; ">@Loc["Common.Back"]</a>
- <input type="button" title="@Loc["Common.Continue"]" class="btn btn-info new-address-next-step-button" onclick="vmorder.vBilling.save();" value="@Loc["Common.Continue"]" />
+ <input type="button" title="@Loc["Common.Continue"]" class="btn btn-info new-address-next-step-button" onclick="document.getElementById('opc-billing-submit').click()" value="@Loc["Common.Continue"]" />
<span class="please-wait" id="billing-please-wait" style="display: none;">@Loc["Common.LoadingNextStep"]</span>
</div>
</div>
diff --git a/src/Web/Grand.Web/Views/Checkout/_BillingWithoutShipping.cshtml b/src/Web/Grand.Web/Views/Checkout/_BillingWithoutShipping.cshtml
index 177324a8a..5838647f0 100644
--- a/src/Web/Grand.Web/Views/Checkout/_BillingWithoutShipping.cshtml
+++ b/src/Web/Grand.Web/Views/Checkout/_BillingWithoutShipping.cshtml
@@ -69,7 +69,7 @@
<script asp-location="Footer" asp-order="301">
document.addEventListener("DOMContentLoaded", function () {
if (document.getElementById("billing-address-select") == null) {
- document.querySelector('#billing-buttons-container .new-address-next-step-button').setAttribute('onclick', "vmorder.vBilling.save(); document.getElementById('opc-billing-submit').click()");
+ document.querySelector('#billing-buttons-container .new-address-next-step-button').setAttribute('onclick', "vmorder.BillingAddress = true; document.getElementById('opc-billing-submit').click()");
}
});
</script>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/public.checkout.js b/src/Web/Grand.Web/wwwroot/theme/script/public.checkout.js
index 7745e15ef..365805bcb 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/public.checkout.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/public.checkout.js
@@ -63,9 +63,15 @@ var vmorder = new Vue({
},
methods: {
formCheckoutSubmit() {
- vmorder.vShipping.save();
- vmorder.shippingAddressErrors = null;
- vmorder.billingAddressErrors = null;
+ if (vmorder.BillingAddress) {
+ vmorder.vBilling.save();
+ vmorder.shippingAddressErrors = null;
+ vmorder.billingAddressErrors = null;
+ } else {
+ vmorder.vShipping.save();
+ vmorder.shippingAddressErrors = null;
+ vmorder.billingAddressErrors = null;
+ }
},
setDisabled(e) {
var button = e.target;
@@ -316,7 +322,7 @@ var vmorder = new Vue({
document.querySelector('#shipping-new-address-form').style.display = 'none';
}
} else {
- document.querySelector('#shipping-buttons-container .new-address-next-step-button').setAttribute('onclick', "vmorder.vShipping.save();");
+ document.querySelector('#shipping-buttons-container .new-address-next-step-button').setAttribute('onclick', "document.getElementById('opc-shipping-submit').click()");
document.querySelector('#shipping-new-address-form').style.display = 'none';
}
}
@@ -364,7 +370,7 @@ var vmorder = new Vue({
}).then(function (response) {
if (response.data.goto_section !== undefined) {
if (!(response.data.update_section.name == "shipping")) {
- document.querySelector('#back-' + response.data.goto_section).setAttribute('onclick', 'document.querySelector("#button-shipping").click(); vmorder.Billing = false;');
+ document.querySelector('#back-' + response.data.goto_section).setAttribute('onclick', 'document.querySelector("#button-shipping").click(); vmorder.BillingAddress = false;');
vmorder.vShipping.nextStep(response);
}
}
@@ -413,7 +419,7 @@ var vmorder = new Vue({
vmorder.BillingNewAddressPreselected = true;
if (document.querySelector('#billing-new-address-form'))
document.querySelector('#billing-new-address-form').style.display = 'block';
- document.querySelector('#billing-buttons-container .new-address-next-step-button').setAttribute('onclick', "vmorder.vBilling.save(); document.getElementById('opc-billing-submit').click()");
+ document.querySelector('#billing-buttons-container .new-address-next-step-button').setAttribute('onclick', "vmorder.BillingAddress = true; document.getElementById('opc-billing-submit').click()");
} else {
vmorder.BillingNewAddressPreselected = false;
@@ -878,15 +884,15 @@ var vmorder = new Vue({
},
BillingAddress: function () {
setTimeout(function () {
- if (document.getElementById("billing-address-select").value == '') {
- document.querySelector('#billing-buttons-container .new-address-next-step-button').setAttribute('onclick', "vmorder.vBilling.save(); document.getElementById('opc-billing-submit').click()");
+ if (document.getElementById("billing-address-select")) {
+ document.querySelector('#billing-buttons-container .new-address-next-step-button').setAttribute('onclick', "vmorder.BillingAddress = true; document.getElementById('opc-billing-submit').click()");
}
}, 300);
},
vShipping: function () {
if (this.vShipping !== null) {
- if (document.querySelector("#shipping-address-select")) {
- vmorder.vShipping.newAddress(!document.querySelector('#shipping-address-select').value);
+ if (document.getElementById("shipping-address-select")) {
+ vmorder.vShipping.newAddress(!document.getElementById('shipping-address-select').value);
}
}
},