We have a list of events that you can access when relevant actions are taken in the widget. Those events are accessible through the ZapietEvent interface.
To listen to the events described here, use the window.ZapietEvent.listen() method. This method accepts two arguments:
The event name
An optional callback function with the event's payload
Example:
window.ZapietEvent.listen("widget_loaded", function() {
alert("Zapiet widget loaded!");
});Take a look at our Widget API documentation for more information.
Available events
Preparation time, slot limits and conditional activation are supported via locations API.
The following events are available in v7.0.5 and above:
widget_loadedFired when the widget finishes loading in the page and is ready to be used.
selected_methodFired when a checkout method is selected in the widget.
Payload type:
"delivery" | "pickup" | "shipping"Example:
window.ZapietEvent.listen("selected_method", function(checkout_method) {
switch (checkout_method) {
case "pickup":
// Do something when pickup is selected
break;
case "delivery":
// Do something when delivery is selected
break;
case "shipping":
// Do something when shipping is selected
break;
}
});
delivery.datepicker.renderedFired when the delivery calendar is rendered on the page.
delivery.datepicker.openedFired when the delivery calendar is opened.
delivery.timepicker.renderedFired when the delivery time picker is rendered on the page.
delivery.timepicker.openedFired when the delivery time picker is opened.
pickup.datepicker.renderedFired when the pickup calendar is rendered on the page.
pickup.datepicker.openedFired when the pickup calendar is opened.
pickup.timepicker.renderedFired when the pickup time picker is rendered on the page.
pickup.timepicker.openedFired when the delivery time picker is opened.
shipping.datepicker.renderedFired when the shipping calendar is rendered on the page.
shipping.datepicker.openedFired when the shipping calendar is opened.
checkoutEnabledFired when the checkout button is enabled and provides the checkout params.
Payload type:
{
method: "pickup" | "shipping" | "delivery",
location: {
id: number,
company_name: string,
date_picker_enabled: boolean,
latitude: string,
longitude: string,
address_line_1: string,
address_line_2: string,
city: string,
country: string,
postal_code: string,
region: string,
region_code: string,
slots: array,
custom_attribute_1: string,
custom_attribute_2: string,
custom_attribute_3: string,
more_information: string,
opening_hours: any,
distance: string,
limits_enabled: string,
time_picker_enabled: boolean
},
date: string,
time: string,
start_time: string,
slot_id: number,
postal_code: string
}Example:
window.ZapietEvent.listen("checkoutEnabled", function(params) {
if (params.method == "pickup") {
console.log("Checkout enabled with Store pickup selected");
}
});
The following events are currently available on the newest version of our app:
Zapiet.setCheckoutMethod( "delivery" | "pickup" | "shipping"):Used to select a checkout method: Shipping, Delivery or Pickup.
Zapiet.getSelectedCheckoutMethod():Used to get the selected checkout method.
Zapiet.getAvailableCheckoutMethods():Used to get available checkout methods.
locationSelectedFired whenever a location is selected, either for delivery or pickup.
Payload type:
{
method: "pickup" | "shipping" | "delivery",
location: {
id: number,
company_name: string,
date_picker_enabled: boolean,
latitude: string,
longitude: string,
address_line_1: string,
address_line_2: string,
city: string,
country: string,
postal_code: string,
region: string,
region_code: string,
slots: array,
custom_attribute_1: string,
custom_attribute_2: string,
custom_attribute_3: string,
more_information: string,
opening_hours: any,
distance: string,
limits_enabled: string,
time_picker_enabled: boolean
}
}Example:
window.ZapietEvent.listen("locationSelected", function(params) {
if (params.method == "pickup") {
console.log("Pickup location selected: " + params.location.company_name);
}
});
Cart attributes
We use the Shopify Cart API to add the necessary attributes to your orders.
List of the possible attributes:
Checkout-Method: "pickup" | "delivery" | "shipping"Pickup-Location-IdPickup-Location-CompanyPickup-Location-Address-Line-1Pickup-Location-Address-Line-2Pickup-Location-CityPickup-Location-RegionPickup-Location-Postal-CodePickup-Location-CountryPickup-DatePickup-TimeDelivery-Location-IdDelivery-DateDelivery-TimeDelivery-Slot-Id(Internal use only)Shipping-DateCustom-Attribute-1Custom-Attribute-2Custom-Attribute-3
