productAskQuestions.askForProductSuccess¶
productAskQuestions.askForProductSuccess
is an event on the Event Bus that occurs whenever the user successfully submits the ask for product form.
Event body¶
The productAskQuestions.askForProductSuccess
body has a TAskQuestionDetails type which represents the details of the submitted question. It is optional so it might not exist.
Example¶
In this example we listen to productAskQuestions.askForProductSuccess
event and perform an action whenever it's emitted.
useStorefront(async (storefront) => {
storefront.eventBus.on('productAskQuestions.askForProductSuccess', ({ body: askQuestionDetails }) => {
console.log('A question has been asked', askQuestionDetails);
});
});
Example¶
In this example we use a Message Storage API to retrieve an array of past productAskQuestions.askForProductSuccess
events.
useStorefront((storefront) => {
const messageStorageApi = storefront.getApiSync('messageStorageSystemApi');
const pastAskForProductSuccessEvents = messageStorageApi.getChannelMessages('productAskQuestions.askForProductSuccess');
if (pastAskForProductSuccessEvents.length > 0) {
pastAskForProductSuccessEvents.forEach(({ body: eventBody }) => {
console.log('perform action on every past event');
});
}
});