Fix cart view and provide better naming for default items fixes #5012

This commit is contained in:
Kukks 2023-05-30 10:05:31 +02:00
parent 79836ef1de
commit 35dd580e74
No known key found for this signature in database
GPG key ID: 8E5530D9D1C93097
4 changed files with 12 additions and 14 deletions

View file

@ -51,7 +51,6 @@ namespace BTCPayServer.Plugins.PointOfSale
private readonly LinkGenerator _linkGenerator;
private readonly IOptions<BTCPayServerOptions> _btcPayServerOptions;
private readonly DisplayFormatter _displayFormatter;
private readonly HtmlSanitizer _htmlSanitizer;
public const string AppType = "PointOfSale";
public PointOfSaleAppType(
@ -65,7 +64,6 @@ namespace BTCPayServer.Plugins.PointOfSale
_linkGenerator = linkGenerator;
_btcPayServerOptions = btcPayServerOptions;
_displayFormatter = displayFormatter;
_htmlSanitizer = htmlSanitizer;
}
public override Task<string> ConfigureLink(AppData app)

View file

@ -34,44 +34,44 @@ namespace BTCPayServer.Services.Apps
new()
{
Id = "rooibos",
Title = "Rooibos",
Title = "Rooibos (limited)",
Description =
"Rooibos is a dramatic red tea made from a South African herb that contains polyphenols and flavonoids. Often called 'African redbush tea', Rooibos herbal tea delights the senses and delivers potential health benefits with each caffeine-free sip.",
Image = "~/img/pos-sample/rooibos.jpg",
PriceType = ViewPointOfSaleViewModel.ItemPriceType.Fixed,
Price = 1.2m
Price = 1.2m,
Inventory = 5,
},
new()
{
Id = "pu-erh",
Title = "Pu Erh",
Title = "Pu Erh (free)",
Description =
"This loose pur-erh tea is produced in Yunnan Province, China. The process in a relatively high humidity environment has mellowed the elemental character of the tea when compared to young Pu-erh.",
Image = "~/img/pos-sample/pu-erh.jpg",
PriceType = ViewPointOfSaleViewModel.ItemPriceType.Fixed,
Price = 2
Price = 0
},
new()
{
Id = "herbal-tea",
Title = "Herbal Tea",
Title = "Herbal Tea (minimum)",
Description =
"Chamomile tea is made from the flower heads of the chamomile plant. The medicinal use of chamomile dates back to the ancient Egyptians, Romans and Greeks. Pay us what you want!",
Image = "~/img/pos-sample/herbal-tea.jpg",
PriceType = ViewPointOfSaleViewModel.ItemPriceType.Minimum,
Price = 1.8m,
Disabled = true
Disabled = false
},
new()
{
Id = "fruit-tea",
Title = "Fruit Tea",
Title = "Fruit Tea (any amount)",
Description =
"The Tibetan Himalayas, the land is majestic and beautiful—a spiritual place where, despite the perilous environment, many journey seeking enlightenment. Pay us what you want!",
Image = "~/img/pos-sample/fruit-tea.jpg",
PriceType = ViewPointOfSaleViewModel.ItemPriceType.Topup,
Inventory = 5,
Disabled = true
Disabled = false
}
});
DefaultView = PosViewType.Static;

View file

@ -255,7 +255,7 @@
<span class="text-muted small">
@{
var buttonText = string.IsNullOrEmpty(item.BuyButtonText) ? item.PriceType != ViewPointOfSaleViewModel.ItemPriceType.Fixed ? Model.CustomButtonText : Model.ButtonText : item.BuyButtonText;
var buttonText = string.IsNullOrEmpty(item.BuyButtonText) ? item.PriceType == ViewPointOfSaleViewModel.ItemPriceType.Topup ? Model.CustomButtonText : Model.ButtonText : item.BuyButtonText;
if (item.PriceType != ViewPointOfSaleViewModel.ItemPriceType.Topup)
{
var formatted = DisplayFormatter.Currency(item.Price ?? 0, Model.CurrencyCode, DisplayFormatter.CurrencyFormat.Symbol);

View file

@ -112,7 +112,7 @@ Cart.prototype.getTotalProducts = function() {
typeof this.content[key] != 'undefined' &&
!this.content[key].disabled
) {
const price = this.toCents(this.content[key].price.value ||0);
const price = this.toCents(this.content[key].price ||0);
amount += (this.content[key].count * price);
}
}
@ -438,7 +438,7 @@ Cart.prototype.listItems = function() {
'title': this.escape(item.title),
'count': this.escape(item.count),
'inventory': this.escape(item.inventory < 0? 99999: item.inventory),
'price': this.escape(item.price.formatted || 0)
'price': this.escape(item.price || 0)
});
list.push($(tableTemplate));
}