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.

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
apiMode test | development | stage | 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.
text object Texts used in the widget
deliveryWindows DeliveryWindow[] Immediately displays delivery windows when combined with view=checkout
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
showLeaveAtDoorstep boolean Specify if the "leave at doorstep" checkbox should be shown in the checkout view (default=true)
leaveAtDoorstepChecked boolean Initial value for the leave at doorstep checkbox (default=false)
initialComment string Initial value to pre-fill the comment for the courier (default='')
showLogo boolean Specify if the Porterbuddy Logo should be shown in the widget when using the checkout view (default=false)
initialSelectedWindow DeliveryWindow Specify an initially selected delivery window for checkout view. Only works when delivery windows are supplied
onComment function (comment: string) Function that runs when comment text is updated. The functions is called with the updated text as the only parameter
onLeaveAtDoorstep function (leaveAtDoorstep: boolean) Function that runs when leave at doorstep is checked. The function is called with true or false according to the checked state
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.
onUpdateDeliveryWindows function (callback) Function that runs when delivery windows should be updated. The function is given a callback function that must be executed with delivery windows once they are fetched. This is to support async fetching.
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
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.

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.