From e687eee9f1d5a9c9bc6060759eed76230c3127a0 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Tue, 9 Jul 2019 18:54:48 +0200 Subject: [PATCH] Widget: Allow voucher with itemless button --- .../static/pretixpresale/js/widget/widget.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pretix/static/pretixpresale/js/widget/widget.js b/src/pretix/static/pretixpresale/js/widget/widget.js index bf89dcd2c..b46ea768f 100644 --- a/src/pretix/static/pretixpresale/js/widget/widget.js +++ b/src/pretix/static/pretixpresale/js/widget/widget.js @@ -458,7 +458,7 @@ var shared_methods = { return; } if (this.$root.is_button && this.$root.items.length === 0) { - this.resume(); + this.resume(this.$root.voucher_code); } else { var url = this.$root.formTarget + "&locale=" + lang + "&ajax=1"; this.$root.overlay.frame_loading = true; @@ -542,10 +542,15 @@ var shared_methods = { this.$root.overlay.frame_loading = true; iframe.src = redirect_url; }, - resume: function () { - var redirect_url = this.$root.target_url + 'w/' + widget_id + '/?iframe=1&locale=' + lang; - if (this.$root.cart_id) { - redirect_url += '&take_cart_id=' + this.$root.cart_id; + resume: function (voucher) { + var redirect_url; + if (voucher) { + redirect_url = this.$root.voucherFormTarget + '&voucher=' + voucher; + } else { + redirect_url = this.$root.target_url + 'w/' + widget_id + '/?iframe=1&locale=' + lang; + if (this.$root.cart_id) { + redirect_url += '&take_cart_id=' + this.$root.cart_id; + } } if (this.$root.widget_data) { redirect_url += '&widget_data=' + escape(this.$root.widget_data_json);