Compare commits

...

3 Commits

Author SHA1 Message Date
Raphael Michel
8d5dc4cd54 Add display property 2025-11-10 15:36:37 +01:00
Raphael Michel
eb10134e1f Apply suggestions from code review
Co-authored-by: Richard Schreiber <schreiber@rami.io>
2025-11-10 15:35:44 +01:00
Raphael Michel
2210e49c8c Product list: Show number of items currently in cart 2025-11-10 11:46:12 +01:00
3 changed files with 38 additions and 4 deletions

View File

@@ -3,6 +3,8 @@
{% load eventurl %} {% load eventurl %}
{% load money %} {% load money %}
{% load thumb %} {% load thumb %}
{% load icon %}
{% load getitem %}
{% load eventsignal %} {% load eventsignal %}
{% load rich_text %} {% load rich_text %}
{% for tup in items_by_category %}{% with category=tup.0 items=tup.1 form_prefix=tup.2 %} {% for tup in items_by_category %}{% with category=tup.0 items=tup.1 form_prefix=tup.2 %}
@@ -43,7 +45,9 @@
</a> </a>
{% endif %} {% endif %}
<div class="product-description {% if item.picture %}with-picture{% endif %}"> <div class="product-description {% if item.picture %}with-picture{% endif %}">
<h{{ headline_level|default:3|add:1 }} class="h4" id="{{ form_prefix }}item-{{ item.pk }}-legend">{{ item.name }}</h{{ headline_level|default:3|add:1 }}> <h{{ headline_level|default:3|add:1 }} class="h4" id="{{ form_prefix }}item-{{ item.pk }}-legend">
{{ item.name }}
</h{{ headline_level|default:3|add:1 }}>
{% if item.description %} {% if item.description %}
<div id="{{ form_prefix }}item-{{ item.pk }}-description" class="product-description"> <div id="{{ form_prefix }}item-{{ item.pk }}-description" class="product-description">
{{ item.description|localize|rich_text }} {{ item.description|localize|rich_text }}
@@ -119,7 +123,19 @@
data-price="{% if event.settings.display_net_prices %}{{ var.display_price.net|unlocalize }}{% else %}{{ var.display_price.gross|unlocalize }}{% endif %}" data-price="{% if event.settings.display_net_prices %}{{ var.display_price.net|unlocalize }}{% else %}{{ var.display_price.gross|unlocalize }}{% endif %}"
{% endif %}> {% endif %}>
<div class="col-md-8 col-sm-6 col-xs-12"> <div class="col-md-8 col-sm-6 col-xs-12">
<h{{ headline_level|default:3|add:2 }} class="h5" id="{{ form_prefix }}item-{{ item.pk }}-{{ var.pk }}-legend">{{ var }}</h{{ headline_level|default:3|add:2 }}> <h{{ headline_level|default:3|add:2 }} class="h5" id="{{ form_prefix }}item-{{ item.pk }}-{{ var.pk }}-legend">
{{ var }}
{% if cart.itemvarsums|getitem:var %}
<span class="textbubble-success">
{% icon "shopping-cart" %}
{% blocktrans trimmed count amount=cart.itemvarsums|getitem:var %}
{{ amount }}× in your cart
{% plural %}
{{ amount }}× in your cart
{% endblocktrans %}
</span>
{% endif %}
</h{{ headline_level|default:3|add:2 }}>
{% if var.description %} {% if var.description %}
<div id="{{ form_prefix }}item-{{ item.pk }}-{{ var.pk }}-description" class="variation-description"> <div id="{{ form_prefix }}item-{{ item.pk }}-{{ var.pk }}-description" class="variation-description">
{{ var.description|localize|rich_text }} {{ var.description|localize|rich_text }}
@@ -264,7 +280,19 @@
</a> </a>
{% endif %} {% endif %}
<div class="product-description {% if item.picture %}with-picture{% endif %}"> <div class="product-description {% if item.picture %}with-picture{% endif %}">
<h{{ headline_level|default:3|add:1 }} class="h4" id="{{ form_prefix }}item-{{ item.pk }}-legend">{{ item.name }}</h{{ headline_level|default:3|add:1 }}> <h{{ headline_level|default:3|add:1 }} class="h4" id="{{ form_prefix }}item-{{ item.pk }}-legend">
{{ item.name }}
{% if cart.itemvarsums|getitem:item %}
<span class="textbubble-success">
{% icon "shopping-cart" %}
{% blocktrans trimmed count amount=cart.itemvarsums|getitem:item %}
{{ amount }}× in your cart
{% plural %}
{{ amount }}× in your cart
{% endblocktrans %}
</span>
{% endif %}
</h{{ headline_level|default:3|add:1 }}>
{% if item.description %} {% if item.description %}
<div id="{{ form_prefix }}item-{{ item.pk }}-description" class="product-description"> <div id="{{ form_prefix }}item-{{ item.pk }}-description" class="product-description">
{{ item.description|localize|rich_text }} {{ item.description|localize|rich_text }}

View File

@@ -33,7 +33,7 @@
# License for the specific language governing permissions and limitations under the License. # License for the specific language governing permissions and limitations under the License.
import copy import copy
import warnings import warnings
from collections import defaultdict from collections import Counter, defaultdict
from datetime import datetime, timedelta from datetime import datetime, timedelta
from decimal import Decimal from decimal import Decimal
from functools import wraps from functools import wraps
@@ -242,6 +242,10 @@ class CartMixin:
minutes_left = None minutes_left = None
seconds_left = None seconds_left = None
itemvarsums = Counter()
for p in cartpos:
itemvarsums[p.variation or p.item] += 1
return { return {
'positions': positions, 'positions': positions,
'invoice_address': self.invoice_address, 'invoice_address': self.invoice_address,
@@ -258,6 +262,7 @@ class CartMixin:
'max_expiry_extend': max_expiry_extend, 'max_expiry_extend': max_expiry_extend,
'is_ordered': bool(order), 'is_ordered': bool(order),
'itemcount': sum(c.count for c in positions if not c.addon_to), 'itemcount': sum(c.count for c in positions if not c.addon_to),
'itemvarsums': itemvarsums,
'current_selected_payments': [ 'current_selected_payments': [
p for p in self.current_selected_payments(positions, fees, self.invoice_address) p for p in self.current_selected_payments(positions, fees, self.invoice_address)
if p.get('multi_use_supported') if p.get('multi_use_supported')

View File

@@ -574,6 +574,7 @@ h2 .label {
.textbubble-success, .textbubble-success-warning, .textbubble-info, .textbubble-warning, .textbubble-danger { .textbubble-success, .textbubble-success-warning, .textbubble-info, .textbubble-warning, .textbubble-danger {
display: inline-block;
padding: 0 .4em; padding: 0 .4em;
border-radius: $border-radius-base; border-radius: $border-radius-base;
font-weight: bold; font-weight: bold;