To add a delivery method selector to your website, include the Delivery Gateway SDK script and mount the DGW object. This allows customers to select between home delivery or pickup point delivery via a modal interface.
<!-- 1. Add the SDK script to your HTML -->
<script src="https://api.deliverygateway.io/sdk/en.js" async></script>
<!-- 2. Configure and mount the widget in JavaScript -->
<script>
function deliveryMethodSelector(DGW) {
DGW.mount({
containerId: "delivery-gateway", // The HTML ID of the container element
merchantId: "your-merchant-id", // Your unique merchant ID
view: {
type: "delivery-method-selection",
openSelectedMethodInModal: true,
operatorsAsSeparateMethods: true,
},
});
}
// Handle script loading: use window.DGW if already loaded, otherwise set the callback
if (window.DGW) {
deliveryMethodSelector(window.DGW);
} else {
window.DGWOnLoad = deliveryMethodSelector;
}
</script>