AddressFormTrait
Step 1: billing data and delivery address.
The customer type is not asked with a select: the customer ticks "buying for a company" and
"VAT payer" and the server derives userTypeId and buyerType
(OrderCheckoutManager::resolveUserTypeId()).
IMPORTANT: the collapsible blocks (company, delivery address) use the native Nette toggle
(addCondition()->toggle()), never n:if: a field that is not rendered is not submitted and
saving would reset its value. A conditional required via addConditionOn() must not block
the submit while the block is hidden, so it is bound to the checkbox value, not to visibility.
Table of Contents
Methods
- onAddressSuccess() : void
- createComponentAddressForm() : Form
- applyUserAccountFallback() : void
- Prefills defaults for a logged-in customer: unfinished checkout first, then the account.
- boolValue() : bool
- countryOptions() : array<string, string>
- Returns country options for the select (active countries, CZ and SK first; {@see \App\Core\Utils\Helpers\CountryOptionsHelper}).
- setAddressDefaults() : void
- strValue() : string
- translatePrompt() : string
- Translates a text for a control with a disabled translator (the country select).
Methods
onAddressSuccess()
public
onAddressSuccess(Form $form) : void
Parameters
- $form : Form
createComponentAddressForm()
protected
createComponentAddressForm() : Form
Return values
FormapplyUserAccountFallback()
Prefills defaults for a logged-in customer: unfinished checkout first, then the account.
private
applyUserAccountFallback(array<string, mixed> &$defaults) : void
What the customer already filled in (held by the unfinished checkout in the session or DB
per %eshop.cart.storage%) is never overwritten; only empty fields are filled from the
account. The order is a snapshot, so the user profile is not changed.
NOTE: only fields stored on the user account (cms_system_users) are used; contacts of
the Invoicer (CustomerContact matched by e-mail) are not, because that would need a choice
among several saved addresses.
Parameters
- $defaults : array<string, mixed>
boolValue()
private
boolValue(Form $form, string $name) : bool
Parameters
- $form : Form
- $name : string
Return values
boolcountryOptions()
Returns country options for the select (active countries, CZ and SK first; {@see \App\Core\Utils\Helpers\CountryOptionsHelper}).
private
countryOptions() : array<string, string>
Return values
array<string, string>setAddressDefaults()
private
setAddressDefaults(Form $form) : void
Parameters
- $form : Form
strValue()
private
strValue(Form $form, string $name) : string
Parameters
- $form : Form
- $name : string
Return values
stringtranslatePrompt()
Translates a text for a control with a disabled translator (the country select).
private
translatePrompt(string $key) : string
Parameters
- $key : string