Builds a custom shopping cart checkout rule type contributed by this app. Obtained from checkoutRuleTypeBuilder on the controller mappings. A checkout rule can inspect the cart items before checkout is allowed and can take part in processing the checkout itself. Set the two function names and any configuration fields, then call build to register the rule type.
Group: Builders
Methods
checkItemsFn(String s)
Returns: CheckoutRuleTypeBuilder
Names the function called to check the items in the cart against this rule, which is what allows the rule to block or warn about a checkout.
| Parameter | Description |
|---|---|
s | name of the global JavaScript function that checks the cart items |
processCheckoutFn(String s)
Returns: CheckoutRuleTypeBuilder
Names the function called when the checkout is processed, letting the rule do its own work as part of completing the order.
| Parameter | Description |
|---|---|
s | name of the global JavaScript function that processes the checkout |
addTextField(String id, String text, boolean required)
Returns: CheckoutRuleTypeBuilder
Adds a free text configuration field that an administrator fills in when adding this rule to a shopping cart.
| Parameter | Description |
|---|---|
id | identifier of the field, which is also the key its value is stored under |
text | label shown next to the field |
required | true if the administrator must supply a value |
addSelectField(String id, String text, boolean required, List<String> options)
Returns: CheckoutRuleTypeBuilder
Adds a drop down configuration field with a fixed list of options that an administrator chooses from when adding this rule.
| Parameter | Description |
|---|---|
id | identifier of the field, which is also the key its value is stored under |
text | label shown next to the field |
required | true if the administrator must supply a value |
options | the values offered in the drop down |
build()
Returns: void
Creates the checkout rule type from the configured values and registers it against this app. Does nothing if the app's engine has already finished initialising.