Get Delivery Estimates
Before you begin, make sure you have an active Dora API store token. If you don’t have one, please login into your dora account, create a store custom store and copy the generated token for that store.
Integration Steps
Integrating Dora’s Delivery Estimates API into your application is straightforward. Follow these simple steps to get started:
- Include the Dora API script in your HTML:
<script type="application/javascript" src="https://cdn.api.usedora.com/v1/chain.js"></script>
-
Implement the checkout() function in your JavaScript to trigger the delivery estimate widget.
-
Customize the checkout object with the necessary parameters such as sender address, customer details, delivery information, and callbacks.
-
Call the checkout.setup() method to prepare the widget.
-
Finally, use the checkout.open() method to display the widget and retrieve delivery estimates when the “Get Estimates” button is clicked.
Here’s a sample HTML and JavaScript code snippet to help you get started:
<button onclick="checkout()">Get Estimates</button>
<script type="application/javascript" src="https://cdn.api.usedora.com/v1/chain.js"></script>
<script type="application/javascript">
function checkout() {
const checkout = new Dora.GetEstimate({
"sender_address": "10 John Street, Ipaja, Lagos",
"customer_name": "TundeNasri",
"customer_email": "sinoma@example.com",
"customer_state_id": 4,
"customer_house_number": 4,
"customer_phone_number": "0802839***8",
"phone_code": 234,
"customer_address": "12 Ahmadu Bello way, Central Business District, Abuja",
"delivery_total_order_value": 10000,
"delivery_number_of_parcels": 1,
"delivery_unit_weight": 10,
"items": {
[
"item_description": "Freshfish",
"item_quantity": 1,
"item_weight": 10,
"item_value": 10000
]
},
onSuccess(response) {
console.log(response.event);
},
onError(error) {
console.log(error);
},
onClose(event) {
console.log("Widget closed", { event });
},
});
checkout.setup();
checkout.open();
}
</script>