Fix price field when increasing number of bundles in cart

This commit is contained in:
Raphael Michel
2020-07-21 17:23:30 +02:00
parent 7bd9a01f5e
commit b305ac012c
2 changed files with 10 additions and 3 deletions

View File

@@ -173,12 +173,12 @@
<input type="hidden" name="variation_{{ line.item.id }}_{{ line.variation.id }}"
value="1" />
<input type="hidden" name="price_{{ line.item.id }}_{{ line.variation.id }}"
value="{{ line.price }}" />
value="{% if event.settings.display_net_prices %}{{ line.bundle_sum_net }}{% else %}{{ line.bundle_sum }}{% endif %}" />
{% else %}
<input type="hidden" name="item_{{ line.item.id }}"
value="1" />
<input type="hidden" name="price_{{ line.item.id }}"
value="{% if event.settings.display_net_prices %}{{ line.net_price }}{% else %}{{ line.price }}{% endif %}" />
value="{% if event.settings.display_net_prices %}{{ line.bundle_sum_net }}{% else %}{{ line.bundle_sum }}{% endif %}" />
{% endif %}
<button class="btn btn-mini btn-link {% if line.seat %}btn-invisible{% endif %}" title="{% trans "Add one more" %}" {% if line.seat %}disabled{% endif %}>
<i class="fa fa-plus"></i>

View File

@@ -74,7 +74,10 @@ class CartMixin:
cartpos = self.positions
lcp = list(cartpos)
has_addons = {cp.addon_to_id for cp in lcp if cp.addon_to_id}
has_addons = defaultdict(list)
for cp in lcp:
if cp.addon_to_id:
has_addons[cp.addon_to_id].append(cp)
pos_additional_fields = defaultdict(list)
for cp in lcp:
@@ -129,6 +132,10 @@ class CartMixin:
group.net_total = group.count * group.net_price
group.has_questions = answers and k[0] != ""
group.tax_rule = group.item.tax_rule
group.bundle_sum = group.price + sum(a.price for a in has_addons[group.pk])
group.bundle_sum_net = group.net_price + sum(a.net_price for a in has_addons[group.pk])
if answers:
group.cache_answers(all=False)
group.additional_answers = pos_additional_fields.get(group.pk)