mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Re-label cart button if cart is not visible or all products are free
This commit is contained in:
@@ -189,6 +189,7 @@
|
||||
</div>
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
<button class="btn btn-block btn-primary btn-lg" type="submit">
|
||||
<span class="fa fa-lock"></span>
|
||||
{% if cart.total > 0 %}
|
||||
{% trans "Place binding order" %}
|
||||
{% else %}
|
||||
|
||||
@@ -241,7 +241,15 @@
|
||||
<div class="row-fluid">
|
||||
<div class="col-md-4 col-md-offset-8 col-xs-12">
|
||||
<button class="btn btn-block btn-primary btn-lg" type="submit" id="btn-add-to-cart">
|
||||
<i class="fa fa-shopping-cart"></i> {% trans "Add to cart" %}
|
||||
{% if request.event.settings.redirect_to_checkout_directly %}
|
||||
{% if allfree %}
|
||||
<i class="fa fa-check"></i> {% trans "Register" %}
|
||||
{% else %}
|
||||
<i class="fa fa-shopping-cart"></i> {% trans "Proceed with checkout" %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<i class="fa fa-shopping-cart"></i> {% trans "Add to cart" %}
|
||||
{% endif %}
|
||||
</button>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
@@ -338,7 +338,15 @@
|
||||
<div class="row-fluid checkout-button-row">
|
||||
<div class="col-md-4 col-md-offset-8 col-xs-12">
|
||||
<button class="btn btn-block btn-primary btn-lg" id="btn-add-to-cart" type="submit">
|
||||
<i class="fa fa-shopping-cart"></i> {% trans "Add to cart" %}
|
||||
{% if request.event.settings.redirect_to_checkout_directly %}
|
||||
{% if allfree %}
|
||||
<i class="fa fa-check"></i> {% trans "Register" %}
|
||||
{% else %}
|
||||
<i class="fa fa-shopping-cart"></i> {% trans "Proceed with checkout" %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<i class="fa fa-shopping-cart"></i> {% trans "Add to cart" %}
|
||||
{% endif %}
|
||||
</button>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
import mimetypes
|
||||
import os
|
||||
from decimal import Decimal
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
@@ -455,6 +456,16 @@ class RedeemView(NoSearchIndexViewMixin, EventViewMixin, TemplateView):
|
||||
context['options'] = sum([(len(item.available_variations) if item.has_variations else 1)
|
||||
for item in items])
|
||||
|
||||
context['allfree'] = all(
|
||||
item.display_price.gross == Decimal('0.00') for item in items if not item.has_variations
|
||||
) and all(
|
||||
all(
|
||||
var.display_price.gross == Decimal('0.00')
|
||||
for var in item.available_variations
|
||||
)
|
||||
for item in items if item.has_variations
|
||||
)
|
||||
|
||||
# Regroup those by category
|
||||
context['items_by_category'] = item_group_by_category(items)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import calendar
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
from datetime import date, datetime, timedelta
|
||||
from decimal import Decimal
|
||||
from importlib import import_module
|
||||
|
||||
import pytz
|
||||
@@ -319,6 +320,15 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
|
||||
items, display_add_to_cart = get_grouped_items(self.request.event, self.subevent,
|
||||
channel=self.request.sales_channel.identifier)
|
||||
context['itemnum'] = len(items)
|
||||
context['allfree'] = all(
|
||||
item.display_price.gross == Decimal('0.00') for item in items if not item.has_variations
|
||||
) and all(
|
||||
all(
|
||||
var.display_price.gross == Decimal('0.00')
|
||||
for var in item.available_variations
|
||||
)
|
||||
for item in items if item.has_variations
|
||||
)
|
||||
|
||||
# Regroup those by category
|
||||
context['items_by_category'] = item_group_by_category(items)
|
||||
|
||||
Reference in New Issue
Block a user