@model ShoppingCartModel.DiscountBoxModel
@if (Model.Display)
{
    <div class="coupon-box">
        <div class="title">
            <strong>@T("ShoppingCart.DiscountCouponCode")</strong>
        </div>
        <div class="hint">
            @T("ShoppingCart.DiscountCouponCode.Tooltip")
        </div>
        <div class="coupon-code">
            <input name="discountcouponcode" id="discountcouponcode" type="text" class="discount-coupon-code" aria-label="@T("ShoppingCart.DiscountCouponCode.Label")" />

            <button type="submit" name="applydiscountcouponcode" id="applydiscountcouponcode" class="button-2 apply-discount-coupon-code-button">@T("ShoppingCart.DiscountCouponCode.Button")</button>
        </div>
        @foreach (var message in Model.Messages)
        {
            <div class="@(Model.IsApplied ? "message-success" : "message-failure")">
                @message
            </div>
        }
        @foreach (var discount in Model.AppliedDiscountsWithCodes)
        {
            <div class="current-code">
                <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>
            </div>
        }
    </div>
    <script asp-location="Footer">
        $(document).ready(function () {
            $('#discountcouponcode').on('keydown', function (event) {
                if (event.keyCode == 13) {
                    $('#applydiscountcouponcode').trigger("click");
                    return false;
                }
            });
        });
    </script>
}