Your label doesn't work because you are redirecting to the current page before setting the label text. Instead of modifying the "btnNextStep_Click" method, you can add a custom validator to ensure the checkbox is checked (the following changes are for version 1.40).
1. Edit File:
Modules\CheckoutConfirm.ascx (included is the entire SelectButton DIV, I've commented out your label as it's not needed and added a CustomValidator. Just replace "
Your Error Message" with the message you want to show when customers click confirm without checking the box).
<div class="SelectButton">
<asp:Button runat="server" ID="btnNextStep" Text="<% $NopResources:Checkout.ConfirmButton %>"
OnClick="btnNextStep_Click" SkinID="ConfirmOrderNextStepButton" />
<asp:CheckBox ID="tcbox" Text=" " runat="server" Style="position: relative; top: 3px;" />
tick to confirm you have read and accepted our terms and conditions.
<%--
<asp:Label ID="tclabel" Font-Names="arial" Font-Size="10pt" runat="server" ForeColor="#CC0000" />
--%>
<asp:CustomValidator id="cvTCBox" runat="server" OnServerValidate="ValidateTCBox" Display="Static"
Font-Names="arial" Font-Size="10pt" ForeColor="#CC0000"
ErrorMessage="Your Error Message"
/>
</div>
2. Add to File:
Modules\CheckoutConfirm.ascx.cs
protected void ValidateTCBox(object source, ServerValidateEventArgs args)
{
args.IsValid = (tcbox.Checked == true);
}
3. In the same file, you can revert the btnNextStep_Click method to its default implementation:
protected void btnNextStep_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
try
{
PaymentInfo paymentInfo = this.PaymentInfo;
if (paymentInfo == null)
Response.Redirect("~/CheckoutPaymentInfo.aspx");
paymentInfo.BillingAddress = NopContext.Current.User.BillingAddress;
paymentInfo.ShippingAddress = NopContext.Current.User.ShippingAddress;
paymentInfo.CustomerLanguage = NopContext.Current.WorkingLanguage;
paymentInfo.CustomerCurrency = NopContext.Current.WorkingCurrency;
int orderID = 0;
string result = OrderManager.PlaceOrder(paymentInfo, NopContext.Current.User, out orderID);
this.PaymentInfo = null;
Order order = OrderManager.GetOrderByID(orderID);
if (!String.IsNullOrEmpty(result))
{
lError.Text = Server.HtmlEncode(result);
return;
}
else
{
PaymentManager.PostProcessPayment(order);
}
Response.Redirect("~/CheckoutCompleted.aspx");
}
catch (Exception exc)
{
LogManager.InsertLog(LogTypeEnum.OrderError, exc.Message, exc);
lError.Text = Server.HtmlEncode(exc.ToString());
}
}
}
You will need to recompile the solution and you may want to add a hyperlink to the terms and conditions (opening on a new page) so your customers know what they are accepting.
.