From 9a6756ce5d171337de22a6cd7da22e0781fa81af Mon Sep 17 00:00:00 2001 From: Mira Weller Date: Wed, 9 Oct 2024 11:52:46 +0200 Subject: [PATCH] show discount notice on all categories with an available discount, not only those with cross_selling_condition=discount --- src/pretix/base/services/cross_selling.py | 6 +++++- .../templates/pretixpresale/event/checkout_addons.html | 2 +- .../pretixpresale/event/fragment_product_list.html | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pretix/base/services/cross_selling.py b/src/pretix/base/services/cross_selling.py index c17c8fb40b..871ba179fc 100644 --- a/src/pretix/base/services/cross_selling.py +++ b/src/pretix/base/services/cross_selling.py @@ -68,6 +68,8 @@ class CrossSellingService: '') for (category, items_qs, discount_info) in self._applicable_categories(0) ) + for category, items, form_prefix in result: + category.has_discount = any(item.original_price for item in items) return [(category, items, form_prefix) for (category, items, form_prefix) in result if len(items) > 0] def _applicable_categories(self, subevent_id): @@ -182,7 +184,7 @@ class CrossSellingService: max_count = inf # calculate discounted price - if discount_rule: + if discount_rule and discount_rule.benefit_discount_matching_percent > 0: if not item.has_variations: item.original_price = item.original_price or item.display_price previous_price = item.display_price @@ -192,6 +194,8 @@ class CrossSellingService: ) item.display_price = new_price else: + # discounts always match "whole" items, not specific variations -> we apply the discount to all + # available variations of the item for var in item.available_variations: var.original_price = var.original_price or var.display_price previous_price = var.display_price diff --git a/src/pretix/presale/templates/pretixpresale/event/checkout_addons.html b/src/pretix/presale/templates/pretixpresale/event/checkout_addons.html index 171a0e3979..d4263fb5c6 100644 --- a/src/pretix/presale/templates/pretixpresale/event/checkout_addons.html +++ b/src/pretix/presale/templates/pretixpresale/event/checkout_addons.html @@ -60,7 +60,7 @@
- {% include "pretixpresale/event/fragment_product_list.html" with items_by_category=cross_selling_data ev=event is_cross_selling=True %} + {% include "pretixpresale/event/fragment_product_list.html" with items_by_category=cross_selling_data ev=event %}
{% endif %} diff --git a/src/pretix/presale/templates/pretixpresale/event/fragment_product_list.html b/src/pretix/presale/templates/pretixpresale/event/fragment_product_list.html index 93b4d4f406..e7d88001a2 100644 --- a/src/pretix/presale/templates/pretixpresale/event/fragment_product_list.html +++ b/src/pretix/presale/templates/pretixpresale/event/fragment_product_list.html @@ -9,7 +9,7 @@ {% if category %}

{{ category.name }} - {% if is_cross_selling and category.cross_selling_condition == 'discounts' %} + {% if category.has_discount %} {% trans "Your order qualifies for a discount" %} {% endif %}