mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54:03 +00:00
Widget: Allow to pre-fill fields in the invoice address
This commit is contained in:
@@ -183,6 +183,8 @@ with that information::
|
|||||||
<pretix-widget event="https://pretix.eu/demo/democon/"
|
<pretix-widget event="https://pretix.eu/demo/democon/"
|
||||||
data-attendee-name-given-name="John"
|
data-attendee-name-given-name="John"
|
||||||
data-attendee-name-family-name="Doe"
|
data-attendee-name-family-name="Doe"
|
||||||
|
data-invoice-address-name-given-name="John"
|
||||||
|
data-invoice-address-name-family-name="Doe"
|
||||||
data-email="test@example.org"
|
data-email="test@example.org"
|
||||||
data-question-L9G8NG9M="Foobar">
|
data-question-L9G8NG9M="Foobar">
|
||||||
</pretix-widget>
|
</pretix-widget>
|
||||||
@@ -200,6 +202,11 @@ This works for the pretix Button as well. Currently, the following attributes ar
|
|||||||
``data-attendee-name-latin-transcription``. If you don't know or don't care, you can also just pass a string as
|
``data-attendee-name-latin-transcription``. If you don't know or don't care, you can also just pass a string as
|
||||||
``data-attendee-name``, which will pre-fill the last part of the name, whatever that is.
|
``data-attendee-name``, which will pre-fill the last part of the name, whatever that is.
|
||||||
|
|
||||||
|
* ``data-invoice-address-FIELD`` will pre-fill the corresponding field of the invoice address. Possible values for
|
||||||
|
``FIELD`` are ``company``, ``street``, ``zipcode``, ``city`` and ``country``, as well as fields specified by the
|
||||||
|
naming scheme such as ``name-title`` or ``name-given-name`` (see above). ``country`` expects a two-character
|
||||||
|
country code.
|
||||||
|
|
||||||
Any configured pretix plugins might understand more data fields. For example, if the appropriate plugins on pretix
|
Any configured pretix plugins might understand more data fields. For example, if the appropriate plugins on pretix
|
||||||
Hosted or pretix Enterprise are active, you can pass the following fields:
|
Hosted or pretix Enterprise are active, you can pass the following fields:
|
||||||
|
|
||||||
|
|||||||
@@ -329,15 +329,30 @@ class QuestionsStep(QuestionsViewMixin, CartMixin, TemplateFlowStep):
|
|||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def invoice_form(self):
|
def invoice_form(self):
|
||||||
|
initial = {
|
||||||
|
'name_parts': {
|
||||||
|
k[21:].replace('-', '_'): v
|
||||||
|
for k, v in self.cart_session.get('widget_data', {}).items()
|
||||||
|
if k.startswith('invoice-address-name-')
|
||||||
|
},
|
||||||
|
'company': self.cart_session.get('widget_data', {}).get('invoice-address-company', ''),
|
||||||
|
'is_business': bool(self.cart_session.get('widget_data', {}).get('invoice-address-company', '')),
|
||||||
|
'street': self.cart_session.get('widget_data', {}).get('invoice-address-street', ''),
|
||||||
|
'zipcode': self.cart_session.get('widget_data', {}).get('invoice-address-zipcode', ''),
|
||||||
|
'city': self.cart_session.get('widget_data', {}).get('invoice-address-city', ''),
|
||||||
|
'country': self.cart_session.get('widget_data', {}).get('invoice-address-country', ''),
|
||||||
|
}
|
||||||
if not self.request.event.settings.invoice_address_asked and self.request.event.settings.invoice_name_required:
|
if not self.request.event.settings.invoice_address_asked and self.request.event.settings.invoice_name_required:
|
||||||
return InvoiceNameForm(data=self.request.POST if self.request.method == "POST" else None,
|
return InvoiceNameForm(data=self.request.POST if self.request.method == "POST" else None,
|
||||||
event=self.request.event,
|
event=self.request.event,
|
||||||
request=self.request,
|
request=self.request,
|
||||||
instance=self.invoice_address,
|
instance=self.invoice_address,
|
||||||
|
initial=initial,
|
||||||
validate_vat_id=False)
|
validate_vat_id=False)
|
||||||
return InvoiceAddressForm(data=self.request.POST if self.request.method == "POST" else None,
|
return InvoiceAddressForm(data=self.request.POST if self.request.method == "POST" else None,
|
||||||
event=self.request.event,
|
event=self.request.event,
|
||||||
request=self.request,
|
request=self.request,
|
||||||
|
initial=initial,
|
||||||
instance=self.invoice_address,
|
instance=self.invoice_address,
|
||||||
validate_vat_id=self.eu_reverse_charge_relevant)
|
validate_vat_id=self.eu_reverse_charge_relevant)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user