From 83bc714739a5498c78ceb689d7584b40352f2cb9 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 25 Jun 2018 12:44:54 +0200 Subject: [PATCH] Widget: Hide "FREE" if there is only one priced item --- .../static/pretixpresale/js/widget/widget.js | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/pretix/static/pretixpresale/js/widget/widget.js b/src/pretix/static/pretixpresale/js/widget/widget.js index f8bafa6aa0..3ef0b42b7f 100644 --- a/src/pretix/static/pretixpresale/js/widget/widget.js +++ b/src/pretix/static/pretixpresale/js/widget/widget.js @@ -255,8 +255,9 @@ Vue.component('variation', { + '
' + '' + + ' :field_name="\'price_\' + item.id + \'_\' + variation.id" v-if="$root.showPrices">' + '' + + ' ' + '
' + '
' + '' @@ -299,10 +300,11 @@ Vue.component('item', { + '
' + '
' - + '' + '' - + '
{{ pricerange }}
' + + '
{{ pricerange }}
' + + ' ' + '
' + '
' + ''+ strings.variations + '' @@ -649,6 +651,23 @@ var shared_root_computed = { }, useIframe: function () { return Math.min(screen.width, window.innerWidth) >= 800 && (this.skip_ssl || site_is_secure()); + }, + showPrices: function () { + var has_priced = false; + var cnt_items = 0; + for (var i = 0; i < this.categories.length; i++) { + for (var j = 0; j < this.categories[i].items.length; j++) { + var item = this.categories[i].items[j]; + if (item.has_variations) { + cnt_items += item.variations.length; + has_priced = true; + } else { + cnt_items++; + has_priced = has_priced || item.price.gross != "0.00"; + } + } + } + return has_priced || cnt_items > 1; } };