From 30e55b5b8e25e9e9a8eb7725131d15ae3cff09dc Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 31 Mar 2022 21:19:38 +0200 Subject: [PATCH] Add option to charge fee on free products (#22) --- pretix_servicefees/signals.py | 8 ++++++-- .../templates/pretix_servicefees/settings.html | 1 + pretix_servicefees/views.py | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pretix_servicefees/signals.py b/pretix_servicefees/signals.py index 59e3f0e..2645534 100644 --- a/pretix_servicefees/signals.py +++ b/pretix_servicefees/signals.py @@ -32,7 +32,10 @@ def navbar_settings(sender, request, **kwargs): def get_fees(event, total, invoice_address, mod='', request=None, positions=[], gift_cards=None): if request is not None and not positions: positions = get_cart(request) - positions = [pos for pos in positions if pos.price != Decimal('0.00')] + + skip_free = event.settings.get('service_fee_skip_free', as_type=bool) + if skip_free: + positions = [pos for pos in positions if pos.price != Decimal('0.00')] skip_addons = event.settings.get('service_fee_skip_addons', as_type=bool) if skip_addons: @@ -162,4 +165,5 @@ def order_meta_signal(sender: Event, request: HttpRequest, **kwargs): return meta -settings_hierarkey.add_default('service_fee_skip_addons', 'True', bool) \ No newline at end of file +settings_hierarkey.add_default('service_fee_skip_addons', 'True', bool) +settings_hierarkey.add_default('service_fee_skip_free', 'True', bool) diff --git a/pretix_servicefees/templates/pretix_servicefees/settings.html b/pretix_servicefees/templates/pretix_servicefees/settings.html index 70e5005..642e6be 100644 --- a/pretix_servicefees/templates/pretix_servicefees/settings.html +++ b/pretix_servicefees/templates/pretix_servicefees/settings.html @@ -11,6 +11,7 @@ {% bootstrap_field form.service_fee_per_ticket addon_after=request.event.currency layout="control" %} {% bootstrap_field form.service_fee_skip_non_admission layout="control" %} {% bootstrap_field form.service_fee_skip_addons layout="control" %} + {% bootstrap_field form.service_fee_skip_free layout="control" %} {% bootstrap_field form.service_fee_abs addon_after=request.event.currency layout="control" %} {% bootstrap_field form.service_fee_percent addon_after="%" layout="control" %} {% bootstrap_field form.service_fee_skip_if_gift_card layout="control" %} diff --git a/pretix_servicefees/views.py b/pretix_servicefees/views.py index 6bd3f6b..1afbc4d 100644 --- a/pretix_servicefees/views.py +++ b/pretix_servicefees/views.py @@ -41,6 +41,11 @@ class ServiceFeeSettingsForm(SettingsForm): label=_('Do not charge per-ticket service fee on non-admission products'), required=False ) + service_fee_skip_free = forms.BooleanField( + label=_('Do not charge per-ticket service fee on free products'), + help_text=_('Note that regardless of this setting, a per-ticket fee will not be charged if the entire order is free.'), + required=False + ) service_fee_abs_resellers = forms.DecimalField( label=_('Fixed fee per order'),