mirror of
https://github.com/pretix/pretix.git
synced 2026-08-16 11:46:27 +00:00
Allow to redirect to checkout directly after adding a product to the cart
This commit is contained in:
@@ -97,6 +97,10 @@ DEFAULTS = {
|
|||||||
'default': '30',
|
'default': '30',
|
||||||
'type': int
|
'type': int
|
||||||
},
|
},
|
||||||
|
'redirect_to_checkout_directly': {
|
||||||
|
'default': 'False',
|
||||||
|
'type': bool
|
||||||
|
},
|
||||||
'payment_explanation': {
|
'payment_explanation': {
|
||||||
'default': '',
|
'default': '',
|
||||||
'type': LazyI18nString
|
'type': LazyI18nString
|
||||||
|
|||||||
@@ -1074,6 +1074,10 @@ class DisplaySettingsForm(SettingsForm):
|
|||||||
label=_('Ask search engines not to index the ticket shop'),
|
label=_('Ask search engines not to index the ticket shop'),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
|
redirect_to_checkout_directly = forms.BooleanField(
|
||||||
|
label=_('Directly redirect to check-out after a product has been added to the cart.'),
|
||||||
|
required=False
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
event = kwargs['obj']
|
event = kwargs['obj']
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
{% if form.frontpage_subevent_ordering %}
|
{% if form.frontpage_subevent_ordering %}
|
||||||
{% bootstrap_field form.frontpage_subevent_ordering layout="control" %}
|
{% bootstrap_field form.frontpage_subevent_ordering layout="control" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% bootstrap_field form.redirect_to_checkout_directly layout="control" %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{% trans "Shop design" %}</legend>
|
<legend>{% trans "Shop design" %}</legend>
|
||||||
|
|||||||
@@ -182,7 +182,7 @@
|
|||||||
<form method="post" data-asynctask
|
<form method="post" data-asynctask
|
||||||
data-asynctask-headline="{% trans "We're now trying to reserve this for you!" %}"
|
data-asynctask-headline="{% trans "We're now trying to reserve this for you!" %}"
|
||||||
data-asynctask-text="{% blocktrans with time=event.settings.reservation_time %}Once the items are in your cart, you will have {{ time }} minutes to complete your purchase.{% endblocktrans %}"
|
data-asynctask-text="{% blocktrans with time=event.settings.reservation_time %}Once the items are in your cart, you will have {{ time }} minutes to complete your purchase.{% endblocktrans %}"
|
||||||
action="{% eventurl request.event "presale:event.cart.add" cart_namespace=cart_namespace %}?next={{ request.path|urlencode }}">
|
action="{% eventurl request.event "presale:event.cart.add" cart_namespace=cart_namespace %}?next={{ cart_redirect|urlencode }}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="subevent" value="{{ subevent.id|default_if_none:"" }}" />
|
<input type="hidden" name="subevent" value="{{ subevent.id|default_if_none:"" }}" />
|
||||||
{% for tup in items_by_category %}
|
{% for tup in items_by_category %}
|
||||||
|
|||||||
@@ -20,8 +20,7 @@
|
|||||||
</p>
|
</p>
|
||||||
{% if event.presale_is_running or event.settings.show_items_outside_presale_period %}
|
{% if event.presale_is_running or event.settings.show_items_outside_presale_period %}
|
||||||
<form method="post"
|
<form method="post"
|
||||||
action="{% eventurl request.event "presale:event.cart.add" cart_namespace=cart_namespace %}?next={% eventurl request.event "presale:event.index" cart_namespace=cart_namespace %}{% if "iframe" in request.GET and not new_tab %}&iframe={{ request.GET.iframe }}{% endif %}{% if "take_cart_id" in request.GET and new_tab %}&take_cart_id={{ request.GET.take_cart_id }}{% endif %}"
|
action="{% eventurl request.event "presale:event.cart.add" cart_namespace=cart_namespace %}?next={{ cart_redirect|urlencode }}{% if "iframe" in request.GET and not new_tab %}&iframe={{ request.GET.iframe }}{% endif %}{% if "take_cart_id" in request.GET and new_tab %}&take_cart_id={{ request.GET.take_cart_id }}{% endif %}" {% if new_tab %}target="_blank"{% else %}
|
||||||
{% if new_tab %}target="_blank"{% else %}
|
|
||||||
data-asynctask
|
data-asynctask
|
||||||
data-asynctask-headline="{% trans "We're now trying to reserve this for you!" %}"
|
data-asynctask-headline="{% trans "We're now trying to reserve this for you!" %}"
|
||||||
data-asynctask-text="{% blocktrans with time=event.settings.reservation_time %}Once the items are in your cart, you will have {{ time }} minutes to complete your purchase.{% endblocktrans %}"
|
data-asynctask-text="{% blocktrans with time=event.settings.reservation_time %}Once the items are in your cart, you will have {{ time }} minutes to complete your purchase.{% endblocktrans %}"
|
||||||
|
|||||||
@@ -425,6 +425,11 @@ class RedeemView(NoSearchIndexViewMixin, EventViewMixin, TemplateView):
|
|||||||
# Cookies are not supported! Lets just make the form open in a new tab
|
# Cookies are not supported! Lets just make the form open in a new tab
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self.request.event.settings.redirect_to_checkout_directly:
|
||||||
|
context['cart_redirect'] = eventreverse(self.request.event, 'presale:event.checkout.start')
|
||||||
|
else:
|
||||||
|
context['cart_redirect'] = eventreverse(self.request.event, 'presale:event.index')
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
|||||||
@@ -291,6 +291,10 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
|
|||||||
or not self.subevent
|
or not self.subevent
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
if self.request.event.settings.redirect_to_checkout_directly:
|
||||||
|
context['cart_redirect'] = eventreverse(self.request.event, 'presale:event.checkout.start')
|
||||||
|
else:
|
||||||
|
context['cart_redirect'] = self.request.path
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user