mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 09:54:30 +01:00
Enable/Disable tips and discount. Fix custom amount. (#612)
This commit is contained in:
parent
dd52075ff1
commit
1e7a2ffe97
@ -55,12 +55,16 @@ namespace BTCPayServer.Controllers
|
||||
" custom: true";
|
||||
EnableShoppingCart = false;
|
||||
ShowCustomAmount = true;
|
||||
ShowDiscount = true;
|
||||
EnableTips = true;
|
||||
}
|
||||
public string Title { get; set; }
|
||||
public string Currency { get; set; }
|
||||
public string Template { get; set; }
|
||||
public bool EnableShoppingCart { get; set; }
|
||||
public bool ShowCustomAmount { get; set; }
|
||||
public bool ShowDiscount { get; set; }
|
||||
public bool EnableTips { get; set; }
|
||||
|
||||
public const string BUTTON_TEXT_DEF = "Buy for {0}";
|
||||
public string ButtonText { get; set; } = BUTTON_TEXT_DEF;
|
||||
@ -89,6 +93,8 @@ namespace BTCPayServer.Controllers
|
||||
Title = settings.Title,
|
||||
EnableShoppingCart = settings.EnableShoppingCart,
|
||||
ShowCustomAmount = settings.ShowCustomAmount,
|
||||
ShowDiscount = settings.ShowDiscount,
|
||||
EnableTips = settings.EnableTips,
|
||||
Currency = settings.Currency,
|
||||
Template = settings.Template,
|
||||
ButtonText = settings.ButtonText ?? PointOfSaleSettings.BUTTON_TEXT_DEF,
|
||||
@ -160,6 +166,8 @@ namespace BTCPayServer.Controllers
|
||||
Title = vm.Title,
|
||||
EnableShoppingCart = vm.EnableShoppingCart,
|
||||
ShowCustomAmount = vm.ShowCustomAmount,
|
||||
ShowDiscount = vm.ShowDiscount,
|
||||
EnableTips = vm.EnableTips,
|
||||
Currency = vm.Currency.ToUpperInvariant(),
|
||||
Template = vm.Template,
|
||||
ButtonText = vm.ButtonText,
|
||||
|
@ -62,6 +62,8 @@ namespace BTCPayServer.Controllers
|
||||
Step = step.ToString(CultureInfo.InvariantCulture),
|
||||
EnableShoppingCart = settings.EnableShoppingCart,
|
||||
ShowCustomAmount = settings.ShowCustomAmount,
|
||||
ShowDiscount = settings.ShowDiscount,
|
||||
EnableTips = settings.EnableTips,
|
||||
CurrencyCode = settings.Currency,
|
||||
CurrencySymbol = numberFormatInfo.CurrencySymbol,
|
||||
CurrencyInfo = new ViewPointOfSaleViewModel.CurrencyInfoData()
|
||||
|
@ -17,6 +17,10 @@ namespace BTCPayServer.Models.AppViewModels
|
||||
public bool EnableShoppingCart { get; set; }
|
||||
[Display(Name = "User can input custom amount")]
|
||||
public bool ShowCustomAmount { get; set; }
|
||||
[Display(Name = "User can input discount in %")]
|
||||
public bool ShowDiscount { get; set; }
|
||||
[Display(Name = "Enable tips")]
|
||||
public bool EnableTips { get; set; }
|
||||
public string Example1 { get; internal set; }
|
||||
public string Example2 { get; internal set; }
|
||||
public string ExampleCallback { get; internal set; }
|
||||
|
@ -36,6 +36,8 @@ namespace BTCPayServer.Models.AppViewModels
|
||||
|
||||
public bool EnableShoppingCart { get; set; }
|
||||
public bool ShowCustomAmount { get; set; }
|
||||
public bool ShowDiscount { get; set; }
|
||||
public bool EnableTips { get; set; }
|
||||
public string Step { get; set; }
|
||||
public string Title { get; set; }
|
||||
public Item[] Items { get; set; }
|
||||
|
@ -57,6 +57,14 @@
|
||||
<label asp-for="ShowCustomAmount"></label>
|
||||
<input asp-for="ShowCustomAmount" type="checkbox" class="form-check" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="ShowDiscount"></label>
|
||||
<input asp-for="ShowDiscount" type="checkbox" class="form-check" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="EnableTips"></label>
|
||||
<input asp-for="EnableTips" type="checkbox" class="form-check" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="ButtonText" class="control-label"></label>*
|
||||
<input asp-for="ButtonText" class="form-control" />
|
||||
|
@ -93,6 +93,8 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@if (Model.ShowDiscount)
|
||||
{
|
||||
<tr>
|
||||
<td colspan="5" class="border-top-0">
|
||||
<div class="input-group">
|
||||
@ -106,9 +108,12 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="template-cart-tip" type="text/template">
|
||||
@if (Model.EnableTips)
|
||||
{
|
||||
<tr class="h5">
|
||||
<td colspan="5" class="border-top-0 pt-4">@Model.CustomTipText</td>
|
||||
</tr>
|
||||
@ -135,6 +140,7 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="template-cart-total" type="text/template">
|
||||
@ -170,18 +176,24 @@
|
||||
<span class="js-cart-summary-products text-nowrap"></span>
|
||||
</td>
|
||||
</tr>
|
||||
@if (Model.ShowDiscount)
|
||||
{
|
||||
<tr class="h6">
|
||||
<td class="border-0 pb-y">Discount</td>
|
||||
<td align="right" class="border-0 pb-y">
|
||||
<span class="js-cart-summary-discount text-nowrap"></span>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@if (Model.EnableTips)
|
||||
{
|
||||
<tr class="h6">
|
||||
<td class="border-top-0 pt-0">Tip</td>
|
||||
<td align="right" class="border-top-0 pt-0">
|
||||
<span class="js-cart-summary-tip text-nowrap"></span>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
<tr class="h3 table-light">
|
||||
<td>Total</td>
|
||||
<td align="right">
|
||||
|
@ -25,6 +25,10 @@ function Cart() {
|
||||
}
|
||||
|
||||
Cart.prototype.setCustomAmount = function(amount) {
|
||||
if (!srvModel.showCustomAmount) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.customAmount = this.toNumber(amount);
|
||||
|
||||
if (this.customAmount > 0) {
|
||||
@ -36,10 +40,18 @@ Cart.prototype.setCustomAmount = function(amount) {
|
||||
}
|
||||
|
||||
Cart.prototype.getCustomAmount = function() {
|
||||
if (!srvModel.showCustomAmount) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this.toCents(this.customAmount);
|
||||
}
|
||||
|
||||
Cart.prototype.setTip = function(amount) {
|
||||
if (!srvModel.enableTips) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.tip = this.toNumber(amount);
|
||||
|
||||
if (this.tip > 0) {
|
||||
@ -51,10 +63,18 @@ Cart.prototype.setTip = function(amount) {
|
||||
}
|
||||
|
||||
Cart.prototype.getTip = function() {
|
||||
if (!srvModel.enableTips) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this.toCents(this.tip);
|
||||
}
|
||||
|
||||
Cart.prototype.setDiscount = function(amount) {
|
||||
if (!srvModel.showDiscount) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.discount = this.toNumber(amount);
|
||||
|
||||
if (this.discount > 0) {
|
||||
@ -66,10 +86,18 @@ Cart.prototype.setDiscount = function(amount) {
|
||||
}
|
||||
|
||||
Cart.prototype.getDiscount = function() {
|
||||
if (!srvModel.showDiscount) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this.toCents(this.discount);
|
||||
}
|
||||
|
||||
Cart.prototype.getDiscountAmount = function(amount) {
|
||||
if (!srvModel.showDiscount) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this.percentage(amount, this.getDiscount());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user