Skip to main content
With the $wsOptions module, you read the values of template options in the frontend. Template options are settings that are defined once in the template and can then be maintained in the Admin Interface without having to adjust the template again. This lets you switch display details (for example whether the icon of a payment method appears in the footer) without touching the template. This page is about reading the option values. How options are defined (types, value limits, attachTo, display in the Admin Interface) is described in Defining template options.

Basic concept

A template option always goes through the same process: define → maintain in the Admin Interface → read in the template.
  • Define: The option is created in a template with the {{ option … }} statement (see Defining template options).
  • Become available: Defined options appear in the Admin Interface after the templates have been compiled successfully. If an option is removed from the templates again, it only disappears from the Admin Interface after the templates are compiled again.
  • Maintain: The values are set in the Admin Interface. For options bound to configurations, they can differ per configuration node (see attachTo).
  • Read: in the template via $wsOptions.get(…).

Module overview

Example / excerpt of $wsOptions
JSON output
Note: ƒ() indicates a function. Methods at a glance

Templates

Template options can be read in any template.

Variables

No variables are available for $wsOptions. Access is only possible via the get() method.

Methods

$wsOptions.get()

Returns the value of a template option maintained in the Admin Interface. Without a second parameter, a global option is read. For options bound to a configuration node with attachTo, specify the node ID as the second parameter. Signature
$wsOptions.get(name, nodeId)
Return value
The maintained value of the option. The type corresponds to the option type defined in the definition (String, Bool, Int, Float, Enum).
If the option has not yet been explicitly set in the Admin Interface, null is returned. Therefore, check the return value before using it (for example with if) so that the template does not unintentionally remain empty for an option that has not yet been maintained.
Parameters Example: global option:
Outputs the value of the intValue option. Example: option bound to a configuration node:
Returns the value of the attached option for the payment method with the configuration node payment.payment.bill (for example “Prepayment”). The second parameter is required because the same option can be set differently per node for freely creatable configurations, such as one configuration per payment method (for example disabled for “Prepayment” and enabled for “Google Pay”).

nodeId: the ID of the configuration node

Do not confuse the configuration node ID (nodeId) with the id field within a configuration. The payment.payment configuration, for example, contains its own id field (a “technical ID”). This field cannot be used as nodeId.
So that you have the correct node ID at hand, the following objects provide a nodeId field:
  • $wsAccount: addressFields
  • $wsAsse: asseConfigs
  • $wsCategories: fields, customFields
  • $wsConfig: countries, payments, shippingMethods, shippingMethodGroups, currency, emails, listElements, redirects
  • $wsForm: loadType / loadAllTypes and their fields / loadField
Here, $payment.nodeId returns the node ID of the respective payment method, which is passed directly as the second parameter.

Actions

No actions are available for $wsOptions.

Examples

In this example, an option bound to payment.payment is defined that displays in the footer only the payment methods for which the option has been enabled in the Admin Interface. This lets you decide per payment method what is displayed without adjusting the template.
Result
Only the payment methods for which the “methodLocationFooter” option is enabled are displayed in the footer. Since this option is bound to payment.payment, it is read per payment method via its nodeId. If the option is not set for a payment method, get() returns the value null and the if branch is not executed.