mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Change sort order in cart to keep subevents together (#2730)
Co-authored-by: Richard Schreiber <wiffbi@gmail.com>
This commit is contained in:
@@ -173,13 +173,14 @@ class CartMixin:
|
|||||||
# standalone positions are grouped by main product position id, addons below them also sorted by position id
|
# standalone positions are grouped by main product position id, addons below them also sorted by position id
|
||||||
i, addon_penalty, pos.positionid if isinstance(pos, OrderPosition) else pos.pk,
|
i, addon_penalty, pos.positionid if isinstance(pos, OrderPosition) else pos.pk,
|
||||||
# all other places are only used for positions that can be grouped. We just put zeros.
|
# all other places are only used for positions that can be grouped. We just put zeros.
|
||||||
) + (0, ) * 10
|
) + (0, ) * 12
|
||||||
|
|
||||||
# positions are sorted and grouped by various attributes
|
# positions are sorted and grouped by various attributes
|
||||||
category_key = (pos.item.category.position, pos.item.category.id) if pos.item.category is not None else (0, 0)
|
category_key = (pos.item.category.position, pos.item.category.id) if pos.item.category is not None else (0, 0)
|
||||||
item_key = pos.item.position, pos.item_id
|
item_key = pos.item.position, pos.item_id
|
||||||
variation_key = (pos.variation.position, pos.variation.id) if pos.variation is not None else (0, 0)
|
variation_key = (pos.variation.position, pos.variation.id) if pos.variation is not None else (0, 0)
|
||||||
grp = category_key + item_key + variation_key + (pos.price, (pos.voucher_id or 0), (pos.subevent_id or 0), (pos.seat_id or 0))
|
subevent_key = (pos.subevent.date_from, str(pos.subevent.name), pos.subevent_id) if pos.subevent_id else (0, "", 0)
|
||||||
|
grp = subevent_key + category_key + item_key + variation_key + (pos.price, (pos.voucher_id or 0), (pos.seat_id or 0))
|
||||||
if pos.addon_to_id:
|
if pos.addon_to_id:
|
||||||
if for_sorting:
|
if for_sorting:
|
||||||
ii = pos.positionid if isinstance(pos, OrderPosition) else pos.pk
|
ii = pos.positionid if isinstance(pos, OrderPosition) else pos.pk
|
||||||
@@ -187,7 +188,7 @@ class CartMixin:
|
|||||||
ii = 0
|
ii = 0
|
||||||
return (
|
return (
|
||||||
i, addon_penalty, ii,
|
i, addon_penalty, ii,
|
||||||
) + category_key + item_key + variation_key + (pos.price, (pos.voucher_id or 0), (pos.subevent_id or 0), (pos.seat_id or 0))
|
) + grp
|
||||||
return (
|
return (
|
||||||
# These are grouped by attributes so we don't put any position ids
|
# These are grouped by attributes so we don't put any position ids
|
||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user