mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54:03 +00:00
Allow customers to change add-ons on existing orders (#2283)
This commit is contained in:
@@ -475,7 +475,7 @@ class AddOnsStep(CartMixin, AsyncAction, TemplateFlowStep):
|
||||
'item__addons', 'item__addons__addon_category', 'addons', 'addons__variation',
|
||||
).order_by('pk'):
|
||||
formsetentry = {
|
||||
'cartpos': cartpos,
|
||||
'pos': cartpos,
|
||||
'item': cartpos.item,
|
||||
'variation': cartpos.variation,
|
||||
'categories': []
|
||||
@@ -582,13 +582,13 @@ class AddOnsStep(CartMixin, AsyncAction, TemplateFlowStep):
|
||||
for i in category['items']:
|
||||
if i.has_variations:
|
||||
for v in i.available_variations:
|
||||
val = int(self.request.POST.get(f'cp_{form["cartpos"].pk}_variation_{i.pk}_{v.pk}') or '0')
|
||||
price = self.request.POST.get(f'cp_{form["cartpos"].pk}_variation_{i.pk}_{v.pk}_price') or '0'
|
||||
val = int(self.request.POST.get(f'cp_{form["pos"].pk}_variation_{i.pk}_{v.pk}') or '0')
|
||||
price = self.request.POST.get(f'cp_{form["pos"].pk}_variation_{i.pk}_{v.pk}_price') or '0'
|
||||
if val:
|
||||
selected[i, v] = val, price
|
||||
else:
|
||||
val = int(self.request.POST.get(f'cp_{form["cartpos"].pk}_item_{i.pk}') or '0')
|
||||
price = self.request.POST.get(f'cp_{form["cartpos"].pk}_item_{i.pk}_price') or '0'
|
||||
val = int(self.request.POST.get(f'cp_{form["pos"].pk}_item_{i.pk}') or '0')
|
||||
price = self.request.POST.get(f'cp_{form["pos"].pk}_item_{i.pk}_price') or '0'
|
||||
if val:
|
||||
selected[i, None] = val, price
|
||||
|
||||
@@ -627,7 +627,7 @@ class AddOnsStep(CartMixin, AsyncAction, TemplateFlowStep):
|
||||
validate_cart_addons.send(
|
||||
sender=self.event,
|
||||
addons={k: v[0] for k, v in selected.items()},
|
||||
base_position=form["cartpos"],
|
||||
base_position=form["pos"],
|
||||
iao=category['iao']
|
||||
)
|
||||
except CartError as e:
|
||||
@@ -648,7 +648,7 @@ class AddOnsStep(CartMixin, AsyncAction, TemplateFlowStep):
|
||||
|
||||
for (i, v), (c, price) in selected.items():
|
||||
data.append({
|
||||
'addon_to': f['cartpos'].pk,
|
||||
'addon_to': f['pos'].pk,
|
||||
'item': i.pk,
|
||||
'variation': v.pk if v else None,
|
||||
'count': c,
|
||||
|
||||
Reference in New Issue
Block a user