useRequestQuote
Use useRequestQuote when a product is set up as an offer/quote request instead of a direct purchase. It returns a RequestQuoteController that loads the configured inquiry form, validates input, and submits the quote request (optionally with an email) along with a snapshot of the current configuration.
Getting the controller
import { useRequestQuote, REQUEST_QUOTE_EMAIL_FIELD_KEY } from "@expivi/product-configurator";
const controller = useRequestQuote(configurator);
REQUEST_QUOTE_EMAIL_FIELD_KEY (value "_email") is the reserved key to use in your form payload for the shopper's email address.
Example: fetch the form and submit a quote
const controller = useRequestQuote(configurator);
if (controller.isVisible) {
// Load the inquiry form definition for the main product
const form = await controller.fetchForm();
await controller.submit({
first_name: "Ada",
company: "Example Inc.",
});
}
API
isVisible
Getter that returns true when the main product has an offer configuration whose status is "active".
sendEmail
Getter that returns whether the offer configuration requires an email to be sent. When true, submit() throws if no email is provided.
formId
Getter that returns the configured inquiry form id, or null.
formData
Getter that returns the most recently fetched form resource (ApiFormResourceView), or null until fetchForm() has run.
fetchForm()
Loads the form resource for the main product's configured form id and stores it on the controller (readable via formData). Resolves to null when no form id is configured.
isBusy
Getter that returns whether a submit is currently in progress. submit() is a no-op while busy.
subscribeBusy(callback)
Subscribes to busy-state changes. callback receives the new boolean value. Returns an unsubscribe function.
submit(formValues)
Submits a quote request. The method:
- Resolves the main product's offer configuration (throws
"Offer configuration not found"if missing). - Reads the email from
formValues[REQUEST_QUOTE_EMAIL_FIELD_KEY]and throws"Email is required"whensendEmailis enabled but no email is present. - Serializes the current configuration and creates a snapshot through the download design service.
- Submits to the offer inquiry service with the product offer id, offer configuration id, snapshot id,
formData, and email. - Pushes a success message on completion, or an error message and re-throws on failure — both through
useMessages(configurator).