@wix/agent-skills 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +111 -0
- package/package.json +29 -0
- package/skills/wix-app/SKILL.md +344 -0
- package/skills/wix-app/references/APP_IDENTIFIERS.md +35 -0
- package/skills/wix-app/references/APP_MARKET_REVIEW.md +311 -0
- package/skills/wix-app/references/APP_VALIDATION.md +171 -0
- package/skills/wix-app/references/BACKEND_API.md +233 -0
- package/skills/wix-app/references/BACKEND_EVENT.md +116 -0
- package/skills/wix-app/references/CODE_QUALITY.md +33 -0
- package/skills/wix-app/references/CUSTOM_ELEMENT_WIDGET.md +587 -0
- package/skills/wix-app/references/DASHBOARD_MENU_PLUGIN.md +157 -0
- package/skills/wix-app/references/DASHBOARD_MODAL.md +283 -0
- package/skills/wix-app/references/DASHBOARD_PAGE.md +403 -0
- package/skills/wix-app/references/DASHBOARD_PLUGIN.md +205 -0
- package/skills/wix-app/references/DATA_COLLECTION.md +451 -0
- package/skills/wix-app/references/DOCUMENTATION.md +42 -0
- package/skills/wix-app/references/EDITOR_REACT_COMPONENT.md +65 -0
- package/skills/wix-app/references/EMBEDDED_SCRIPT.md +468 -0
- package/skills/wix-app/references/EXTENSION_REGISTRATION.md +96 -0
- package/skills/wix-app/references/SERVICE_PLUGIN.md +235 -0
- package/skills/wix-app/references/SITE_PLUGIN.md +436 -0
- package/skills/wix-app/references/STORES_VERSIONING.md +334 -0
- package/skills/wix-app/references/backend-event/COMMON-EVENTS.md +84 -0
- package/skills/wix-app/references/custom-element-widget/SETTINGS_PANEL.md +345 -0
- package/skills/wix-app/references/dashboard-menu-plugin/blog-slots.md +71 -0
- package/skills/wix-app/references/dashboard-menu-plugin/bookings-slots.md +58 -0
- package/skills/wix-app/references/dashboard-menu-plugin/crm-slots.md +8 -0
- package/skills/wix-app/references/dashboard-menu-plugin/ecommerce-slots.md +17 -0
- package/skills/wix-app/references/dashboard-menu-plugin/events-slots.md +29 -0
- package/skills/wix-app/references/dashboard-menu-plugin/restaurants-slots.md +27 -0
- package/skills/wix-app/references/dashboard-menu-plugin/stores-slots.md +35 -0
- package/skills/wix-app/references/dashboard-page/API_SPEC.md +138 -0
- package/skills/wix-app/references/dashboard-page/DASHBOARD_API.md +573 -0
- package/skills/wix-app/references/dashboard-page/DYNAMIC_PARAMETERS.md +269 -0
- package/skills/wix-app/references/dashboard-page/ECOM_NAVIGATION.md +164 -0
- package/skills/wix-app/references/dashboard-plugin/SLOTS.md +294 -0
- package/skills/wix-app/references/data-collection/WIX_DATA.md +270 -0
- package/skills/wix-app/references/data-collection/extension-template.ts +107 -0
- package/skills/wix-app/references/editor-react-component/ACCESSIBILITY.md +138 -0
- package/skills/wix-app/references/editor-react-component/COMPONENT-API.md +454 -0
- package/skills/wix-app/references/editor-react-component/COMPONENT-CONFIGURATION.md +165 -0
- package/skills/wix-app/references/editor-react-component/CSS-GUIDELINES.md +576 -0
- package/skills/wix-app/references/editor-react-component/DIRECTIONALITY.md +170 -0
- package/skills/wix-app/references/editor-react-component/EDIT-FLOW.md +6 -0
- package/skills/wix-app/references/editor-react-component/PARTS.md +25 -0
- package/skills/wix-app/references/editor-react-component/PROPS-VS-CSS.md +203 -0
- package/skills/wix-app/references/editor-react-component/REACT-GUIDELINES.md +167 -0
- package/skills/wix-app/references/editor-react-component/REACT-PATTERNS.md +137 -0
- package/skills/wix-app/references/service-plugin/ADDITIONAL-FEES.md +112 -0
- package/skills/wix-app/references/service-plugin/BOOKINGS-STAFF-SORTING.md +118 -0
- package/skills/wix-app/references/service-plugin/DISCOUNT-TRIGGERS.md +87 -0
- package/skills/wix-app/references/service-plugin/GIFT-CARDS.md +86 -0
- package/skills/wix-app/references/service-plugin/PAYMENT-SETTINGS.md +135 -0
- package/skills/wix-app/references/service-plugin/SHIPPING-RATES.md +79 -0
- package/skills/wix-app/references/service-plugin/VALIDATIONS.md +68 -0
- package/skills/wix-app/references/site-plugin/EXAMPLES.md +311 -0
- package/skills/wix-app/references/site-plugin/SLOTS.md +263 -0
- package/skills/wix-design-system/SKILL.md +129 -0
- package/skills/wix-design-system/references/file-structure.md +56 -0
- package/skills/wix-design-system/scripts/wds.cjs +531 -0
- package/skills/wix-headless/SKILL.md +418 -0
- package/skills/wix-headless/references/DISCOVERY.md +332 -0
- package/skills/wix-headless/references/ORCHESTRATION.md +269 -0
- package/skills/wix-headless/references/SETUP.md +154 -0
- package/skills/wix-headless/references/blog/BLOG_CONTENT.md +152 -0
- package/skills/wix-headless/references/blog/BLOG_PAGES.md +299 -0
- package/skills/wix-headless/references/blog/BLOG_SETUP.md +218 -0
- package/skills/wix-headless/references/blog/INSTRUCTIONS.md +32 -0
- package/skills/wix-headless/references/cms/CMS_FOUNDATIONS.md +373 -0
- package/skills/wix-headless/references/cms/FAQ_KNOWLEDGE_BASE.md +229 -0
- package/skills/wix-headless/references/cms/INSTRUCTIONS.md +40 -0
- package/skills/wix-headless/references/cms/PORTFOLIO.md +454 -0
- package/skills/wix-headless/references/cms/RESOURCE_LIBRARY.md +356 -0
- package/skills/wix-headless/references/cms/TEAM_DIRECTORY.md +299 -0
- package/skills/wix-headless/references/commands/install-app.md +42 -0
- package/skills/wix-headless/references/commands/known-apps.json +5 -0
- package/skills/wix-headless/references/commands/mcp-bootstrap.md +28 -0
- package/skills/wix-headless/references/designer/INSTRUCTIONS.md +828 -0
- package/skills/wix-headless/references/ecom/CART_PAGES.md +120 -0
- package/skills/wix-headless/references/ecom/CART_WIRING.md +103 -0
- package/skills/wix-headless/references/ecom/COMPONENTS_CSS.md +132 -0
- package/skills/wix-headless/references/ecom/INSTRUCTIONS.md +59 -0
- package/skills/wix-headless/references/forms/CONTACT_FORM.md +477 -0
- package/skills/wix-headless/references/forms/INSTRUCTIONS.md +43 -0
- package/skills/wix-headless/references/gift-cards/COMPONENTS.md +119 -0
- package/skills/wix-headless/references/gift-cards/INSTRUCTIONS.md +51 -0
- package/skills/wix-headless/references/gift-cards/PAGES.md +129 -0
- package/skills/wix-headless/references/images/INSTRUCTIONS.md +359 -0
- package/skills/wix-headless/references/shared/BUILD_NOISE.md +8 -0
- package/skills/wix-headless/references/shared/IMAGE_GENERATION.md +185 -0
- package/skills/wix-headless/references/shared/IMPLEMENTER.md +155 -0
- package/skills/wix-headless/references/shared/MCP_PREFIX.md +105 -0
- package/skills/wix-headless/references/shared/PRODUCTION_SHARP_EDGES.md +97 -0
- package/skills/wix-headless/references/shared/RETURN_CONTRACT.md +423 -0
- package/skills/wix-headless/references/shared/STYLING.md +117 -0
- package/skills/wix-headless/references/stores/BACK_IN_STOCK.md +178 -0
- package/skills/wix-headless/references/stores/CATEGORY_PAGES.md +86 -0
- package/skills/wix-headless/references/stores/COMPONENTS_CSS.md +129 -0
- package/skills/wix-headless/references/stores/HOME_AND_NAV.md +227 -0
- package/skills/wix-headless/references/stores/INSTRUCTIONS.md +96 -0
- package/skills/wix-headless/references/stores/PRODUCT_CATALOG_DATA.md +249 -0
- package/skills/wix-headless/references/stores/PRODUCT_PAGES.md +213 -0
- package/skills/wix-headless/references/stores/SHARED_WIRING.md +164 -0
- package/skills/wix-headless/references/verticals/_schema.json +160 -0
- package/skills/wix-headless/references/verticals/_schema.md +185 -0
- package/skills/wix-headless/references/verticals/blog.md +125 -0
- package/skills/wix-headless/references/verticals/cms.md +121 -0
- package/skills/wix-headless/references/verticals/ecom.md +96 -0
- package/skills/wix-headless/references/verticals/forms.md +106 -0
- package/skills/wix-headless/references/verticals/gift-cards.md +121 -0
- package/skills/wix-headless/references/verticals/stores.md +167 -0
- package/skills/wix-headless/scripts/check-manifest.mjs +198 -0
- package/skills/wix-headless/scripts/copy-utility-templates.mjs +153 -0
- package/skills/wix-headless/scripts/emit-design-tokens.mjs +77 -0
- package/skills/wix-headless/scripts/finalize-run-json.mjs +141 -0
- package/skills/wix-headless/scripts/init-site-json.mjs +63 -0
- package/skills/wix-headless/scripts/patch-decorative-slots.mjs +124 -0
- package/skills/wix-headless/scripts/plan-entity-image-waves.mjs +190 -0
- package/skills/wix-headless/scripts/preview.sh +45 -0
- package/skills/wix-headless/scripts/release.sh +73 -0
- package/skills/wix-headless/scripts/scaffold.sh +53 -0
- package/skills/wix-headless/scripts/seed-utilities.sh +55 -0
- package/skills/wix-headless/shared-utilities/analytics.ts +40 -0
- package/skills/wix-headless/shared-utilities/ricos.ts +179 -0
- package/skills/wix-headless/shared-utilities/wix-image.ts +72 -0
- package/skills/wix-headless/templates/ecom/CartBadge.tsx +84 -0
- package/skills/wix-headless/templates/ecom/CartView.tsx +543 -0
- package/skills/wix-headless/templates/ecom/cart.astro +13 -0
- package/skills/wix-headless/templates/ecom/components-ecom.css +215 -0
- package/skills/wix-headless/templates/ecom/discounts.ts +71 -0
- package/skills/wix-headless/templates/ecom/thank-you.astro +24 -0
- package/skills/wix-headless/templates/gift-cards/GiftCardPurchase.tsx +172 -0
- package/skills/wix-headless/templates/gift-cards/_home-teaser-snippet.astro +42 -0
- package/skills/wix-headless/templates/gift-cards/_nav-snippet.astro +11 -0
- package/skills/wix-headless/templates/gift-cards/components-gift-cards.css +219 -0
- package/skills/wix-headless/templates/gift-cards/gift-cards.astro +51 -0
- package/skills/wix-headless/templates/gift-cards/gift-cards.ts +75 -0
- package/skills/wix-headless/templates/stores/AddToCartButton.tsx +77 -0
- package/skills/wix-headless/templates/stores/BackInStockForm.tsx +176 -0
- package/skills/wix-headless/templates/stores/CategoryRail.astro +69 -0
- package/skills/wix-headless/templates/stores/ProductCard.astro +79 -0
- package/skills/wix-headless/templates/stores/ProductPurchase.tsx +397 -0
- package/skills/wix-headless/templates/stores/SeoTags.astro +21 -0
- package/skills/wix-headless/templates/stores/back-in-stock.ts +67 -0
- package/skills/wix-headless/templates/stores/categories.ts +155 -0
- package/skills/wix-headless/templates/stores/category/[slug].astro +130 -0
- package/skills/wix-headless/templates/stores/components-stores.css +295 -0
- package/skills/wix-headless/templates/stores/products/[slug].astro +128 -0
- package/skills/wix-headless/templates/stores/products/index.astro +101 -0
- package/skills/wix-manage/SKILL.md +280 -0
- package/skills/wix-manage/references/app-installation/install-wix-apps.md +155 -0
- package/skills/wix-manage/references/app-installation/list-installed-apps.md +124 -0
- package/skills/wix-manage/references/blog/how-to-create-blog-posts.md +226 -0
- package/skills/wix-manage/references/bookings/booking-service-policy-setup.md +95 -0
- package/skills/wix-manage/references/bookings/booking-system-integration-gaps.md +416 -0
- package/skills/wix-manage/references/bookings/bookings-staff-setup.md +255 -0
- package/skills/wix-manage/references/bookings/create-and-update-booking-services.md +462 -0
- package/skills/wix-manage/references/bookings/end-to-end-booking-flow.md +278 -0
- package/skills/wix-manage/references/bookings/external-calendar-integration.md +258 -0
- package/skills/wix-manage/references/bookings/multi-resource-service-creation.md +231 -0
- package/skills/wix-manage/references/calendar/configure-default-business-hours.md +226 -0
- package/skills/wix-manage/references/cms/cms-data-items-crud.md +422 -0
- package/skills/wix-manage/references/cms/cms-data-operations-extended.md +263 -0
- package/skills/wix-manage/references/cms/cms-ecommerce-catalog-integration.md +136 -0
- package/skills/wix-manage/references/cms/cms-references-and-relationships.md +160 -0
- package/skills/wix-manage/references/cms/cms-schema-management.md +143 -0
- package/skills/wix-manage/references/contacts/bulk-delete-contacts.md +73 -0
- package/skills/wix-manage/references/contacts/bulk-label-and-unlabel-contacts.md +67 -0
- package/skills/wix-manage/references/domains/domain-search-and-purchase.md +434 -0
- package/skills/wix-manage/references/ecommerce/api-recommendation-tracking.md +420 -0
- package/skills/wix-manage/references/ecommerce/flow-add-free-shipping.md +267 -0
- package/skills/wix-manage/references/ecommerce/flow-bundle-and-save.md +290 -0
- package/skills/wix-manage/references/ecommerce/flow-fix-coverage-gaps.md +300 -0
- package/skills/wix-manage/references/ecommerce/flow-optimize-shipping-rates.md +364 -0
- package/skills/wix-manage/references/ecommerce/flow-seasonal-promotion.md +315 -0
- package/skills/wix-manage/references/ecommerce/flow-stock-mover.md +308 -0
- package/skills/wix-manage/references/ecommerce/flow-upsell-boost.md +271 -0
- package/skills/wix-manage/references/ecommerce/goal-clear-inventory.md +118 -0
- package/skills/wix-manage/references/ecommerce/goal-drive-cross-sells.md +122 -0
- package/skills/wix-manage/references/ecommerce/goal-increase-aov.md +132 -0
- package/skills/wix-manage/references/ecommerce/goal-reduce-cart-abandonment.md +148 -0
- package/skills/wix-manage/references/ecommerce/goal-seasonal-revenue.md +146 -0
- package/skills/wix-manage/references/ecommerce/guardrail-discount-conflicts.md +118 -0
- package/skills/wix-manage/references/ecommerce/guardrail-margin-protection.md +88 -0
- package/skills/wix-manage/references/ecommerce/guardrail-rate-pricing-sanity.md +108 -0
- package/skills/wix-manage/references/ecommerce/guardrail-shipping-health.md +124 -0
- package/skills/wix-manage/references/ecommerce/recipe-apply-shipping-recommendations.md +299 -0
- package/skills/wix-manage/references/ecommerce/recommend-ecommerce-strategy.md +582 -0
- package/skills/wix-manage/references/ecommerce/setup-coupons.md +338 -0
- package/skills/wix-manage/references/ecommerce/setup-discount-rules.md +444 -0
- package/skills/wix-manage/references/ecommerce/setup-shipping-rates.md +86 -0
- package/skills/wix-manage/references/ecommerce/setup-shipping-regions.md +56 -0
- package/skills/wix-manage/references/ecommerce/setup-store-pickup-location.md +209 -0
- package/skills/wix-manage/references/ecommerce/skill-graph.md +139 -0
- package/skills/wix-manage/references/ecommerce/troubleshoot-checkout-delivery-dropoff.md +124 -0
- package/skills/wix-manage/references/ecommerce/troubleshoot-discount-not-applying.md +95 -0
- package/skills/wix-manage/references/events/list-events.md +203 -0
- package/skills/wix-manage/references/forms/create-form.md +260 -0
- package/skills/wix-manage/references/get-paid/create-payment-links.md +212 -0
- package/skills/wix-manage/references/get-paid/how-to-setup-wix-payments.md +57 -0
- package/skills/wix-manage/references/get-paid/payment-links-for-bookings.md +101 -0
- package/skills/wix-manage/references/media/upload-media-to-wix.md +216 -0
- package/skills/wix-manage/references/pricing-plans/create-and-update-pricing-plans.md +77 -0
- package/skills/wix-manage/references/pricing-plans/pricing-plans-bookings-integration.md +166 -0
- package/skills/wix-manage/references/restaurants/wix-restaurants-setup.md +336 -0
- package/skills/wix-manage/references/rich-content/ricos-converter-service.md +295 -0
- package/skills/wix-manage/references/site-properties/change-payment-currency-site-properties.md +59 -0
- package/skills/wix-manage/references/sites/create-site-from-template.md +183 -0
- package/skills/wix-manage/references/sites/query-sites.md +125 -0
- package/skills/wix-manage/references/stores/add-store-pages-to-site.md +57 -0
- package/skills/wix-manage/references/stores/bulk-create-products-with-options.md +1041 -0
- package/skills/wix-manage/references/stores/create-product-catalog-v1.md +125 -0
- package/skills/wix-manage/references/stores/create-product-from-image.md +824 -0
- package/skills/wix-manage/references/stores/create-product-with-options-catalog-v3.md +566 -0
- package/skills/wix-manage/references/stores/find-products-query-and-search-catalog-v3.md +194 -0
- package/skills/wix-manage/references/stores/query-products-catalog-v1.md +80 -0
- package/skills/wix-manage/references/stores/setup-online-store-catalog-v3.md +99 -0
- package/skills/wix-manage/references/stores/update-product-pre-order.md +213 -0
- package/skills/wix-manage/references/stores/update-product-with-options.md +318 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
|
|
2
|
+
# Wix Service Plugin (SPI) Builder
|
|
3
|
+
|
|
4
|
+
Creates service plugin extensions for Wix CLI applications. Service plugins are a set of APIs defined by Wix that you can use to inject custom logic into the existing backend flows of Wix business solutions or to introduce entirely new flows to Wix sites.
|
|
5
|
+
|
|
6
|
+
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), but service plugins can extend any Wix business solution that exposes SPIs.
|
|
7
|
+
|
|
8
|
+
## Quick Start Checklist
|
|
9
|
+
|
|
10
|
+
Follow these steps in order when creating a service plugin:
|
|
11
|
+
|
|
12
|
+
1. [ ] **Read the reference doc** for your SPI type, then **STOP and call `ReadFullDocsMethodSchema`** with the docs URL from the reference to get the exact request/response types — **DO NOT write any code until you have the schema**
|
|
13
|
+
2. [ ] Create plugin folder: `src/extensions/backend/service-plugins/<service-type>/<plugin-name>/`
|
|
14
|
+
3. [ ] Create `plugin.ts` with correct imports and `provideHandlers()` call
|
|
15
|
+
4. [ ] Implement all required handler functions with complete business logic
|
|
16
|
+
5. [ ] Create `extensions.ts` with appropriate builder method and unique UUID
|
|
17
|
+
6. [ ] Update `src/extensions.ts` to import and use the new extension
|
|
18
|
+
7. [ ] Run `npx tsc --noEmit` to verify TypeScript compiles
|
|
19
|
+
8. [ ] Run `npx wix build` to verify build succeeds
|
|
20
|
+
9. [ ] Test by triggering the relevant site action (e.g., add to cart for fees)
|
|
21
|
+
|
|
22
|
+
## References
|
|
23
|
+
|
|
24
|
+
**You MUST read the relevant reference document before implementing a relevant SPI.** Each reference contains the correct imports, handler signatures, response structures, and working examples.
|
|
25
|
+
|
|
26
|
+
| SPI Type | Reference |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| Additional Fees | [ADDITIONAL-FEES.md](service-plugin/ADDITIONAL-FEES.md) |
|
|
29
|
+
| Discount Triggers | [DISCOUNT-TRIGGERS.md](service-plugin/DISCOUNT-TRIGGERS.md) |
|
|
30
|
+
| Gift Cards | [GIFT-CARDS.md](service-plugin/GIFT-CARDS.md) |
|
|
31
|
+
| Payment Settings | [PAYMENT-SETTINGS.md](service-plugin/PAYMENT-SETTINGS.md) |
|
|
32
|
+
| Shipping Rates | [SHIPPING-RATES.md](service-plugin/SHIPPING-RATES.md) |
|
|
33
|
+
| Validations | [VALIDATIONS.md](service-plugin/VALIDATIONS.md) |
|
|
34
|
+
| Bookings Staff Sorting | [BOOKINGS-STAFF-SORTING.md](service-plugin/BOOKINGS-STAFF-SORTING.md) |
|
|
35
|
+
|
|
36
|
+
## Output Structure
|
|
37
|
+
|
|
38
|
+
Service plugins consist of two files that work together. Registration of plugins requires an extension builder file.
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
src/extensions/backend/service-plugins/
|
|
42
|
+
└── {service-type}/
|
|
43
|
+
└── {plugin-name}/
|
|
44
|
+
├── plugin.ts # Handler logic with provideHandlers()
|
|
45
|
+
└── extensions.ts # Builder configuration (id, name, source)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### File Descriptions
|
|
49
|
+
|
|
50
|
+
| File | Purpose |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `plugin.ts` | Contains the service plugin handler logic with `provideHandlers()` - this is where you implement your custom business logic |
|
|
53
|
+
| `extensions.ts` | Contains the service plugin builder configuration with id (GUID), name, source path, and builder-specific optional fields |
|
|
54
|
+
|
|
55
|
+
## Implementation Requirements
|
|
56
|
+
|
|
57
|
+
### Generation Requirements
|
|
58
|
+
|
|
59
|
+
1. **Implement ALL required handler functions** with complete business logic
|
|
60
|
+
2. **Include proper TypeScript types and error handling**
|
|
61
|
+
3. **Focus on implementing the EXACT business logic** described in the user prompt
|
|
62
|
+
|
|
63
|
+
### Implementation Patterns
|
|
64
|
+
|
|
65
|
+
- **If capabilities are undocumented/unavailable**, explicitly state the gap and proceed only with documented minimal logic
|
|
66
|
+
- **Implement all required handler functions** according to Wix specifications
|
|
67
|
+
- **Never use placeholders** - always implement complete, working functionality
|
|
68
|
+
|
|
69
|
+
### Data Validation
|
|
70
|
+
|
|
71
|
+
All service plugins must include comprehensive data validation:
|
|
72
|
+
|
|
73
|
+
- **Validate all input data** from Wix requests
|
|
74
|
+
- **Ensure required fields** are present and properly formatted
|
|
75
|
+
- **Handle missing or malformed data** gracefully
|
|
76
|
+
- **Validate business logic constraints** (e.g., minimum order amounts, valid addresses)
|
|
77
|
+
|
|
78
|
+
## Implementation Pattern
|
|
79
|
+
|
|
80
|
+
The handler file (`plugin.ts`) contains the service plugin logic. It must:
|
|
81
|
+
|
|
82
|
+
1. Import the relevant service plugin from the appropriate package (e.g., `@wix/ecom/service-plugins` for eCommerce, `@wix/bookings/service-plugins` for Bookings)
|
|
83
|
+
2. Call `provideHandlers()` with an object containing handler functions
|
|
84
|
+
3. Each handler function receives a payload with `request` and `metadata`
|
|
85
|
+
4. Return the expected response structure for that SPI type
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { shippingRates } from "@wix/ecom/service-plugins";
|
|
89
|
+
|
|
90
|
+
shippingRates.provideHandlers({
|
|
91
|
+
getShippingRates: async (payload) => {
|
|
92
|
+
const { request, metadata } = payload;
|
|
93
|
+
|
|
94
|
+
// Implement custom logic based on request data
|
|
95
|
+
// - request contains cart items, shipping address, etc.
|
|
96
|
+
// - metadata contains currency, locale, etc.
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
shippingRates: [
|
|
100
|
+
{
|
|
101
|
+
code: "custom-shipping",
|
|
102
|
+
title: "Custom Shipping",
|
|
103
|
+
logistics: {
|
|
104
|
+
deliveryTime: "3-5 business days",
|
|
105
|
+
},
|
|
106
|
+
cost: {
|
|
107
|
+
price: "9.99",
|
|
108
|
+
currency: metadata.currency || "USD",
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Handler functions are called automatically by Wix when the relevant site action triggers them. Your custom logic should be placed inside each handler function.
|
|
118
|
+
|
|
119
|
+
## Elevating Permissions for API Calls
|
|
120
|
+
|
|
121
|
+
When making Wix API calls from service plugins, you must elevate permissions using `auth.elevate` from `@wix/essentials`.
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { auth } from "@wix/essentials";
|
|
125
|
+
import { items } from "@wix/data";
|
|
126
|
+
|
|
127
|
+
export const myFunction = async () => {
|
|
128
|
+
const elevatedFunction = auth.elevate(items.query);
|
|
129
|
+
const elevatedResponse = await elevatedFunction("myCollection");
|
|
130
|
+
return elevatedResponse;
|
|
131
|
+
};
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { auth } from "@wix/essentials";
|
|
136
|
+
import { cart } from "@wix/ecom";
|
|
137
|
+
|
|
138
|
+
export const myFunction = async () => {
|
|
139
|
+
const elevatedFunction = auth.elevate(cart.getCart);
|
|
140
|
+
const elevatedResponse = await elevatedFunction("cart-id");
|
|
141
|
+
return elevatedResponse;
|
|
142
|
+
};
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
import { auth } from "@wix/essentials";
|
|
147
|
+
import { products } from "@wix/stores";
|
|
148
|
+
|
|
149
|
+
export const myFunction = async () => {
|
|
150
|
+
const elevatedFunction = auth.elevate(products.deleteCollection);
|
|
151
|
+
const elevatedResponse = await elevatedFunction("collection-id");
|
|
152
|
+
return elevatedResponse;
|
|
153
|
+
};
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Best Practices
|
|
157
|
+
|
|
158
|
+
### Development Workflow
|
|
159
|
+
|
|
160
|
+
- **Always implement complete, working functionality** - never use placeholders
|
|
161
|
+
- **Handle all required fields** according to Wix documentation
|
|
162
|
+
- **Implement proper validation** for all input data
|
|
163
|
+
- **Return responses in exact format** expected by Wix
|
|
164
|
+
- **Add comprehensive error handling** for all failure scenarios
|
|
165
|
+
- **Use meaningful variable names** and clear code structure
|
|
166
|
+
- **Test thoroughly** with different input combinations
|
|
167
|
+
|
|
168
|
+
### Implementation Guidelines
|
|
169
|
+
|
|
170
|
+
- **Validate all input:** Check required fields are present and properly formatted
|
|
171
|
+
- **Handle errors gracefully:** Return appropriate error responses, don't throw unhandled exceptions
|
|
172
|
+
- **Return exact format:** Responses must match Wix documented structure exactly
|
|
173
|
+
- **Use TypeScript types:** Leverage SDK types for better type safety
|
|
174
|
+
- **Test edge cases:** Empty carts, missing addresses, invalid data
|
|
175
|
+
- **Performance:** Keep calculations efficient - these run on every checkout
|
|
176
|
+
- **Logging:** Add console.log for debugging but keep production logs minimal
|
|
177
|
+
|
|
178
|
+
## Extension Registration
|
|
179
|
+
|
|
180
|
+
**Extension registration is MANDATORY and has TWO required steps.**
|
|
181
|
+
|
|
182
|
+
### Step 1: Create Plugin-Specific Extension File
|
|
183
|
+
|
|
184
|
+
Each service plugin requires an `extensions.ts` file in its folder with the appropriate builder method for the SPI type:
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
import { extensions } from "@wix/astro/builders";
|
|
188
|
+
|
|
189
|
+
export const ecomadditionalfeesMyFees = extensions.ecomAdditionalFees({
|
|
190
|
+
id: "{{GENERATE_UUID}}",
|
|
191
|
+
name: "My Additional Fees",
|
|
192
|
+
source: "./extensions/backend/service-plugins/ecom-additional-fees/my-fees/plugin.ts",
|
|
193
|
+
});
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**CRITICAL: UUID Generation**
|
|
197
|
+
|
|
198
|
+
The `id` must be a unique, static UUID v4 string. Generate a fresh UUID for each extension - do NOT use `randomUUID()` or copy UUIDs from examples. Replace `{{GENERATE_UUID}}` with a freshly generated UUID like `"a1b2c3d4-e5f6-7890-abcd-ef1234567890"`.
|
|
199
|
+
|
|
200
|
+
### Builder Configuration Fields
|
|
201
|
+
|
|
202
|
+
All builder methods accept these three fields:
|
|
203
|
+
|
|
204
|
+
| Field | Type | Description |
|
|
205
|
+
| --- | --- | --- |
|
|
206
|
+
| `id` | string | Service plugin ID as a GUID. Must be unique across all extensions in the project. |
|
|
207
|
+
| `name` | string | The service plugin name (visible in app dashboard when developing an app). |
|
|
208
|
+
| `source` | string | Path to the service plugin handler file that contains the plugin logic. |
|
|
209
|
+
|
|
210
|
+
**Builder methods by SPI type and their accepted fields:**
|
|
211
|
+
|
|
212
|
+
| SPI Type | Builder Method | Accepted Fields |
|
|
213
|
+
| ----------------- | ------------------------ | --------------- |
|
|
214
|
+
| Shipping Rates | `ecomShippingRates()` | `id`, `name`, `source`, `description`, `learnMoreUrl`, `dashboardUrl`, `fallbackDefinitionMandatory`, `thumbnailUrl` |
|
|
215
|
+
| Additional Fees | `ecomAdditionalFees()` | `id`, `name`, `source` |
|
|
216
|
+
| Validations | `ecomValidations()` | `id`, `name`, `source`, `validateInCart` |
|
|
217
|
+
| Discount Triggers | `ecomDiscountTriggers()` | `id`, `name`, `source` |
|
|
218
|
+
| Gift Cards | `ecomGiftCards()` | `id`, `name`, `source` |
|
|
219
|
+
| Payment Settings | `ecomPaymentSettings()` | `id`, `name`, `source`, `fallbackValueForRequires3dSecure` |
|
|
220
|
+
| Bookings Staff Sorting | `bookingsStaffSortingProvider()` | `id`, `name`, `source`, `methodName`, `methodDescription` (max 100 chars), `dashboardPluginId` |
|
|
221
|
+
|
|
222
|
+
Only `ecomShippingRates()` accepts `description`. Passing unsupported fields to other builders causes TypeScript errors. `bookingsStaffSortingProvider()` requires `methodName` and `methodDescription` fields (methodDescription has a 100-character limit), and optionally accepts `dashboardPluginId`.
|
|
223
|
+
|
|
224
|
+
### Step 2: Register in Main Extensions File
|
|
225
|
+
|
|
226
|
+
**CRITICAL:** After creating the plugin-specific extension file, you MUST read [Extension Registration reference](EXTENSION_REGISTRATION.md) and follow the "App Registration" section to update `src/extensions.ts`.
|
|
227
|
+
|
|
228
|
+
**Without completing Step 2, the service plugin will not be active in the eCommerce system.**
|
|
229
|
+
|
|
230
|
+
## Testing Service Plugins
|
|
231
|
+
|
|
232
|
+
To test your service plugin extension:
|
|
233
|
+
|
|
234
|
+
1. **Release a version** with your changes - new service plugins or changes to existing ones won't take effect until you've built and released your project
|
|
235
|
+
2. **Trigger the call** to your service plugin by performing the relevant action (e.g., add items to cart and view cart to test Additional Fees)
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
|
|
2
|
+
# Wix Site Plugin Builder
|
|
3
|
+
|
|
4
|
+
Creates site plugin extensions for Wix CLI applications. Site plugins are custom elements that integrate into predefined **slots** within Wix business solutions (like Wix Stores, Wix Bookings, Wix eCommerce), extending their functionality and user experience.
|
|
5
|
+
|
|
6
|
+
Site owners can place site plugins into UI slots using the plugin explorer in Wix editors.
|
|
7
|
+
|
|
8
|
+
## Quick Start Checklist
|
|
9
|
+
|
|
10
|
+
Follow these steps in order when creating a site plugin:
|
|
11
|
+
|
|
12
|
+
1. [ ] Create plugin folder: `src/extensions/site/plugins/<plugin-name>/`
|
|
13
|
+
2. [ ] Create `<plugin-name>.tsx` extending `HTMLElement` with `observedAttributes`
|
|
14
|
+
3. [ ] Create `<plugin-name>.panel.tsx` with WDS components and `widget.getProp/setProp`
|
|
15
|
+
4. [ ] Create `<plugin-name>.extension.ts` with `extensions.sitePlugin()` and unique UUID
|
|
16
|
+
5. [ ] Update `src/extensions.ts` to import and use the new extension
|
|
17
|
+
|
|
18
|
+
## Architecture
|
|
19
|
+
|
|
20
|
+
Site plugins consist of **three required files**:
|
|
21
|
+
|
|
22
|
+
### 1. Plugin Component (`<plugin-name>.tsx`)
|
|
23
|
+
|
|
24
|
+
Custom element component that renders in the slot using native HTMLElement:
|
|
25
|
+
|
|
26
|
+
- Extend `HTMLElement` class
|
|
27
|
+
- Define `observedAttributes` for reactive properties
|
|
28
|
+
- Implement `connectedCallback()` and `attributeChangedCallback()` for rendering
|
|
29
|
+
- Use inline styles via template strings
|
|
30
|
+
- Attributes use **kebab-case** (e.g., `display-name`)
|
|
31
|
+
|
|
32
|
+
### 2. Settings Panel (`<plugin-name>.panel.tsx`)
|
|
33
|
+
|
|
34
|
+
Settings panel shown in the Wix Editor sidebar:
|
|
35
|
+
|
|
36
|
+
- Uses Wix Design System (`@wix/design-system`) components — see the `wix-design-system` skill for component reference
|
|
37
|
+
- Manages plugin properties via `@wix/editor` widget API
|
|
38
|
+
- Loads initial values with `widget.getProp('kebab-case-name')`
|
|
39
|
+
- Updates properties with `widget.setProp('kebab-case-name', value)`
|
|
40
|
+
- Widget properties are bound to custom element attributes — any property change automatically updates the corresponding attribute
|
|
41
|
+
- Wrapped in `WixDesignSystemProvider > SidePanel > SidePanel.Content`
|
|
42
|
+
|
|
43
|
+
### 3. Extension Configuration (`<plugin-name>.extension.ts`)
|
|
44
|
+
|
|
45
|
+
Defines the plugin's placement configuration:
|
|
46
|
+
|
|
47
|
+
- Specifies which slots the plugin can be added to
|
|
48
|
+
- Configures auto-add behavior on app installation
|
|
49
|
+
- Sets the tag name and file paths
|
|
50
|
+
|
|
51
|
+
## Plugin Component Pattern
|
|
52
|
+
|
|
53
|
+
Site plugins use native `HTMLElement` custom elements:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
// my-site-plugin.tsx
|
|
57
|
+
class MyElement extends HTMLElement {
|
|
58
|
+
static get observedAttributes() {
|
|
59
|
+
return ['display-name'];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
constructor() {
|
|
63
|
+
super();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
connectedCallback() {
|
|
67
|
+
this.render();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
attributeChangedCallback() {
|
|
71
|
+
this.render();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
render() {
|
|
75
|
+
const displayName = this.getAttribute('display-name') || "Your Plugin's Title";
|
|
76
|
+
|
|
77
|
+
this.innerHTML = `
|
|
78
|
+
<div style="font-size: 16px; padding: 16px; border: 1px solid #ccc; border-radius: 8px; margin: 16px;">
|
|
79
|
+
<h2>${displayName}</h2>
|
|
80
|
+
<hr />
|
|
81
|
+
<p>
|
|
82
|
+
This is a Site Plugin generated by Wix CLI.<br />
|
|
83
|
+
Edit your element's code to change this text.
|
|
84
|
+
</p>
|
|
85
|
+
</div>
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default MyElement;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Key Points:**
|
|
94
|
+
|
|
95
|
+
- Extend `HTMLElement` class directly
|
|
96
|
+
- Define `observedAttributes` static getter to list reactive attributes
|
|
97
|
+
- Attributes use **kebab-case** (e.g., `display-name`, `bg-color`)
|
|
98
|
+
- Implement `connectedCallback()` for initial render
|
|
99
|
+
- Implement `attributeChangedCallback()` to re-render when attributes change
|
|
100
|
+
- Use inline styles via template strings
|
|
101
|
+
- Use `this.getAttribute('attribute-name')` to read attribute values
|
|
102
|
+
- Wix handles `define()` for you — do NOT call `customElements.define()` in your code
|
|
103
|
+
|
|
104
|
+
## Settings Panel Pattern
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
// my-site-plugin.panel.tsx
|
|
108
|
+
import React, { type FC, useState, useEffect, useCallback } from 'react';
|
|
109
|
+
import { widget } from '@wix/editor';
|
|
110
|
+
import {
|
|
111
|
+
SidePanel,
|
|
112
|
+
WixDesignSystemProvider,
|
|
113
|
+
Input,
|
|
114
|
+
FormField,
|
|
115
|
+
} from '@wix/design-system';
|
|
116
|
+
import '@wix/design-system/styles.global.css';
|
|
117
|
+
|
|
118
|
+
const Panel: FC = () => {
|
|
119
|
+
const [displayName, setDisplayName] = useState<string>('');
|
|
120
|
+
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
widget.getProp('display-name')
|
|
123
|
+
.then(displayName => setDisplayName(displayName || "Your Plugin's Title"))
|
|
124
|
+
.catch(error => console.error('Failed to fetch display-name:', error));
|
|
125
|
+
}, [setDisplayName]);
|
|
126
|
+
|
|
127
|
+
const handleDisplayNameChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
|
|
128
|
+
const newDisplayName = event.target.value;
|
|
129
|
+
setDisplayName(newDisplayName);
|
|
130
|
+
widget.setProp('display-name', newDisplayName);
|
|
131
|
+
}, [setDisplayName]);
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<WixDesignSystemProvider>
|
|
135
|
+
<SidePanel width="300" height="100vh">
|
|
136
|
+
<SidePanel.Content noPadding stretchVertically>
|
|
137
|
+
<SidePanel.Field>
|
|
138
|
+
<FormField label="Display Name">
|
|
139
|
+
<Input
|
|
140
|
+
type="text"
|
|
141
|
+
value={displayName}
|
|
142
|
+
onChange={handleDisplayNameChange}
|
|
143
|
+
aria-label="Display Name"
|
|
144
|
+
/>
|
|
145
|
+
</FormField>
|
|
146
|
+
</SidePanel.Field>
|
|
147
|
+
</SidePanel.Content>
|
|
148
|
+
</SidePanel>
|
|
149
|
+
</WixDesignSystemProvider>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export default Panel;
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Key Points:**
|
|
157
|
+
|
|
158
|
+
- Prop names in `widget.getProp()` and `widget.setProp()` use **kebab-case** (e.g., `"display-name"`)
|
|
159
|
+
- Always update both local state AND widget prop in onChange handlers
|
|
160
|
+
- Widget properties are bound to custom element attributes — changes automatically update the corresponding attribute
|
|
161
|
+
- Wrap content in `WixDesignSystemProvider > SidePanel > SidePanel.Content`
|
|
162
|
+
- Use WDS components from `@wix/design-system`
|
|
163
|
+
- Import `@wix/design-system/styles.global.css` for styles
|
|
164
|
+
- Include `aria-label` for accessibility
|
|
165
|
+
|
|
166
|
+
## Color & Font Picker Fields
|
|
167
|
+
|
|
168
|
+
Site plugin settings panels can use `inputs.selectColor()` and `inputs.selectFont()` from `@wix/editor` to open the native Wix Editor color and font picker dialogs.
|
|
169
|
+
|
|
170
|
+
### ColorPickerField
|
|
171
|
+
|
|
172
|
+
Opens the Wix color picker with theme colors, gradients, and more — **NOT** a basic HTML `<input type="color">`.
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import React, { type FC } from 'react';
|
|
176
|
+
import { inputs } from '@wix/editor';
|
|
177
|
+
import { FormField, Box, FillPreview, SidePanel } from '@wix/design-system';
|
|
178
|
+
|
|
179
|
+
interface ColorPickerFieldProps {
|
|
180
|
+
label: string;
|
|
181
|
+
value: string;
|
|
182
|
+
onChange: (value: string) => void;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export const ColorPickerField: FC<ColorPickerFieldProps> = ({
|
|
186
|
+
label,
|
|
187
|
+
value,
|
|
188
|
+
onChange,
|
|
189
|
+
}) => (
|
|
190
|
+
<SidePanel.Field>
|
|
191
|
+
<FormField label={label}>
|
|
192
|
+
<Box width="30px" height="30px">
|
|
193
|
+
<FillPreview
|
|
194
|
+
fill={value}
|
|
195
|
+
onClick={() => inputs.selectColor(value, { onChange: (val) => { if (val) onChange(val); } })}
|
|
196
|
+
/>
|
|
197
|
+
</Box>
|
|
198
|
+
</FormField>
|
|
199
|
+
</SidePanel.Field>
|
|
200
|
+
);
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### FontPickerField
|
|
204
|
+
|
|
205
|
+
Opens the Wix font picker with font family, size, bold, italic, and other typography features.
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
import React, { type FC } from 'react';
|
|
209
|
+
import { inputs } from '@wix/editor';
|
|
210
|
+
import { FormField, Button, Text, SidePanel } from '@wix/design-system';
|
|
211
|
+
|
|
212
|
+
interface FontValue {
|
|
213
|
+
font: string;
|
|
214
|
+
textDecoration: string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
interface FontPickerFieldProps {
|
|
218
|
+
label: string;
|
|
219
|
+
value: FontValue;
|
|
220
|
+
onChange: (value: FontValue) => void;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export const FontPickerField: FC<FontPickerFieldProps> = ({
|
|
224
|
+
label,
|
|
225
|
+
value,
|
|
226
|
+
onChange,
|
|
227
|
+
}) => (
|
|
228
|
+
<SidePanel.Field>
|
|
229
|
+
<FormField label={label}>
|
|
230
|
+
<Button
|
|
231
|
+
size="small"
|
|
232
|
+
priority="secondary"
|
|
233
|
+
onClick={() => inputs.selectFont(value, { onChange: (val) => onChange({ font: val.font, textDecoration: val.textDecoration || "" }) })}
|
|
234
|
+
fullWidth
|
|
235
|
+
>
|
|
236
|
+
<Text size="small" ellipsis>Change Font</Text>
|
|
237
|
+
</Button>
|
|
238
|
+
</FormField>
|
|
239
|
+
</SidePanel.Field>
|
|
240
|
+
);
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**Important:**
|
|
244
|
+
- Always use `inputs.selectColor()` from `@wix/editor` with `FillPreview` — do NOT use `<Input type="color">`
|
|
245
|
+
- Always use `inputs.selectFont()` from `@wix/editor` with the callback pattern `inputs.selectFont(value, { onChange })`
|
|
246
|
+
- Import `inputs` from `@wix/editor` (not from `@wix/sdk`)
|
|
247
|
+
|
|
248
|
+
## Attribute Naming Convention
|
|
249
|
+
|
|
250
|
+
Site plugins use **kebab-case** consistently for HTML attributes:
|
|
251
|
+
|
|
252
|
+
| File | Convention | Example |
|
|
253
|
+
| --------------------------------- | ---------- | ---------------------------------- |
|
|
254
|
+
| `<plugin>.tsx` (getAttribute) | kebab-case | `this.getAttribute('display-name')` |
|
|
255
|
+
| `<plugin>.tsx` (observedAttributes) | kebab-case | `['display-name', 'bg-color']` |
|
|
256
|
+
| `<plugin>.panel.tsx` (widget API) | kebab-case | `widget.getProp('display-name')` |
|
|
257
|
+
|
|
258
|
+
## Output Structure
|
|
259
|
+
|
|
260
|
+
Site plugins live under `src/extensions/site/plugins`. Each plugin has its own folder with files named after the plugin.
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
src/extensions/site/plugins/
|
|
264
|
+
└── {plugin-name}/
|
|
265
|
+
├── {plugin-name}.tsx # Main plugin component (HTMLElement)
|
|
266
|
+
├── {plugin-name}.panel.tsx # Settings panel component
|
|
267
|
+
└── {plugin-name}.extension.ts # Extension registration
|
|
268
|
+
public/
|
|
269
|
+
└── {plugin-name}-logo.svg # Plugin logo (optional)
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## References
|
|
273
|
+
|
|
274
|
+
| Topic | Reference |
|
|
275
|
+
| --- | --- |
|
|
276
|
+
| Complete Examples | [EXAMPLES.md](site-plugin/EXAMPLES.md) |
|
|
277
|
+
| Slots (App IDs, multiple placements, finding slots) | [SLOTS.md](site-plugin/SLOTS.md) |
|
|
278
|
+
| WDS Components | the `wix-design-system` skill |
|
|
279
|
+
|
|
280
|
+
## Available Slots
|
|
281
|
+
|
|
282
|
+
Site plugins integrate into predefined slots in Wix business solutions. Each slot is identified by:
|
|
283
|
+
|
|
284
|
+
- **appDefinitionId**: The ID of the Wix app (e.g., Stores, Bookings)
|
|
285
|
+
- **widgetId**: The ID of the page containing the slot
|
|
286
|
+
- **slotId**: The specific slot identifier
|
|
287
|
+
|
|
288
|
+
Common placement areas include product pages (Wix Stores), checkout and side cart (Wix eCommerce), booking pages (Wix Bookings), service pages, event pages, and blog post pages.
|
|
289
|
+
|
|
290
|
+
For supported pages, common Wix App IDs, and how to find slot IDs, see [SLOTS.md](site-plugin/SLOTS.md).
|
|
291
|
+
|
|
292
|
+
## Extension Registration
|
|
293
|
+
|
|
294
|
+
**Extension registration is MANDATORY and has TWO required steps.**
|
|
295
|
+
|
|
296
|
+
### Step 1: Create Plugin-Specific Extension File
|
|
297
|
+
|
|
298
|
+
Each site plugin requires an extension file in its folder:
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
// my-site-plugin.extension.ts
|
|
302
|
+
import { extensions } from '@wix/astro/builders';
|
|
303
|
+
|
|
304
|
+
export default extensions.sitePlugin({
|
|
305
|
+
id: '{{GENERATE_UUID}}',
|
|
306
|
+
name: 'My Site Plugin',
|
|
307
|
+
marketData: {
|
|
308
|
+
name: 'My Site Plugin',
|
|
309
|
+
description: 'Marketing Description',
|
|
310
|
+
logoUrl: '{{BASE_URL}}/my-site-plugin-logo.svg',
|
|
311
|
+
},
|
|
312
|
+
placements: [{
|
|
313
|
+
appDefinitionId: 'a0c68605-c2e7-4c8d-9ea1-767f9770e087',
|
|
314
|
+
widgetId: '6a25b678-53ec-4b37-a190-65fcd1ca1a63',
|
|
315
|
+
slotId: 'product-page-details-6',
|
|
316
|
+
}],
|
|
317
|
+
installation: { autoAdd: true },
|
|
318
|
+
tagName: 'my-site-plugin',
|
|
319
|
+
element: './extensions/site/plugins/my-site-plugin/my-site-plugin.tsx',
|
|
320
|
+
settings: './extensions/site/plugins/my-site-plugin/my-site-plugin.panel.tsx',
|
|
321
|
+
});
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**CRITICAL: UUID Generation**
|
|
325
|
+
|
|
326
|
+
The `id` must be a unique, static UUID v4 string. Generate a fresh UUID for each extension - do NOT use `randomUUID()` or copy UUIDs from examples. Replace `{{GENERATE_UUID}}` with a freshly generated UUID like `"95a28afd-7df1-4e09-9ec1-ce710b0389a0"`.
|
|
327
|
+
|
|
328
|
+
| Property | Type | Description |
|
|
329
|
+
| -------------------------- | ------- | --------------------------------------------------------------- |
|
|
330
|
+
| `id` | string | Unique static UUID v4 (generate fresh) |
|
|
331
|
+
| `name` | string | Internal name for the plugin |
|
|
332
|
+
| `marketData.name` | string | Display name in plugin explorer and app dashboard |
|
|
333
|
+
| `marketData.description` | string | Description shown in plugin explorer and app dashboard |
|
|
334
|
+
| `marketData.logoUrl` | string | Path to logo file (`{{BASE_URL}}` resolves to public folder) |
|
|
335
|
+
| `placements` | array | Array of slot placements where plugin can be added |
|
|
336
|
+
| `placements.appDefinitionId` | string | ID of the Wix app containing the slot |
|
|
337
|
+
| `placements.widgetId` | string | ID of the page containing the slot |
|
|
338
|
+
| `placements.slotId` | string | ID of the specific slot |
|
|
339
|
+
| `installation.autoAdd` | boolean | Whether to auto-add plugin to slots on app installation |
|
|
340
|
+
| `tagName` | string | HTML custom element tag (kebab-case, must contain a hyphen) |
|
|
341
|
+
| `element` | string | Relative path to plugin component |
|
|
342
|
+
| `settings` | string | Relative path to settings panel component |
|
|
343
|
+
|
|
344
|
+
### Step 2: Register in Main Extensions File
|
|
345
|
+
|
|
346
|
+
**CRITICAL:** After creating the plugin-specific extension file, you MUST read [Extension Registration reference](EXTENSION_REGISTRATION.md) and follow the "App Registration" section to update `src/extensions.ts`.
|
|
347
|
+
|
|
348
|
+
**Without completing Step 2, the site plugin will not be available in the plugin explorer.**
|
|
349
|
+
|
|
350
|
+
## Checkout Plugins
|
|
351
|
+
|
|
352
|
+
If you are building a plugin for the **checkout page**, it may not support automatic addition upon installation. You must create a dashboard page to provide users with a way to add the plugin to their site. See [EXAMPLES.md](site-plugin/EXAMPLES.md) for the dashboard page pattern.
|
|
353
|
+
|
|
354
|
+
## Examples
|
|
355
|
+
|
|
356
|
+
For complete examples with all three required files (plugin component, settings panel, extension configuration), see [EXAMPLES.md](site-plugin/EXAMPLES.md).
|
|
357
|
+
|
|
358
|
+
**Example use cases:**
|
|
359
|
+
|
|
360
|
+
- **Best Seller Badge** - Customizable badge on product pages with text and color settings
|
|
361
|
+
- **Booking Confirmation** - Custom confirmation message for booking pages
|
|
362
|
+
- **Product Reviews Summary** - Star rating and review count display
|
|
363
|
+
- **Data-Driven Plugin** - Plugin with Wix Data API integration and editor environment handling
|
|
364
|
+
|
|
365
|
+
## Best Practices
|
|
366
|
+
|
|
367
|
+
### Implementation Guidelines
|
|
368
|
+
|
|
369
|
+
- **Use inline styles** - CSS imports are not supported in custom elements
|
|
370
|
+
- **Handle editor environment** - Show placeholders when in editor mode for data-dependent plugins
|
|
371
|
+
- **Do not call `define()`** - Wix handles `customElements.define()` for you automatically
|
|
372
|
+
- **Validate all input** - Check required props are present
|
|
373
|
+
- **Follow naming conventions** - kebab-case for all attributes and widget API
|
|
374
|
+
- **Keep plugins focused** - Each plugin should do one thing well
|
|
375
|
+
- **Test in multiple slots** - If supporting multiple placements, test each one
|
|
376
|
+
- **Support both Stores versions** - Include placements for both old and new Wix Stores product pages for maximum compatibility
|
|
377
|
+
|
|
378
|
+
### Editor Sandboxing
|
|
379
|
+
|
|
380
|
+
Site plugins are sandboxed when rendered in the editor. This means they're treated as if they come from a different domain, which impacts access to browser storage APIs.
|
|
381
|
+
|
|
382
|
+
**Restricted APIs in the editor:**
|
|
383
|
+
- `localStorage` and `sessionStorage` (Web Storage API)
|
|
384
|
+
- `document.cookie` (Cookie Store API)
|
|
385
|
+
- IndexedDB API
|
|
386
|
+
- Cache API
|
|
387
|
+
|
|
388
|
+
**How to handle sandboxing:**
|
|
389
|
+
|
|
390
|
+
Use the `viewMode()` function from `@wix/site-window` to check the current mode before accessing restricted APIs:
|
|
391
|
+
|
|
392
|
+
```typescript
|
|
393
|
+
import { window as wixWindow } from '@wix/site-window';
|
|
394
|
+
|
|
395
|
+
const viewMode = await wixWindow.viewMode();
|
|
396
|
+
|
|
397
|
+
if (viewMode === 'Site') {
|
|
398
|
+
const item = localStorage.getItem('myKey');
|
|
399
|
+
} else {
|
|
400
|
+
// Mock storage or modify API usage for editor mode
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### Using Wix SDK Modules in Site Plugins
|
|
405
|
+
|
|
406
|
+
Site plugins can import and use Wix SDK modules directly — you do NOT need `createClient()`. The Wix runtime provides the client context automatically.
|
|
407
|
+
|
|
408
|
+
```typescript
|
|
409
|
+
// ✅ CORRECT — Import SDK modules directly
|
|
410
|
+
import { items } from "@wix/data";
|
|
411
|
+
import { currentCart } from "@wix/ecom";
|
|
412
|
+
import { products } from "@wix/stores";
|
|
413
|
+
|
|
414
|
+
class MyPlugin extends HTMLElement {
|
|
415
|
+
async loadData() {
|
|
416
|
+
// Call SDK methods directly — no createClient needed
|
|
417
|
+
const result = await items.query("MyCollection").find();
|
|
418
|
+
const cart = await currentCart.getCurrentCart();
|
|
419
|
+
const productList = await products.queryProducts().limit(10).find();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
```typescript
|
|
425
|
+
// ❌ WRONG — Do NOT use createClient in site plugins
|
|
426
|
+
import { createClient } from "@wix/sdk";
|
|
427
|
+
const wixClient = createClient({ modules: { items, products } });
|
|
428
|
+
await wixClient.items.query(...); // Wrong — API surface differs through client
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
### Performance Considerations
|
|
432
|
+
|
|
433
|
+
- Keep bundle size small - plugins load on user-facing pages
|
|
434
|
+
- Avoid heavy computations on initial render
|
|
435
|
+
- Lazy load data when possible
|
|
436
|
+
- Use efficient re-rendering patterns
|