Subchapter 2.72
references/SERVICE_PLUGIN.mdMarkdown6 KBView on GitHub
Service plugins are a set of APIs defined by Wix that let you inject custom logic into the existing backend flows of Wix business solutions or introduce entirely new flows. When you implement a service plugin, Wix calls your custom functions during specific flows. Common use cases include eCommerce customization (shipping, fees, payment settings, validations) and Bookings customization (staff sorting).
Use wix generate --params with extensionType: SERVICE_PLUGIN. pluginType is one of:
| Value | SPI | Singular |
|---|---|---|
ECOM_ADDITIONAL_FEES | Additional Fees | No |
ECOM_SHIPPING_RATES | Shipping Rates | Yes |
ECOM_DISCOUNTS_TRIGGER | Discount Triggers | Yes |
ECOM_VALIDATIONS | Validations | No |
ECOM_PAYMENT_SETTINGS | Payment Settings | No |
GIFT_CARDS_PROVIDER | Gift Cards Provider | Yes |
STAFF_SORTING_PROVIDER | Bookings Staff Sorting | No |
REALTIME_PERMISSIONS_PROVIDER | Realtime Permissions Provider | No |
Singular types —
ECOM_SHIPPING_RATES,ECOM_DISCOUNTS_TRIGGER, andGIFT_CARDS_PROVIDERare singular: only one component of each type is allowed per app. Never scaffold or include two components of the same singular type in the same app payload.
name must be lowercase alphanumeric + hyphens, max 19 characters. The CLI generates the folder, plugin.ts, the builder file, the UUID, and the src/extensions.ts registration with the appropriate builder method for the SPI type. Some SPI types (e.g., ECOM_SHIPPING_RATES) get a description placeholder field in the generated builder — replace it with your real copy.
You MUST read the relevant reference document before implementing an SPI, and call ReadFullDocsMethodSchema with the docs URL it points at to get the exact request/response types — do NOT edit code until you have the schema. If the schema alone isn’t enough, follow up with ReadFullDocsArticle on the same URL for prose explanations and additional code examples. Each reference also contains the correct imports, handler signatures, response structures, and a worked example.
| SPI Type | Reference |
|---|---|
| Additional Fees | ADDITIONAL-FEES.md |
| Discount Triggers | DISCOUNT-TRIGGERS.md |
| Gift Cards | GIFT-CARDS.md |
| Payment Settings | PAYMENT-SETTINGS.md |
| Shipping Rates | SHIPPING-RATES.md |
| Validations | VALIDATIONS.md |
| Bookings Staff Sorting | BOOKINGS-STAFF-SORTING.md |
The scaffolded plugin.ts imports the relevant module from the SPI’s package (@wix/ecom/service-plugins, @wix/bookings/service-plugins, etc.) and calls provideHandlers({...}). Each handler is invoked by Wix on the relevant flow with a { request, metadata } payload and must return the SPI-specific response shape — see the per-SPI reference (Shipping Rates, Validations, etc.) for the exact request/response types and a worked example.
When making Wix API calls from service plugins, wrap the SDK method with auth.elevate from @wix/essentials before calling it. The pattern is identical for every Wix SDK module (@wix/data, @wix/ecom, @wix/stores, etc.):
import { auth } from "@wix/essentials";
import { items } from "@wix/data";
const elevated = auth.elevate(items.query);
const response = await elevated("myCollection");The CLI generates a builder with id, name, and source. Some SPI types accept additional optional fields you may want to set in the generated builder file:
| SPI Type | Builder Method | Additional Optional Fields |
|---|---|---|
| Shipping Rates | ecomShippingRates() | description, learnMoreUrl, dashboardUrl, fallbackDefinitionMandatory, thumbnailUrl |
| Validations | ecomValidations() | validateInCart |
| Payment Settings | ecomPaymentSettings() | fallbackValueForRequires3dSecure |
| Bookings Staff Sorting | bookingsStaffSortingProvider() | methodName (required), methodDescription (required, max 100 chars), dashboardPluginId |
Only ecomShippingRates() accepts description. Passing unsupported fields to other builders causes TypeScript errors. bookingsStaffSortingProvider() requires methodName and methodDescription fields — set these in the generated builder file after scaffolding.
Performance: keep handler logic efficient. Most SPIs run on hot paths (every cart view, every checkout step, etc.).
To test your service plugin extension: