2022-07-18 20:51:53 +02:00
|
|
|
@using BTCPayServer.Plugins.PointOfSale.Models
|
|
|
|
@model BTCPayServer.Plugins.PointOfSale.Models.ViewPointOfSaleViewModel
|
2020-05-26 21:52:42 +02:00
|
|
|
@{
|
2023-01-30 09:23:49 +01:00
|
|
|
Layout = "PointOfSale/Public/_Layout";
|
2020-05-26 21:52:42 +02:00
|
|
|
var anyInventoryItems = Model.Items.Any(item => item.Inventory.HasValue);
|
|
|
|
}
|
|
|
|
|
2023-01-30 09:23:49 +01:00
|
|
|
<div class="container public-page-wrap flex-column">
|
|
|
|
<partial name="_StatusMessage" />
|
|
|
|
<partial name="_StoreHeader" model="(string.IsNullOrEmpty(Model.Title) ? Model.StoreName : Model.Title, Model.LogoFileId)" />
|
|
|
|
@if (!string.IsNullOrEmpty(Model.Description))
|
|
|
|
{
|
|
|
|
<div class="lead text-center">@Safe.Raw(Model.Description)</div>
|
|
|
|
}
|
|
|
|
<main class="flex-grow-1 justify-content-center align-self-center text-center mx-auto py-3">
|
|
|
|
<div class="card-deck mx-auto">
|
2022-07-22 15:41:14 +02:00
|
|
|
@for (var x = 0; x < Model.Items.Length; x++)
|
2020-05-26 21:52:42 +02:00
|
|
|
{
|
|
|
|
var item = Model.Items[x];
|
2021-10-11 12:46:05 +02:00
|
|
|
var buttonText = string.IsNullOrEmpty(item.BuyButtonText) ? item.Price.Type != ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType.Fixed ? Model.CustomButtonText : Model.ButtonText : item.BuyButtonText;
|
2023-01-30 09:23:49 +01:00
|
|
|
buttonText = buttonText.Replace("{0}", item.Price.Formatted).Replace("{Price}", item.Price.Formatted);
|
|
|
|
|
2021-06-06 13:44:54 +02:00
|
|
|
<div class="card px-0" data-id="@x">
|
2022-07-22 15:41:14 +02:00
|
|
|
@if (!string.IsNullOrWhiteSpace(item.Image))
|
2020-05-26 21:52:42 +02:00
|
|
|
{
|
|
|
|
<img class="card-img-top" src="@item.Image" alt="Card image cap" asp-append-version="true">
|
|
|
|
}
|
2021-04-10 18:38:57 -07:00
|
|
|
@{CardBody(item.Title, item.Description);}
|
2021-06-06 13:44:54 +02:00
|
|
|
<div class="card-footer bg-transparent border-0 pb-3">
|
2020-05-26 21:52:42 +02:00
|
|
|
@if (!item.Inventory.HasValue || item.Inventory.Value > 0)
|
|
|
|
{
|
2021-10-29 09:58:59 +02:00
|
|
|
@if (item.Price.Type != ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType.Topup)
|
2023-01-30 09:23:49 +01:00
|
|
|
{
|
|
|
|
<form method="post" asp-action="ViewPointOfSale" asp-route-appId="@Model.AppId" asp-antiforgery="false" data-buy>
|
|
|
|
<input type="hidden" name="choicekey" value="@item.Id" />
|
|
|
|
@{PayFormInputContent(item.BuyButtonText ?? Model.CustomButtonText, item.Price.Type, item.Price.Value, item.Price.Value);}
|
|
|
|
</form>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<form method="post" asp-action="ViewPointOfSale" asp-route-appId="@Model.AppId" asp-antiforgery="false">
|
|
|
|
<input type="hidden" name="requiresRefundEmail" value="@Model.RequiresRefundEmail.ToString()" />
|
|
|
|
<button type="submit" name="choiceKey" class="js-add-cart btn btn-primary" value="@item.Id">
|
|
|
|
@Safe.Raw(buttonText)
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
}
|
2020-05-26 21:52:42 +02:00
|
|
|
}
|
|
|
|
@if (item.Inventory.HasValue)
|
|
|
|
{
|
|
|
|
<div class="w-100 pt-2 text-center text-muted">
|
|
|
|
@if (item.Inventory > 0)
|
|
|
|
{
|
|
|
|
<span>@item.Inventory left</span>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<span>Sold out</span>
|
|
|
|
}
|
|
|
|
</div>
|
2021-04-10 18:38:57 -07:00
|
|
|
}
|
|
|
|
else if (anyInventoryItems)
|
2020-05-26 21:52:42 +02:00
|
|
|
{
|
|
|
|
<div class="w-100 pt-2"> </div>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
@if (Model.ShowCustomAmount)
|
|
|
|
{
|
2021-06-06 13:44:54 +02:00
|
|
|
<div class="card px-0">
|
2021-04-10 18:38:57 -07:00
|
|
|
@{CardBody("Custom Amount", "Create invoice to pay custom amount");}
|
2021-06-06 13:44:54 +02:00
|
|
|
<div class="card-footer bg-transparent border-0 pb-3">
|
2022-07-22 15:41:14 +02:00
|
|
|
<form method="post" asp-action="ViewPointOfSale" asp-route-appId="@Model.AppId" asp-antiforgery="false" data-buy>
|
2021-10-29 09:58:59 +02:00
|
|
|
@{PayFormInputContent(Model.CustomButtonText, ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType.Minimum);}
|
2020-05-26 21:52:42 +02:00
|
|
|
</form>
|
|
|
|
@if (anyInventoryItems)
|
|
|
|
{
|
|
|
|
<div class="w-100 pt-2"> </div>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
</div>
|
2023-01-30 09:23:49 +01:00
|
|
|
</main>
|
|
|
|
<footer class="store-footer">
|
|
|
|
<a href="https://btcpayserver.org" target="_blank" rel="noreferrer noopener">
|
|
|
|
Powered by <partial name="_StoreFooterLogo" />
|
|
|
|
</a>
|
|
|
|
</footer>
|
2020-05-26 21:52:42 +02:00
|
|
|
</div>
|
2021-04-10 18:38:57 -07:00
|
|
|
|
|
|
|
@functions {
|
2021-10-29 09:58:59 +02:00
|
|
|
private void PayFormInputContent(string buttonText,ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType itemPriceType, decimal? minPriceValue = null, decimal? priceValue = null)
|
2021-04-10 18:38:57 -07:00
|
|
|
{
|
2022-07-22 13:30:39 +02:00
|
|
|
if (itemPriceType == ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType.Fixed && priceValue == 0)
|
|
|
|
{
|
|
|
|
<div class="input-group ">
|
|
|
|
<input class="form-control" type="text" readonly value="Free"/>
|
|
|
|
<button class="btn btn-primary text-nowrap" type="submit">@buttonText</button>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<div class="input-group">
|
|
|
|
<span class="input-group-text">@Model.CurrencySymbol</span>
|
|
|
|
<input type="hidden" name="requiresRefundEmail" value="@Model.RequiresRefundEmail.ToString()" />
|
|
|
|
<input class="form-control" type="number" min="@(minPriceValue ?? 0)" step="@Model.Step" name="amount" placeholder="Amount" value="@priceValue" readonly="@(itemPriceType == ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType.Fixed)">
|
|
|
|
<button class="btn btn-primary text-nowrap" type="submit">@buttonText</button>
|
|
|
|
</div>
|
|
|
|
}
|
2021-04-10 18:38:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
private void CardBody(string title, string description)
|
|
|
|
{
|
|
|
|
<div class="card-body my-auto pb-0">
|
|
|
|
<h5 class="card-title">@title</h5>
|
2022-07-22 15:41:14 +02:00
|
|
|
@if (!string.IsNullOrWhiteSpace(description))
|
2021-04-10 18:38:57 -07:00
|
|
|
{
|
|
|
|
<p class="card-text">@Safe.Raw(description)</p>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
}
|