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 | 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.
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
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, 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
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.

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.