diff --git a/doc/user/events/widget.rst b/doc/user/events/widget.rst index 57456cb8e6..fe02055557 100644 --- a/doc/user/events/widget.rst +++ b/doc/user/events/widget.rst @@ -143,7 +143,7 @@ resources. Then, instead of the ``pretix-widget`` tag, use the ``pretix-button`` As you can see, the ``pretix-button`` element takes an additional ``items`` attribute that specifies the items that should be added to the cart. The syntax of this attribute is ``item_ITEMID=1,item_ITEMID=2,variation_ITEMID_VARID=4`` where ``ITEMID`` are the internal IDs of items to be added and ``VARID`` are the internal IDs of variations of those -items, if the items have variations. +items, if the items have variations. If you omit the ``items`` attribute, the general start page will be presented. Just as the widget, the button supports the optional attributes ``voucher`` and ``skip-ssl-check``. diff --git a/src/pretix/static/pretixpresale/js/widget/widget.js b/src/pretix/static/pretixpresale/js/widget/widget.js index 35dd0d05e3..119c335efa 100644 --- a/src/pretix/static/pretixpresale/js/widget/widget.js +++ b/src/pretix/static/pretixpresale/js/widget/widget.js @@ -392,10 +392,14 @@ var shared_methods = { } else { return; } - var url = this.$root.formTarget + "&locale=" + lang + "&ajax=1"; - this.$root.frame_loading = true; - this.async_task_interval = 100; - api._postFormJSON(url, this.$refs.form, this.buy_callback, this.buy_error_callback); + if (this.$root.is_button && this.$root.items.length === 0) { + this.resume(); + } else { + var url = this.$root.formTarget + "&locale=" + lang + "&ajax=1"; + this.$root.frame_loading = true; + this.async_task_interval = 100; + api._postFormJSON(url, this.$refs.form, this.buy_callback, this.buy_error_callback); + } }, buy_error_callback: function (xhr, data) { this.$root.error_message = strings['cart_error']; @@ -740,6 +744,7 @@ var create_widget = function (element) { return { event_url: event_url, subevent: subevent, + is_button: false, categories: null, currency: null, voucher_code: voucher, @@ -787,7 +792,7 @@ var create_button = function (element) { var itemsplit = raw_items.split(","); var items = []; for (var i = 0; i < itemsplit.length; i++) { - if (itemsplit[i].indexOf("=")) { + if (itemsplit[i].indexOf("=") > 0 ) { var splitthis = itemsplit[i].split("="); items.push({'item': splitthis[0], 'count': splitthis[1]}) } @@ -799,6 +804,7 @@ var create_button = function (element) { return { event_url: event_url, subevent: subevent, + is_button: true, skip_ssl: skip_ssl, voucher_code: voucher, items: items,