Configuration options - Checkout widget
The checkout widget's appearance and behaviour can be influenced by configuration options. All configuration options are used by setting the respective properties on the "window.porterbuddy" object.
Configuration properties
Available configuration options - items in bold are required
Key | Type | Description |
---|---|---|
token | string | The public API token given to you by Porterbuddy |
view | availability | checkout | deliveryInfo | The view to start the widget in |
availabilityResponse | AvailabilityResponse | Availability Response object as returned from the Porterbuddy API. Please check Porterbuddy API documentation for an example. |
apiMode | test | production | Use this to switch between test or production mode. The default mode is the one for the environment the widget source code is loaded from. |
apiBaseUrl | string | Base URL for fetching delivery windows. Note: this configuration option is used for testing purposes only, in general, setting this option should be not necessary. This setting overrides the url determined by apiMode. |
resetContext | boolean | If set to true, all previously set properties will be reset to the default value if not defined with a new value in this context |
postalCode | string | If you already have the users postcode you can set it here to check availability immediately. For Checkout mode, this sets the store postcode to the specified value |
cssClassPrefix | string | All CSS classes in the widget are prefixed by this string. |
language | NO | EN | Language is necessary when custom texts are provided. It will set proper variable texts regarding the language set. It is only necessary when custom texts are provided. By default language is detected by users browser setting |
text | object | Texts used in the widget |
discount | number | Discount to be applied on all delivery prices shown, specified as hundreds of a value unit (e.g. discount=5000 for a price reduction by 50 NOK) |
additionalDiscounts | Dictionary: string to number | Additional discounts for price calculation in text replacements. Please check the documentation page "Multiple Discounts" for usage examples |
initialSelectedWindow | DeliveryWindow | Specify an initially selected delivery window for checkout view. Only works when delivery windows are supplied |
onSelectDeliveryWindow | function (deliveryWindow) | Function that runs when a delivery window is selected. The function is called with the selected delivery window as the only parameter. In case of anonymous consolidation, the delivery window might not contain a start and end time when the consolidated window is selected |
onUpdateDeliveryWindows | function (callback, additionalInfo) | Function that runs when delivery windows should be updated. The function is given a callback function that must be executed with an availability response once they are fetched. This is to support async fetching. The additional info object (second parameter) should be added to the availability call to the Porterbuddy API. |
updateDeliveryWindowsInterval | number | Time in seconds to wait before requesting updated delivery windows |
now | string | For testing only. Hardcode the value of now to get predictable results when testing with test data and date functions |
wrapInForm | boolean | Set if the checkout should be wrapped in a form or div element. Useful for solving e.g. validiation problems caused by nested forms |
onSetCallbacks | function(callbacks) | Function that gets called after initialization of the widget. The function argument is an object containing callback function references, which can be used to to interact with the widget from externally. |
preserveStateAcrossRerender | boolean | Normally, if the element the checkout is rendered in is removed from the document and recreated, the widget state will be re-initialized. If you want state to be preserved across such rerenderings set this option to true. (You can still force a refresh of the state with the forceRefresh callback). |
The property "onSetCallbacks" has a special behaviour. This is a callback function that gets passed function references to methods to interact with the widget during runtime. The usage of this function is explained here.
Deprecated Configuration properties
The configuration properties in this section are deprecated and kept along for backwards compatibility, but should not be used in new installations.
Key | Type | Description |
---|---|---|
deliveryWindows | DeliveryWindow[] | Delivery windows to display. NOTE: this property is deprecated, use "availabilityResponse" instead. |
showLogo | boolean | Deprecated: Not used anymore, as the new design always has an integrated logo, |