Product Ask Questions API¶
Api name: ProductAskQuestionsApi
.
API used to ask for a given product without the need to use the product-ask-questions webcomponent.
classDiagram
direction LR
ProductAskQuestionsApi --> askForProduct
class ProductAskQuestionsApi {
askForProduct(askForProductProps: TAskForProductProps): Promise~TResponseStatus|undefined~
}
link askForProduct "../methods/ask-for-product/"
Get API¶
To get the Product Ask Questions API
use its name ProductAskQuestionsApi
with the getApi
method.
useStorefront(async (storefront) => {
const productAskQuestionsApi = await storefront.getApi('ProductAskQuestionsApi');
});
Methods¶
- askForProduct - allows to ask questions for a given product
Event Bus events¶
Methods of this API dispatch the following events with the Event Bus:
- productAskQuestions.askForProductSuccess
- FlashMessengerApi.addFlashMessage
- FlashMessengerApi.addFlashMessages
Example¶
In this example we make a ProductAskQuestionsApi
call to ask for a specific product.
useStorefront(async (storefront) => {
const productAskQuestionsApi = await storefront.getApi('ProductAskQuestionsApi');
await productAskQuestionsApi.askForProduct({
productId: 12,
askQuestionDetails: {
mail: 'email@example.com',
question: 'Is this available in a white version?'
}
});
});