Developer forum

Forum » Templates » Validation of vouchercode applied in the cart

Validation of vouchercode applied in the cart

Søren Jakobsen
Reply

Hi,

I'm trying to validate whether a vouchercode code is applied or not in checkout using GetLoop("ValidationErrors"). But I don't catch the error if ex. vouchercode isn't valid. Is validation of voucher codes included in the loop or do I need to use another approch?

@foreach (LoopItem errors in GetLoop("ValidationErrors")){

<div class="row">
<div class="col-md-12">
<div class="alert alert-danger" role="alert"><a href="javascript:document.getElementById('@errors.GetString("Ecom:Cart.ValidationError.FieldSystemName")').focus();"><b>@errors.GetString("Ecom:Cart.ValidationError.ErrorMessage")</b></a></div>
</div>
</div>
}

Vouchercode snippet:

<div class="form-body">
<div class="input-group" style="margin-bottom:20px;">
<input type="text" class="form-control" placeholder="@Translate("Enter voucher code", "Enter voucher code")" name="EcomOrderVoucherCode" id="EcomOrderVoucherCode" value="@GetString("Ecom:Order.Customer.VoucherCode")">
<span class="input-group-btn">
<a class="btn btn-dw-cart" type="submit" onclick="updateCart();">@Translate("Apply", "Apply")</a>
</span>
</div>
            <div>@voucherError</div>
</div>

Replies

 

You must be logged in to post in the forum