@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,137 @@
|
|
|
1
|
+
# React Component Patterns
|
|
2
|
+
|
|
3
|
+
Code patterns and common mistakes for Editor React components.
|
|
4
|
+
|
|
5
|
+
# Part 1: Implementation Patterns
|
|
6
|
+
|
|
7
|
+
## 1.1 SSR-Safe Implementation
|
|
8
|
+
|
|
9
|
+
Avoid browser-only APIs at module scope or during render; use them inside `useEffect` with `typeof window !== 'undefined'`.
|
|
10
|
+
|
|
11
|
+
**❌ Wrong:**
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
const userAgent = window.navigator.userAgent;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**✅ Correct:**
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (typeof window !== "undefined") {
|
|
22
|
+
const userAgent = window.navigator.userAgent;
|
|
23
|
+
}
|
|
24
|
+
}, []);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 1.2 Element Visibility (Platform-Managed)
|
|
28
|
+
|
|
29
|
+
See [`PROPS-VS-CSS.md`](PROPS-VS-CSS.md) — element visibility is platform-managed; always render all elements, no conditional rendering.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
# Part 2: CSS/SCSS Rules
|
|
34
|
+
|
|
35
|
+
Authoritative SCSS rules: `REACT-GUIDELINES.md` Part 2. For RTL/logical CSS patterns, see [`DIRECTIONALITY.md`](DIRECTIONALITY.md).
|
|
36
|
+
|
|
37
|
+
## 2.1 What NOT to Include
|
|
38
|
+
|
|
39
|
+
```scss
|
|
40
|
+
// ❌ NEVER include:
|
|
41
|
+
|
|
42
|
+
// State CSS
|
|
43
|
+
&:hover { ... } // ❌
|
|
44
|
+
&:focus { ... } // ❌
|
|
45
|
+
&:disabled { ... } // ❌
|
|
46
|
+
&[data-state='open'] { ... } // ❌
|
|
47
|
+
|
|
48
|
+
// Transitions/Animations
|
|
49
|
+
transition: all 0.3s; // ❌
|
|
50
|
+
animation: fadeIn 0.5s; // ❌
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
# Part 3: Common Mistakes
|
|
56
|
+
|
|
57
|
+
## 3.1 Adding interaction-state CSS to parts
|
|
58
|
+
|
|
59
|
+
The resting visual (background, color, border-radius, padding, font)
|
|
60
|
+
belongs in the component's CSS — see `CSS-GUIDELINES.md` §"Keep all
|
|
61
|
+
styling in CSS". What does NOT belong is **interaction-state CSS**
|
|
62
|
+
(`:hover`, `:focus`, `:focus-visible`, `:active`, `:disabled`,
|
|
63
|
+
`[data-state]`, `[aria-selected]`) — the platform owns those.
|
|
64
|
+
Selection / mode variants (`selected`, `active`, `open`) are
|
|
65
|
+
different — they go through a JS-toggled modifier class; see
|
|
66
|
+
`CSS-GUIDELINES.md` §"Express selection / mode variants".
|
|
67
|
+
|
|
68
|
+
**❌ Wrong — pseudo-class rules must be removed:**
|
|
69
|
+
|
|
70
|
+
```scss
|
|
71
|
+
.button {
|
|
72
|
+
background-color: #ffffff;
|
|
73
|
+
color: #0f172a;
|
|
74
|
+
border-radius: 8px;
|
|
75
|
+
padding-block: 8px;
|
|
76
|
+
padding-inline: 16px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.button:hover { /* ❌ Interaction state — platform owns this */
|
|
80
|
+
background-color: #f0f0f0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.button:disabled { /* ❌ Interaction state — platform owns this */
|
|
84
|
+
opacity: 0.5;
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**✅ Correct — keep the resting visual; drop the pseudo-class rules:**
|
|
89
|
+
|
|
90
|
+
```scss
|
|
91
|
+
.button {
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
background-color: #ffffff;
|
|
95
|
+
color: #0f172a;
|
|
96
|
+
border-radius: 8px;
|
|
97
|
+
padding-block: 8px;
|
|
98
|
+
padding-inline: 16px;
|
|
99
|
+
box-sizing: border-box;
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## 3.2 Browser APIs at module scope
|
|
104
|
+
|
|
105
|
+
**❌ Wrong:**
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
const isMobile = window.innerWidth < 768; // ❌ SSR breaks
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**✅ Correct:**
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (typeof window !== "undefined") {
|
|
116
|
+
setIsMobile(window.innerWidth < 768);
|
|
117
|
+
}
|
|
118
|
+
}, []);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## 3.3 Use semantic HTML for collection-style UI
|
|
122
|
+
|
|
123
|
+
For lists, breadcrumbs, tabs, menus, and similar collection-style UI, render the underlying semantic HTML directly (`<ol>`/`<ul>` + `<li>`, `<nav>`, `<button role="tab">`, etc.) and own the keyboard / ARIA wiring in your own React code.
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
<ol className="breadcrumbs">
|
|
127
|
+
<li>
|
|
128
|
+
<a href="/">Home</a>
|
|
129
|
+
</li>
|
|
130
|
+
<li>
|
|
131
|
+
<span aria-hidden="true">/</span>
|
|
132
|
+
<a href="/products">Products</a>
|
|
133
|
+
</li>
|
|
134
|
+
</ol>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Handle separators with CSS pseudo-elements or inside each item.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Additional Fees Service Plugin Reference
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Additional Fees SPI allows you to add custom fees to orders during checkout, such as handling fees, rush delivery charges, or global order fees.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { additionalFees } from '@wix/ecom/service-plugins';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Handler
|
|
14
|
+
|
|
15
|
+
| Handler | Description |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `calculateAdditionalFees` | Calculate and return additional fees to apply to the order |
|
|
18
|
+
|
|
19
|
+
## Request and Response Schema
|
|
20
|
+
|
|
21
|
+
Before implementing, call `ReadFullDocsMethodSchema` with the docs URL below to get the full request/response types.
|
|
22
|
+
|
|
23
|
+
**MCP Tools to use:**
|
|
24
|
+
- `ReadFullDocsMethodSchema` - Full request/response schema with field names, types, and descriptions
|
|
25
|
+
- `ReadFullDocsArticle` - Full documentation with code examples (use if schema needs more context)
|
|
26
|
+
|
|
27
|
+
| Handler | Docs URL |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| `calculateAdditionalFees` | https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/additional-fees/additional-fees-service-plugin/calculate-additional-fees?apiView=SDK |
|
|
30
|
+
|
|
31
|
+
## Example: Global Additional Fee from Database Configuration
|
|
32
|
+
|
|
33
|
+
This example queries a CMS collection to retrieve a configurable global fee that applies to all orders.
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { additionalFees } from '@wix/ecom/service-plugins';
|
|
37
|
+
import { auth } from '@wix/essentials';
|
|
38
|
+
import { items } from '@wix/data';
|
|
39
|
+
|
|
40
|
+
interface GlobalFeeConfig {
|
|
41
|
+
_id: string;
|
|
42
|
+
feeAmount: number;
|
|
43
|
+
isEnabled: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
additionalFees.provideHandlers({
|
|
47
|
+
calculateAdditionalFees: async ({ request, metadata }) => {
|
|
48
|
+
try {
|
|
49
|
+
// Query the global additional fee configuration (elevated permissions required)
|
|
50
|
+
const elevatedQuery = auth.elevate(items.query);
|
|
51
|
+
const configResult = await elevatedQuery('global-additional-fee-config')
|
|
52
|
+
.limit(1)
|
|
53
|
+
.find();
|
|
54
|
+
|
|
55
|
+
// If no configuration found or fee is disabled, return empty fees
|
|
56
|
+
if (!configResult.items.length) {
|
|
57
|
+
return {
|
|
58
|
+
additionalFees: [],
|
|
59
|
+
currency: metadata.currency || 'USD'
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const config = configResult.items[0] as GlobalFeeConfig;
|
|
64
|
+
|
|
65
|
+
// Check if the fee is enabled and has a valid amount
|
|
66
|
+
if (!config.isEnabled || !config.feeAmount || config.feeAmount <= 0) {
|
|
67
|
+
return {
|
|
68
|
+
additionalFees: [],
|
|
69
|
+
currency: metadata.currency || 'USD'
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Ensure currency matches site currency
|
|
74
|
+
const responseCurrency = metadata.currency || 'USD';
|
|
75
|
+
|
|
76
|
+
// Convert fee amount to string as required by Wix API
|
|
77
|
+
const feeAmountString = config.feeAmount.toString();
|
|
78
|
+
|
|
79
|
+
// Create the global additional fee
|
|
80
|
+
const globalFee = {
|
|
81
|
+
code: 'global-additional-fee',
|
|
82
|
+
name: 'Global Additional Fee',
|
|
83
|
+
translatedName: 'Global Additional Fee',
|
|
84
|
+
price: feeAmountString,
|
|
85
|
+
taxDetails: {
|
|
86
|
+
taxable: true
|
|
87
|
+
}
|
|
88
|
+
// No lineItemIds specified - applies to entire cart
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
additionalFees: [globalFee],
|
|
93
|
+
currency: responseCurrency
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
} catch (error) {
|
|
97
|
+
return {
|
|
98
|
+
additionalFees: [],
|
|
99
|
+
currency: metadata.currency || 'USD'
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Key Implementation Notes
|
|
107
|
+
|
|
108
|
+
1. **Elevate permissions for API calls** - Use `auth.elevate` from `@wix/essentials` when calling Wix APIs from service plugins
|
|
109
|
+
2. **Return empty array when no fees apply** - Always return `{ additionalFees: [], currency: "..." }` when conditions aren't met
|
|
110
|
+
3. **Price must be a string** - Convert numeric amounts to strings
|
|
111
|
+
4. **Handle errors gracefully** - Return empty fees on error rather than throwing
|
|
112
|
+
5. **Omit lineItemIds for cart-wide fees** - Only specify when fee applies to specific items
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Bookings Staff Sorting Provider Service Plugin Reference
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Staff Sorting Provider SPI allows you to implement custom staff assignment algorithms for Wix Bookings. When a booking slot has multiple available staff members, Wix calls your plugin to determine the priority order for staff assignment.
|
|
6
|
+
|
|
7
|
+
**FQDN**: `wix.interfaces.resources.sorting.v1.staff_sorting_provider`
|
|
8
|
+
|
|
9
|
+
## Import
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { staffSorting } from "@wix/bookings/service-plugins";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Handler
|
|
16
|
+
|
|
17
|
+
| Handler | Description |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| `sortStaffMembers` | Sort available staff members by priority for a given booking slot |
|
|
20
|
+
|
|
21
|
+
## Request and Response Schema
|
|
22
|
+
|
|
23
|
+
Before implementing, call `ReadFullDocsMethodSchema` with the docs URL below to get the full request/response types.
|
|
24
|
+
|
|
25
|
+
**MCP Tools to use:**
|
|
26
|
+
- `ReadFullDocsMethodSchema` - Full request/response schema with field names, types, and descriptions
|
|
27
|
+
- `ReadFullDocsArticle` - Full documentation with code examples (use if schema needs more context)
|
|
28
|
+
|
|
29
|
+
| Handler | Docs URL |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `sortStaffMembers` | https://dev.wix.com/docs/api-reference/business-solutions/bookings/staff-members/staff-sorting-service-plugin/sort-staff-members?apiView=SDK |
|
|
32
|
+
|
|
33
|
+
**Important constraints:**
|
|
34
|
+
- You must return the **exact same IDs** from `availableResourceIds`, reordered by priority
|
|
35
|
+
- Do not add or remove any IDs
|
|
36
|
+
- If your response is invalid, Wix falls back to random assignment
|
|
37
|
+
|
|
38
|
+
## Performance Requirements
|
|
39
|
+
|
|
40
|
+
- **Hard limit**: Response must be returned within **5 seconds**
|
|
41
|
+
- **Recommended**: Keep response time under **500ms** for optimal user experience
|
|
42
|
+
|
|
43
|
+
## Example: Workload Balancing
|
|
44
|
+
|
|
45
|
+
This example sorts staff members to balance workload by prioritizing those with fewer recent bookings.
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { staffSorting } from "@wix/bookings/service-plugins";
|
|
49
|
+
import { auth } from "@wix/essentials";
|
|
50
|
+
import { bookings } from "@wix/bookings";
|
|
51
|
+
|
|
52
|
+
staffSorting.provideHandlers({
|
|
53
|
+
sortStaffMembers: async (payload) => {
|
|
54
|
+
const { request } = payload;
|
|
55
|
+
const { availableResourceIds, slot } = request;
|
|
56
|
+
|
|
57
|
+
// Query recent bookings for each available staff member
|
|
58
|
+
const elevatedQuery = auth.elevate(bookings.queryBookings);
|
|
59
|
+
const recentBookings = await elevatedQuery()
|
|
60
|
+
.eq("resource.id", availableResourceIds)
|
|
61
|
+
.ge("start.timestamp", new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString())
|
|
62
|
+
.find();
|
|
63
|
+
|
|
64
|
+
// Count bookings per staff member
|
|
65
|
+
const bookingCounts = new Map<string, number>();
|
|
66
|
+
for (const id of availableResourceIds) {
|
|
67
|
+
bookingCounts.set(id, 0);
|
|
68
|
+
}
|
|
69
|
+
for (const booking of recentBookings.items) {
|
|
70
|
+
const resourceId = booking.resource?.id;
|
|
71
|
+
if (resourceId && bookingCounts.has(resourceId)) {
|
|
72
|
+
bookingCounts.set(resourceId, (bookingCounts.get(resourceId) ?? 0) + 1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Sort by fewest bookings first (balance workload)
|
|
77
|
+
const sorted = [...availableResourceIds].sort(
|
|
78
|
+
(a, b) => (bookingCounts.get(a) ?? 0) - (bookingCounts.get(b) ?? 0)
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
staff: sorted.map((resourceId) => ({ resourceId })),
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Extension Registration
|
|
89
|
+
|
|
90
|
+
Register the staff sorting provider using the `bookingsStaffSortingProvider()` builder. This builder requires additional fields beyond the standard ones:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { extensions } from "@wix/astro/builders";
|
|
94
|
+
|
|
95
|
+
export const staffSorting = extensions.bookingsStaffSortingProvider({
|
|
96
|
+
id: "{{GENERATE_UUID}}",
|
|
97
|
+
name: "Workload Balanced Staff Assignment",
|
|
98
|
+
source: "./backend/service-plugins/bookings-staff-sorting/workload-balancer/plugin.ts",
|
|
99
|
+
methodName: "Workload Balancer",
|
|
100
|
+
methodDescription: "Balances workload by prioritizing staff with fewer recent bookings",
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Additional Builder Fields
|
|
105
|
+
|
|
106
|
+
| Field | Type | Required | Max Length | Description |
|
|
107
|
+
| --- | --- | --- | --- | --- |
|
|
108
|
+
| `methodName` | string | Yes | - | Display name for the sorting method |
|
|
109
|
+
| `methodDescription` | string | Yes | 100 chars | Description of the sorting algorithm (max 100 characters) |
|
|
110
|
+
| `dashboardPluginId` | string | No | - | Optional dashboard plugin ID for configuration UI |
|
|
111
|
+
|
|
112
|
+
## Key Implementation Notes
|
|
113
|
+
|
|
114
|
+
1. **Return all IDs** - You must return every ID from `availableResourceIds`, just reordered
|
|
115
|
+
2. **Performance matters** - Keep logic fast; the booking flow waits for your response
|
|
116
|
+
3. **Elevate permissions** - Use `auth.elevate` when querying Wix APIs from the handler
|
|
117
|
+
4. **Deterministic sorting** - Use a tiebreaker (e.g., resource ID) when priorities are equal
|
|
118
|
+
5. **Graceful degradation** - If your external data source is unavailable, return the original order rather than failing
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Discount Triggers Service Plugin Reference
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Custom Triggers SPI allows you to define custom conditions that can trigger discounts in the Wix eCommerce system. You can create time-based triggers, product-based triggers, or any custom logic.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { customTriggers } from "@wix/ecom/service-plugins";
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Handlers
|
|
14
|
+
|
|
15
|
+
| Handler | Description |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `getEligibleTriggers` | Evaluate current conditions and return which triggers are active |
|
|
18
|
+
| `listTriggers` | Return the list of all available custom triggers |
|
|
19
|
+
|
|
20
|
+
## Request and Response Schema
|
|
21
|
+
|
|
22
|
+
Before implementing, call `ReadFullDocsMethodSchema` with the docs URLs below to get the full request/response types.
|
|
23
|
+
|
|
24
|
+
**MCP Tools to use:**
|
|
25
|
+
- `ReadFullDocsMethodSchema` - Full request/response schema with field names, types, and descriptions
|
|
26
|
+
- `ReadFullDocsArticle` - Full documentation with code examples (use if schema needs more context)
|
|
27
|
+
|
|
28
|
+
| Handler | Docs URL |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| `getEligibleTriggers` | https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/discounts/custom-discount-triggers-integration-service-plugin/get-eligible-triggers?apiView=SDK |
|
|
31
|
+
| `listTriggers` | https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/discounts/custom-discount-triggers-integration-service-plugin/list-triggers?apiView=SDK |
|
|
32
|
+
|
|
33
|
+
## Example: Happy Hour and Digital Products Triggers
|
|
34
|
+
|
|
35
|
+
This example defines two custom triggers: a time-based "Happy Hour" trigger and a product-type-based "Digital Sale" trigger.
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { customTriggers } from "@wix/ecom/service-plugins";
|
|
39
|
+
|
|
40
|
+
customTriggers.provideHandlers({
|
|
41
|
+
getEligibleTriggers: async (payload) => {
|
|
42
|
+
const { request, metadata } = payload;
|
|
43
|
+
// Use the `request` and `metadata` received from Wix and
|
|
44
|
+
// apply custom logic.
|
|
45
|
+
return {
|
|
46
|
+
// Return your response exactly as documented to integrate with Wix.
|
|
47
|
+
// Return value example:
|
|
48
|
+
eligibleTriggers: [
|
|
49
|
+
{
|
|
50
|
+
customTriggerId: "my-happy-hour-trigger",
|
|
51
|
+
identifier: "123",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
customTriggerId: "my-digital-sale-trigger",
|
|
55
|
+
identifier: "234",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
listTriggers: async (payload) => {
|
|
61
|
+
const { request, metadata } = payload;
|
|
62
|
+
// Use the `request` and `metadata` received from Wix and
|
|
63
|
+
// apply custom logic.
|
|
64
|
+
return {
|
|
65
|
+
// Return your response exactly as documented to integrate with Wix.
|
|
66
|
+
// Return value example:
|
|
67
|
+
customTriggers: [
|
|
68
|
+
{
|
|
69
|
+
_id: "my-happy-hour-trigger",
|
|
70
|
+
name: "Happy Hour 16:00-18:00",
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
_id: "my-digital-sale-trigger",
|
|
74
|
+
name: "Digital products discount",
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Key Implementation Notes
|
|
83
|
+
|
|
84
|
+
1. **Trigger IDs must match** - The `customTriggerId` in `getEligibleTriggers` must match an `_id` from `listTriggers`
|
|
85
|
+
2. **Both handlers required** - You must implement both `getEligibleTriggers` and `listTriggers`
|
|
86
|
+
3. **Dynamic eligibility** - `getEligibleTriggers` is called during checkout to determine which triggers are currently active
|
|
87
|
+
4. **Static list** - `listTriggers` provides the master list of all possible triggers for configuration in the Wix dashboard
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Gift Cards Service Plugin Reference
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Gift Vouchers Provider SPI allows you to integrate external gift card or voucher systems with Wix eCommerce. This enables customers to redeem gift cards, check balances, and void transactions.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { giftVouchersProvider } from '@wix/ecom/service-plugins';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Handlers
|
|
14
|
+
|
|
15
|
+
| Handler | Description |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `redeem` | Process a gift card redemption during checkout |
|
|
18
|
+
| `getBalance` | Check the current balance of a gift card |
|
|
19
|
+
| `_void` | Cancel/void a previous redemption |
|
|
20
|
+
|
|
21
|
+
## Request and Response Schema
|
|
22
|
+
|
|
23
|
+
Before implementing, call `ReadFullDocsMethodSchema` with the docs URLs below to get the full request/response types.
|
|
24
|
+
|
|
25
|
+
**MCP Tools to use:**
|
|
26
|
+
- `ReadFullDocsMethodSchema` - Full request/response schema with field names, types, and descriptions
|
|
27
|
+
- `ReadFullDocsArticle` - Full documentation with code examples (use if schema needs more context)
|
|
28
|
+
|
|
29
|
+
| Handler | Docs URL |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `redeem` | https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/payments/gift-cards/gift-cards-service-plugin/redeem?apiView=SDK |
|
|
32
|
+
| `getBalance` | https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/payments/gift-cards/gift-cards-service-plugin/get-balance?apiView=SDK |
|
|
33
|
+
| `_void` | https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/payments/gift-cards/gift-cards-service-plugin/void?apiView=SDK |
|
|
34
|
+
|
|
35
|
+
## Example: Gift Card Provider Implementation
|
|
36
|
+
|
|
37
|
+
This example shows a basic gift card provider with all three required handlers.
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { giftVouchersProvider } from '@wix/ecom/service-plugins';
|
|
41
|
+
|
|
42
|
+
giftVouchersProvider.provideHandlers({
|
|
43
|
+
redeem: async (payload) => {
|
|
44
|
+
const { request, metadata } = payload;
|
|
45
|
+
// Use the `request` and `metadata` received from Wix and
|
|
46
|
+
// apply custom logic.
|
|
47
|
+
return {
|
|
48
|
+
// Return your response exactly as documented to integrate with Wix.
|
|
49
|
+
// Return value example:
|
|
50
|
+
remainingBalance: 80.00,
|
|
51
|
+
currencyCode: metadata.currency || "ILS",
|
|
52
|
+
transactionId: "00000000-0000-0000-0000-000000000001",
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
_void: async (payload) => {
|
|
56
|
+
const { request, metadata } = payload;
|
|
57
|
+
// Use the `request` and `metadata` received from Wix and
|
|
58
|
+
// apply custom logic.
|
|
59
|
+
return {
|
|
60
|
+
// Return your response exactly as documented to integrate with Wix.
|
|
61
|
+
// Return value example:
|
|
62
|
+
remainingBalance: 100.00,
|
|
63
|
+
currencyCode: metadata.currency || "ILS",
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
getBalance: async (payload) => {
|
|
67
|
+
const { request, metadata } = payload;
|
|
68
|
+
// Use the `request` and `metadata` received from Wix and
|
|
69
|
+
// apply custom logic.
|
|
70
|
+
return {
|
|
71
|
+
// Return your response exactly as documented to integrate with Wix.
|
|
72
|
+
// Return value example:
|
|
73
|
+
balance: 100.00,
|
|
74
|
+
currencyCode: metadata.currency || "ILS",
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Key Implementation Notes
|
|
81
|
+
|
|
82
|
+
1. **All three handlers required** - You must implement `redeem`, `getBalance`, and `_void`
|
|
83
|
+
2. **Transaction tracking** - The `redeem` handler must return a unique `transactionId` for tracking
|
|
84
|
+
3. **Balance as number** - Unlike other SPIs, balance values are numbers, not strings
|
|
85
|
+
4. **Void restores balance** - The `_void` handler should restore the redeemed amount back to the card
|
|
86
|
+
5. **Currency handling** - Use `metadata.currency` to get the site's currency setting
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Payment Settings Service Plugin Reference
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Payment Settings SPI allows you to integrate custom payment settings with the Wix eCommerce payment process. This is called during payment processing (e.g., when a customer enters credit card details) and returns payment settings that Wix passes to the payment provider.
|
|
6
|
+
|
|
7
|
+
A common use case is to enforce 3D Secure (3DS) payments for certain transactions based on custom business logic.
|
|
8
|
+
|
|
9
|
+
## Import
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { paymentSettings } from '@wix/ecom/service-plugins';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Handler
|
|
16
|
+
|
|
17
|
+
| Handler | Description |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| `getPaymentSettings` | Return payment settings to apply during the payment process |
|
|
20
|
+
|
|
21
|
+
## Request and Response Schema
|
|
22
|
+
|
|
23
|
+
Before implementing, call `ReadFullDocsMethodSchema` with the docs URL below to get the full request/response types.
|
|
24
|
+
|
|
25
|
+
**MCP Tools to use:**
|
|
26
|
+
- `ReadFullDocsMethodSchema` - Full request/response schema with field names, types, and descriptions
|
|
27
|
+
- `ReadFullDocsArticle` - Full documentation with code examples (use if schema needs more context)
|
|
28
|
+
|
|
29
|
+
| Handler | Docs URL |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `getPaymentSettings` | https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/payments/payment-settings/payment-settings-integration-service-plugin/get-payment-settings?apiView=SDK |
|
|
32
|
+
|
|
33
|
+
## Example: Require 3DS for High-Value Transactions
|
|
34
|
+
|
|
35
|
+
This example enforces 3D Secure authentication for orders above a certain threshold.
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { paymentSettings } from '@wix/ecom/service-plugins';
|
|
39
|
+
|
|
40
|
+
// Configuration
|
|
41
|
+
const HIGH_VALUE_THRESHOLD = 1000;
|
|
42
|
+
|
|
43
|
+
paymentSettings.provideHandlers({
|
|
44
|
+
getPaymentSettings: async ({ request, metadata }) => {
|
|
45
|
+
try {
|
|
46
|
+
// Get the order total
|
|
47
|
+
const orderTotal = request.order?.totals?.total || 0;
|
|
48
|
+
|
|
49
|
+
// Determine if 3DS is required based on order value
|
|
50
|
+
const require3DS = orderTotal >= HIGH_VALUE_THRESHOLD;
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
paymentSettings: {
|
|
54
|
+
requires3dSecure: require3DS
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
} catch (error) {
|
|
58
|
+
// Default to not requiring 3DS on error
|
|
59
|
+
return {
|
|
60
|
+
paymentSettings: {
|
|
61
|
+
requires3dSecure: false
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Example: Region-Based 3DS Requirements
|
|
70
|
+
|
|
71
|
+
This example requires 3D Secure for specific countries or regions.
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { paymentSettings } from '@wix/ecom/service-plugins';
|
|
75
|
+
|
|
76
|
+
// Countries that require 3DS
|
|
77
|
+
const REQUIRE_3DS_COUNTRIES = ['GB', 'FR', 'DE', 'IT', 'ES'];
|
|
78
|
+
|
|
79
|
+
paymentSettings.provideHandlers({
|
|
80
|
+
getPaymentSettings: async ({ request, metadata }) => {
|
|
81
|
+
try {
|
|
82
|
+
// Get billing country from order
|
|
83
|
+
const billingCountry = request.order?.billingInfo?.address?.country;
|
|
84
|
+
|
|
85
|
+
// Check if country requires 3DS
|
|
86
|
+
const require3DS = billingCountry
|
|
87
|
+
? REQUIRE_3DS_COUNTRIES.includes(billingCountry)
|
|
88
|
+
: false;
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
paymentSettings: {
|
|
92
|
+
requires3dSecure: require3DS
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
} catch (error) {
|
|
96
|
+
// Default to not requiring 3DS on error
|
|
97
|
+
return {
|
|
98
|
+
paymentSettings: {
|
|
99
|
+
requires3dSecure: false
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Key Implementation Notes
|
|
108
|
+
|
|
109
|
+
1. **Payment provider required** - Site must have a payment provider connected to collect payments
|
|
110
|
+
2. **Provider support required** - The payment provider must support the settings (e.g., not all providers support 3DS)
|
|
111
|
+
3. **Called during checkout** - This handler is invoked when the customer enters payment details during checkout
|
|
112
|
+
4. **Settings passed to provider** - The returned settings are passed to the payment provider for enforcement
|
|
113
|
+
5. **Fallback configuration** - Use the `fallbackValueForRequires3dSecure` builder field to set a default value if the SPI call fails (defaults to `false`)
|
|
114
|
+
6. **Handle errors gracefully** - Return sensible defaults on error rather than throwing
|
|
115
|
+
|
|
116
|
+
## Extension Registration
|
|
117
|
+
|
|
118
|
+
Register the payment settings provider using the `ecomPaymentSettings()` builder. This builder accepts a special `fallbackValueForRequires3dSecure` field:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import { extensions } from "@wix/astro/builders";
|
|
122
|
+
|
|
123
|
+
export const paymentSettings = extensions.ecomPaymentSettings({
|
|
124
|
+
id: "{{GENERATE_UUID}}",
|
|
125
|
+
name: "Custom Payment Settings",
|
|
126
|
+
source: "./backend/service-plugins/ecom-payment-settings/my-payment-settings/plugin.ts",
|
|
127
|
+
fallbackValueForRequires3dSecure: false, // Default if SPI call fails
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Additional Builder Fields
|
|
132
|
+
|
|
133
|
+
| Field | Type | Required | Description |
|
|
134
|
+
| --- | --- | --- | --- |
|
|
135
|
+
| `fallbackValueForRequires3dSecure` | boolean | No | Default value for `requires3dSecure` if the SPI call fails (defaults to `false`) |
|