@model ShoppingCartModel.DiscountBoxModel
@if (Model.Display)
{
    <div class="coupon-box">
        <div class="title">
            <strong>@T("ShoppingCart.DiscountCouponCode")</strong>
        </div>
        <div class="cart-box-wrapper">
            <div class="hint">
                @T("ShoppingCart.DiscountCouponCode.Tooltip")
            </div>
            <input id="discountcouponcode" name="discountcouponcode" type="text" class="discount-coupon-code form-control" aria-label="@T("ShoppingCart.DiscountCouponCode.Label")" />&nbsp;
            <div class="discount-button">                
                <button type="submit" name="applydiscountcouponcode" id="applydiscountcouponcode" class="btn btn-default apply-discount-coupon-code-button">@T("ShoppingCart.DiscountCouponCode.Button")</button>
            </div>
            @foreach (var message in Model.Messages)
            {
                <div class="@(Model.IsApplied ? "message bg-success" : "message bg-danger")">
                    @message
                </div>
            }
            @foreach (var discount in Model.AppliedDiscountsWithCodes)
            {
                <div class="current-code">
                    <span class="applied-discount-code bg-success">
                        <span class="applied-discount-code">@string.Format(T("ShoppingCart.DiscountCouponCode.CurrentCode").Text, discount.CouponCode)</span>
                        @*empty value (little hack for FormValueExistsAttribute)*@
                        <button type="submit" name="removediscount-@discount.Id" class="remove-discount-button"></button>
                    </span>
                </div>
            }
        </div>
    </div>
<script asp-location="Footer">
    $(function () {
        $('#discountcouponcode').on('keydown', function (event) {
            if (event.keyCode == 13) {
                $('#applydiscountcouponcode').trigger("click");
                return false;
            }
        });
    });
</script>
}