@model MiniShoppingCartModel

@using Nop.Core.Domain.Catalog

<div id="flyout-cart" class="flyout-cart">
    <div class="mini-shopping-cart">
        <div class="count">
            @if (Model.TotalProducts == 0)
            {
                @T("ShoppingCart.Mini.NoItems")
            }
            else
            {
                @Html.Raw(string.Format(T("ShoppingCart.Mini.ItemsText").Text, $"<a href=\"{Url.RouteUrl("ShoppingCart")}\">{string.Format(T("ShoppingCart.Mini.Items").Text, Model.TotalProducts)}</a>"))
            }
        </div>
        @if (Model.TotalProducts > 0)
        {
            <div class="items">
                @for (var i = 0; i < Model.Items.Count; i++)
                {
                    var item = Model.Items[i];
                    <div class="item @(i == 0 ? "first" : null)">
                        @if (Model.ShowProductImages)
                        {
                            <div class="picture">
                                <a href="@(Url.RouteUrl<Product>(new { SeName = item.ProductSeName }))" title="@item.Picture.Title">
                                    <img alt="@item.Picture.AlternateText" src="@item.Picture.ImageUrl" title="@item.Picture.Title" />
                                </a>
                            </div>
                        }
                        <div class="product">
                            <div class="name">
                                <a href="@(Url.RouteUrl<Product>(new { SeName = item.ProductSeName }))">@item.ProductName</a>
                            </div>
                            @if (!string.IsNullOrEmpty(item.AttributeInfo))
                            {
                                <div class="attributes">
                                    @Html.Raw(item.AttributeInfo)
                                </div>
                            }
                            <div class="price">@T("ShoppingCart.Mini.UnitPrice"): <span>@item.UnitPrice</span></div>
                            <div class="quantity">@T("ShoppingCart.Mini.Quantity"): <span>@item.Quantity</span></div>
                        </div>
                    </div>
                }
            </div>
            <div class="totals">@T("ShoppingCart.Totals.SubTotal"): <strong>@Model.SubTotal</strong></div>
            <div class="buttons">
                @if (Model.DisplayShoppingCartButton)
                {
                    <button type="button" class="button-1 cart-button" onclick="setLocation('@(Url.RouteUrl("ShoppingCart"))')">@T("ShoppingCart.Mini.ViewCart")</button>
                }
                @if (Model.DisplayCheckoutButton)
                {
                    var checkoutUrl = "";
                    if (Model.AnonymousCheckoutAllowed && Model.CurrentCustomerIsGuest)
                    {
                        checkoutUrl = Url.RouteUrl("LoginCheckoutAsGuest", new { returnUrl = Url.RouteUrl("ShoppingCart") });
                    }
                    else
                    {
                        checkoutUrl = Url.RouteUrl("Checkout");
                    }
                    <button type="button" class="button-1 checkout-button" onclick="setLocation('@checkoutUrl')">@T("Checkout.Button")</button>
                }
            </div>
        }
    </div>
</div>
