@inherits ViewModelTemplate<OrderListViewModel>
@using Dynamicweb.Rendering
@using Dynamicweb.Frontend
@using Dynamicweb.Ecommerce.Frontend
@using System.Globalization

@if(Model?.Orders?.Count > 0)
{
    if(Model.Orders.Select(o => o.Price.CurrencyCode).Distinct().Count() == 1)
    {
        string FormatTotal(double value, string currencyCode)
        {
            return Dynamicweb.Ecommerce.Services.Currencies.Format(Dynamicweb.Ecommerce.Services.Currencies?.GetCurrency(currencyCode) ?? Dynamicweb.Ecommerce.Common.Context.Currency, value);
        }
        <div class="fs-3 fw-bold text-price">
            @(FormatTotal(Model.Orders.Sum(o => o.Price.Price), Model.Orders.First().Price.CurrencyCode)) 
        </div>
    }
    else 
    {
        <div class="fs-3 fw-bold">-</div>
        <div class="fs-8 lh-sm text-muted">@Translate("Cannot display total in multiple currencies")</div>
    }
}
else 
{
    <div class="fs-3 fw-bold">-</div>
    <div class="fs-8 lh-sm text-muted">@Translate("No orders found")</div>
}