Events using shippo.on()
The Shipping Elements framework emits lifecycle and action events as the user is interacting with the widget. Event listeners can be added using the on() method as such:
Event List
| Event | Description |
|---|---|
| APP_READY | The widget is rendered and ready to receive configuration or events. |
| CLOSE_BUTTON_CLICKED | The user clicked the close button to close the widget. |
| ORDER_CREATED | A Shippo order object was created for the data passed into Elements. |
| LABEL_PURCHASED_SUCCESS | A label was successfully purchased. |
| ERROR | Any error has occurred. |
| ORDERS_CREATED | Shippo orders object was created for the data passed into Elements. |
| ORDERS_CREATED_ERROR | Something went wrong in created orders within our system. |
noteUsing the
shippo.off() method removes the listener for that callback event.Event Parameters
Each event has unique parameters to the callback function, here are some examples:LABEL_PURCHASED_SUCCESS
TheLABEL_PURCHASED_SUCCESS event returns an array of transaction objects as the parameter to the callback function passed to the on() method:
ORDER_CREATED
TheORDER_CREATED event returns a shipment object with the order_id as the parameter to the callback function passed to the on() method:
ORDERS_CREATED event sends an array of order objects (same as above) as the parameter to the callback function passed to the on() method.
Errors
TheERROR event returns an error object as the parameter to the call function passed to the on() method: