Allow to redirect to checkout directly after adding a product to the cart

This commit is contained in:
Raphael Michel
2019-03-27 16:45:15 +01:00
parent d8a7de8b23
commit 697cdfd5c9
7 changed files with 20 additions and 3 deletions

View File

@@ -182,7 +182,7 @@
<form method="post" data-asynctask
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 %}"
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 %}
<input type="hidden" name="subevent" value="{{ subevent.id|default_if_none:"" }}" />
{% for tup in items_by_category %}

View File

@@ -20,8 +20,7 @@
</p>
{% if event.presale_is_running or event.settings.show_items_outside_presale_period %}
<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 %}"
{% if new_tab %}target="_blank"{% else %}
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 %}
data-asynctask
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 %}"

View File

@@ -425,6 +425,11 @@ class RedeemView(NoSearchIndexViewMixin, EventViewMixin, TemplateView):
# 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
def dispatch(self, request, *args, **kwargs):

View File

@@ -291,6 +291,10 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
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