Skip to main content

Quotation Adapters

Accept and process quotation (request-for-quote) requests for shop items, manually or automatically. Several adapters can be registered; the first adapter that activates for a quotation handles it.

Creating an adapter​

Use the registerQuotation factory. Only adapterId is required — every callback has a sensible default. The example below requires manual verification and proposal. When the proposal is submitted, quote sets its expiry to one hour later.

import { registerQuotation } from '@unchainedshop/core';

registerQuotation({
adapterId: 'manual',
isManualRequestVerificationRequired: true,
isManualProposalRequired: true,
quote: async (context) => ({
expires: new Date(Date.now() + 3600 * 1000),
}),
transformItemConfiguration: async (params, context) => ({
quantity: params.quantity,
configuration: params.configuration,
}),
});

Callback reference​

OptionDescription
quote(context)produce the offer (a QuotationProposal)
transformItemConfiguration(params, context)normalize the submitted request JSON into a structured item configuration
isManualRequestVerificationRequireda request must be verified by a human before it is valid (boolean)
isManualProposalRequiredthe quote is created manually rather than automatically (boolean)
submitRequest / verifyRequest / rejectRequestlifecycle hooks returning a boolean for the corresponding transition

For full control of every IQuotationAdapter method, build the adapter directly and register it via pluginRegistry.register() — see Plugin System.