Product list: Show number of items currently in cart (Z#23212546) (#5599)

* Product list: Show number of items currently in cart

* Apply suggestions from code review

Co-authored-by: Richard Schreiber <schreiber@rami.io>

* Add display property

---------

Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
Raphael Michel
2025-11-11 08:05:40 +01:00
committed by GitHub
parent d1ae579a6f
commit e99eecb8be
3 changed files with 38 additions and 4 deletions

View File

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