Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkout attribute validation #304

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 15 additions & 29 deletions src/Web/Grand.Web/Views/ShoppingCart/CartSummary.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -187,42 +187,27 @@
else
{
<span class="read"
onclick="window.open('@Url.RouteUrl("PagePopup", new { SystemName = PageSeNameConstants.Conditionsofuse })', 450, 500, true)">
onclick="window.open('@Url.RouteUrl("PagePopup", new { SystemName = PageSeNameConstants.Conditionsofuse })', 450, 500, true)">
@Loc["Checkout.TermsOfService.Read"]
</span>
}
</b-form-checkbox>
<div class="alert alert-info my-2" v-show="vmorder.acceptTerms">@Loc["Checkout.TermsOfService.PleaseAccept"]</div>
</div>
<div class="checkout-buttons flex-sm-nowrap flex-wrap text-center mt-3">
<b-button type="button" id="checkoutasguest" v-if="vmorder.cart.ShowCheckoutAsGuestButton" @@click="vmorder.termsCheck(true)" variant="secondary" class="checkout-as-guest-button mx-sm-1 mx-0">
@Loc["Account.Login.CheckoutAsGuest"]
</b-button>
<b-button id="checkout" name="checkout" @@click="vmorder.termsCheck(false)" variant="info" class="checkout-button mt-sm-0 mt-1">
<span v-if="vmorder.cart.IsGuest">
@Loc["Checkout.Button.Login"]
</span>
<span v-else>
@Loc["Checkout.Button"]
</span>
</b-button>
</div>
</template>
<template v-else>
<div class="checkout-buttons flex-sm-nowrap flex-wrap text-center mt-3">
<b-button type="button" id="checkoutasguest" v-if="vmorder.cart.ShowCheckoutAsGuestButton" @@click="location.href='@Url.RouteUrl("Checkout")'" variant="secondary" class="checkout-as-guest-button mx-sm-1 mx-0">
@Loc["Account.Login.CheckoutAsGuest"]
</b-button>
<b-button id="checkout" name="checkout" @@click="document.querySelector('#shopping-cart-form').setAttribute('action', '@Url.RouteUrl("StartCheckout")');document.querySelector('#shopping-cart-form').submit();" variant="info" class="checkout-button mt-sm-0 mt-1">
<span v-if="vmorder.cart.IsGuest">
@Loc["Checkout.Button.Login"]
</span>
<span v-else>
@Loc["Checkout.Button"]
</span>
</b-button>
</div>
</template>
<div class="checkout-buttons flex-sm-nowrap flex-wrap text-center mt-3">
<b-button type="button" id="checkoutasguest" v-if="vmorder.cart.ShowCheckoutAsGuestButton" @@click="vmorder.CheckoutAndValidate(true)" variant="secondary" class="checkout-as-guest-button mx-sm-1 mx-0">
@Loc["Account.Login.CheckoutAsGuest"]
</b-button>
<b-button id="checkout" name="checkout" @@click="vmorder.CheckoutAndValidate(false)" variant="info" class="checkout-button mt-sm-0 mt-1">
<span v-if="vmorder.cart.IsGuest">
@Loc["Checkout.Button.Login"]
</span>
<span v-else>
@Loc["Checkout.Button"]
</span>
</b-button>
</div>
</template>
</template>
<div class="addon-buttons">
Expand All @@ -232,6 +217,7 @@
</div>
</div>
</div>
@await Component.InvokeAsync("Widget", new { widgetZone = "order_summary_content_below" })
</div>
</div>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
</template>
<template v-if="attribute.AttributeControlType == 1">
<label :for="'checkout_attribute_' + attribute.Id" class="sr-only">checkout_attribute_{{attribute.Id}}</label>
<select :id="'checkout_attribute_' + attribute.Id" class="form-control custom-select" onchange="checkoutAttributeChange()" :name="'checkout_attribute_' + attribute.Id">
<template v-if="attribute.IsRequired == false">
<option value="">---</option>
</template>
<select :id="'checkout_attribute_' + attribute.Id" class="form-control custom-select" onchange="checkoutAttributeChange()" :name="'checkout_attribute_' + attribute.Id">
<option value="">---</option>
<option v-for="attributeValue in attribute.Values" :selected="attributeValue.IsPreSelected" :value="attributeValue.Id">
<template v-if="attributeValue.PriceAdjustment == null">
{{attributeValue.Name}}
Expand Down
41 changes: 40 additions & 1 deletion src/Web/Grand.Web/Views/ShoppingCart/_ModelScript.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
termsCheck(guest) {
if (vmorder.cart.MinOrderSubtotalWarning == null) {
if (this.terms) {
if (guest) {
if (guest) {
window.location = '@Url.RouteUrl("Checkout")';
} else {
document.getElementById('shopping-cart-form').setAttribute('action', '@Url.RouteUrl("StartCheckout")');
Expand All @@ -75,6 +75,43 @@
vmorder.acceptTerms = true;
}
}
},
CheckoutAndValidate(guest) {
if (vmorder.cart.MinOrderSubtotalWarning == null) {
if (vmorder.cart.TermsOfServiceOnShoppingCartPage) {
if (this.terms) {
if (guest) {
vmorder.SafeNavigateToCheckout();
} else {
document.getElementById('shopping-cart-form').setAttribute('action', '@Url.RouteUrl("StartCheckout")');
document.getElementById('shopping-cart-form').submit();
}
vmorder.acceptTerms = false;
}
else {
vmorder.acceptTerms = true;
}
} else {
if (guest) {
vmorder.SafeNavigateToCheckout();
} else {
document.getElementById('shopping-cart-form').setAttribute('action', '@Url.RouteUrl("StartCheckout")');
document.getElementById('shopping-cart-form').submit();
}
}
}
},
SafeNavigateToCheckout(){
axios({
url: "/Checkout/Index",
method: 'get',
}).then(function(response) {
if (response.status === 200) {
window.location.href = response.request.responseURL;
}
}).catch(function(error) {
alert(error)
});
},
ApplyGiftVoucher(href) {
var bodyFormData = new FormData();
Expand Down Expand Up @@ -190,6 +227,7 @@
});
},
deleteitem(href) {
document.getElementById("app").setAttribute("v-cloak", true);
axios({
method: 'post',
url: href,
Expand All @@ -205,6 +243,7 @@
document.querySelector('.qty-indicator.cart-qty').innerText = response.data.totalproducts;
}
}).then(function () {
document.getElementById("app").removeAttribute("v-cloak", true);
this.vmorder.updateTotals();
});
},
Expand Down