Checkout: Delete invoice address if no longer required (Z#23203488) (#5358)

This commit is contained in:
Raphael Michel
2025-08-08 15:56:35 +02:00
committed by GitHub
parent 067e11c265
commit 807df01f5d
3 changed files with 77 additions and 0 deletions

View File

@@ -959,6 +959,10 @@ class QuestionsStep(QuestionsViewMixin, CartMixin, TemplateFlowStep):
d['phone'] = str(d['phone'])
self.cart_session['contact_form_data'] = d
if self.address_asked or self.request.event.settings.invoice_name_required:
if not self.address_asked:
# Invoice address was there, but is no longer asked for, however, name is still required
self.invoice_form.instance.clear(except_name=True)
addr = self.invoice_form.save()
if self.cart_customer and self.invoice_form.cleaned_data.get('save'):
@@ -997,6 +1001,10 @@ class QuestionsStep(QuestionsViewMixin, CartMixin, TemplateFlowStep):
'rate to your purchase and the price of the products in your cart has '
'changed accordingly.'))
return redirect_to_url(self.get_next_url(request) + '?open_cart=true')
elif 'invoice_address' in self.cart_session:
# Invoice address was there, but is no longer asked for
self.invoice_address.delete()
del self.cart_session['invoice_address']
try:
validate_memberships_in_order(self.cart_customer, self.positions, self.request.event, lock=False,