@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,79 @@
|
|
|
1
|
+
# Shipping Rates Service Plugin Reference
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Shipping Rates SPI allows you to provide custom shipping options and calculate shipping costs based on order details, destination, weight, or any custom logic.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { shippingRates } from "@wix/ecom/service-plugins";
|
|
11
|
+
import { ChargeType } from "@wix/auto_sdk_ecom_shipping-rates";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Handler
|
|
15
|
+
|
|
16
|
+
| Handler | Description |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| `getShippingRates` | Calculate and return available shipping options with costs |
|
|
19
|
+
|
|
20
|
+
## Request and Response Schema
|
|
21
|
+
|
|
22
|
+
Before implementing, call `ReadFullDocsMethodSchema` with the docs URL 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
|
+
| `getShippingRates` | https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/shipping-rates/shipping-rates-integration-service-plugin/get-shipping-rates?apiView=SDK |
|
|
31
|
+
|
|
32
|
+
## Example: International Shipping with Handling Fee
|
|
33
|
+
|
|
34
|
+
This example provides an international shipping option with an additional handling fee charge.
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { shippingRates } from "@wix/ecom/service-plugins";
|
|
38
|
+
import { ChargeType } from "@wix/auto_sdk_ecom_shipping-rates";
|
|
39
|
+
|
|
40
|
+
shippingRates.provideHandlers({
|
|
41
|
+
getShippingRates: 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
|
+
shippingRates: [
|
|
49
|
+
{
|
|
50
|
+
code: "usps-international",
|
|
51
|
+
title: "USPS - International",
|
|
52
|
+
logistics: {
|
|
53
|
+
deliveryTime: "2-5 days",
|
|
54
|
+
},
|
|
55
|
+
cost: {
|
|
56
|
+
price: "15",
|
|
57
|
+
currency: metadata.currency || "ILS",
|
|
58
|
+
additionalCharges: [
|
|
59
|
+
{
|
|
60
|
+
price: "10",
|
|
61
|
+
type: ChargeType.HANDLING_FEE,
|
|
62
|
+
details: "Handling fee of $5 applied for fragile items.",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Key Implementation Notes
|
|
74
|
+
|
|
75
|
+
1. **Price as string** - All price values must be strings, not numbers
|
|
76
|
+
2. **Currency from metadata** - Use `metadata.currency` to get the site's currency
|
|
77
|
+
3. **Multiple options** - You can return multiple shipping rate options for customer to choose
|
|
78
|
+
4. **Unique codes** - Each shipping option needs a unique `code` identifier
|
|
79
|
+
5. **Additional charges** - Use `additionalCharges` array for itemized extra costs like handling fees
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Validations Service Plugin Reference
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Validations SPI allows you to add custom validation rules to the checkout process. You can validate cart contents, order totals, quantities, or any business logic requirement.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { validations } from "@wix/ecom/service-plugins";
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Handler
|
|
14
|
+
|
|
15
|
+
| Handler | Description |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `getValidationViolations` | Evaluate order and return any validation violations |
|
|
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
|
+
| `getValidationViolations` | https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/validations/validations-integration-service-plugin/get-validation-violations?apiView=SDK |
|
|
30
|
+
|
|
31
|
+
## Example: Minimum Quantity Validation
|
|
32
|
+
|
|
33
|
+
This example validates that the order meets a minimum item quantity requirement.
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { validations } from "@wix/ecom/service-plugins";
|
|
37
|
+
|
|
38
|
+
validations.provideHandlers({
|
|
39
|
+
getValidationViolations: async (payload) => {
|
|
40
|
+
const { request, metadata } = payload;
|
|
41
|
+
// Use the `request` and `metadata` received from Wix and
|
|
42
|
+
// apply custom logic.
|
|
43
|
+
return {
|
|
44
|
+
// Return your response exactly as documented to integrate with Wix.
|
|
45
|
+
// Return value example:
|
|
46
|
+
violations: [
|
|
47
|
+
{
|
|
48
|
+
description: "You must purchase at least 100 items.",
|
|
49
|
+
severity: validations.Severity.WARNING,
|
|
50
|
+
target: {
|
|
51
|
+
other: {
|
|
52
|
+
name: validations.NameInOther.OTHER_DEFAULT,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Key Implementation Notes
|
|
63
|
+
|
|
64
|
+
1. **Return empty array when valid** - Return `{ violations: [] }` when no validation issues
|
|
65
|
+
2. **Use SDK enums** - Use `validations.Severity` and `validations.NameInOther` for proper values
|
|
66
|
+
3. **Clear messages** - Write descriptive `description` text that helps customers fix the issue
|
|
67
|
+
4. **ERROR vs WARNING** - Use ERROR to block checkout, WARNING to inform but allow proceeding
|
|
68
|
+
5. **Target specificity** - Use `other.name` for cart-wide validations, `lineItem._id` for item-specific issues
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# Site Plugin Examples
|
|
2
|
+
|
|
3
|
+
Complete examples showing all required files for site plugins.
|
|
4
|
+
|
|
5
|
+
## Best Seller Badge Plugin
|
|
6
|
+
|
|
7
|
+
A customizable badge that displays on product pages with configurable text and colors.
|
|
8
|
+
|
|
9
|
+
### Plugin Component (`best-seller-badge.tsx`)
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
class BestSellerBadge extends HTMLElement {
|
|
13
|
+
static get observedAttributes() {
|
|
14
|
+
return ['badge-text', 'bg-color', 'text-color'];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
connectedCallback() {
|
|
22
|
+
this.render();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
attributeChangedCallback() {
|
|
26
|
+
this.render();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
const badgeText = this.getAttribute('badge-text') || 'Best Seller';
|
|
31
|
+
const bgColor = this.getAttribute('bg-color') || '#ff6b35';
|
|
32
|
+
const textColor = this.getAttribute('text-color') || '#ffffff';
|
|
33
|
+
|
|
34
|
+
this.innerHTML = `
|
|
35
|
+
<span style="
|
|
36
|
+
display: inline-block;
|
|
37
|
+
padding: 8px 16px;
|
|
38
|
+
background-color: ${bgColor};
|
|
39
|
+
color: ${textColor};
|
|
40
|
+
font-weight: bold;
|
|
41
|
+
border-radius: 4px;
|
|
42
|
+
font-size: 14px;
|
|
43
|
+
text-transform: uppercase;
|
|
44
|
+
letter-spacing: 1px;
|
|
45
|
+
">${badgeText}</span>
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default BestSellerBadge;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Settings Panel (`best-seller-badge.panel.tsx`)
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import React, { type FC, useState, useEffect, useCallback } from 'react';
|
|
57
|
+
import { widget, inputs } from '@wix/editor';
|
|
58
|
+
import {
|
|
59
|
+
SidePanel,
|
|
60
|
+
WixDesignSystemProvider,
|
|
61
|
+
Input,
|
|
62
|
+
FormField,
|
|
63
|
+
Box,
|
|
64
|
+
FillPreview,
|
|
65
|
+
} from '@wix/design-system';
|
|
66
|
+
import '@wix/design-system/styles.global.css';
|
|
67
|
+
|
|
68
|
+
const Panel: FC = () => {
|
|
69
|
+
const [badgeText, setBadgeText] = useState<string>('');
|
|
70
|
+
const [bgColor, setBgColor] = useState<string>('#ff6b35');
|
|
71
|
+
const [textColor, setTextColor] = useState<string>('#ffffff');
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
Promise.all([
|
|
75
|
+
widget.getProp('badge-text'),
|
|
76
|
+
widget.getProp('bg-color'),
|
|
77
|
+
widget.getProp('text-color'),
|
|
78
|
+
])
|
|
79
|
+
.then(([text, bg, color]) => {
|
|
80
|
+
setBadgeText(text || 'Best Seller');
|
|
81
|
+
setBgColor(bg || '#ff6b35');
|
|
82
|
+
setTextColor(color || '#ffffff');
|
|
83
|
+
})
|
|
84
|
+
.catch(error => console.error('Failed to fetch props:', error));
|
|
85
|
+
}, []);
|
|
86
|
+
|
|
87
|
+
const handleTextChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
|
|
88
|
+
const newText = event.target.value;
|
|
89
|
+
setBadgeText(newText);
|
|
90
|
+
widget.setProp('badge-text', newText);
|
|
91
|
+
}, []);
|
|
92
|
+
|
|
93
|
+
const handleBgColorChange = useCallback((value: string) => {
|
|
94
|
+
setBgColor(value);
|
|
95
|
+
widget.setProp('bg-color', value);
|
|
96
|
+
}, []);
|
|
97
|
+
|
|
98
|
+
const handleTextColorChange = useCallback((value: string) => {
|
|
99
|
+
setTextColor(value);
|
|
100
|
+
widget.setProp('text-color', value);
|
|
101
|
+
}, []);
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<WixDesignSystemProvider>
|
|
105
|
+
<SidePanel width="300" height="100vh">
|
|
106
|
+
<SidePanel.Content noPadding stretchVertically>
|
|
107
|
+
<SidePanel.Field>
|
|
108
|
+
<FormField label="Badge Text">
|
|
109
|
+
<Input
|
|
110
|
+
type="text"
|
|
111
|
+
value={badgeText}
|
|
112
|
+
onChange={handleTextChange}
|
|
113
|
+
aria-label="Badge Text"
|
|
114
|
+
/>
|
|
115
|
+
</FormField>
|
|
116
|
+
</SidePanel.Field>
|
|
117
|
+
<SidePanel.Field>
|
|
118
|
+
<FormField label="Background Color">
|
|
119
|
+
<Box width="30px" height="30px">
|
|
120
|
+
<FillPreview
|
|
121
|
+
fill={bgColor}
|
|
122
|
+
onClick={() => inputs.selectColor(bgColor, { onChange: (val) => { if (val) handleBgColorChange(val); } })}
|
|
123
|
+
/>
|
|
124
|
+
</Box>
|
|
125
|
+
</FormField>
|
|
126
|
+
</SidePanel.Field>
|
|
127
|
+
<SidePanel.Field>
|
|
128
|
+
<FormField label="Text Color">
|
|
129
|
+
<Box width="30px" height="30px">
|
|
130
|
+
<FillPreview
|
|
131
|
+
fill={textColor}
|
|
132
|
+
onClick={() => inputs.selectColor(textColor, { onChange: (val) => { if (val) handleTextColorChange(val); } })}
|
|
133
|
+
/>
|
|
134
|
+
</Box>
|
|
135
|
+
</FormField>
|
|
136
|
+
</SidePanel.Field>
|
|
137
|
+
</SidePanel.Content>
|
|
138
|
+
</SidePanel>
|
|
139
|
+
</WixDesignSystemProvider>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export default Panel;
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Extension Configuration (`best-seller-badge.extension.ts`)
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { extensions } from '@wix/astro/builders';
|
|
150
|
+
|
|
151
|
+
export default extensions.sitePlugin({
|
|
152
|
+
id: 'f8e2a1b3-c4d5-6789-abcd-ef0123456789',
|
|
153
|
+
name: 'Best Seller Badge',
|
|
154
|
+
marketData: {
|
|
155
|
+
name: 'Best Seller Badge',
|
|
156
|
+
description: 'Display a customizable badge on product pages',
|
|
157
|
+
logoUrl: '{{BASE_URL}}/best-seller-badge-logo.svg',
|
|
158
|
+
},
|
|
159
|
+
placements: [
|
|
160
|
+
{
|
|
161
|
+
appDefinitionId: '1380b703-ce81-ff05-f115-39571d94dfcd',
|
|
162
|
+
widgetId: '13a94f09-2766-3c40-4a32-8edb5acdd8bc',
|
|
163
|
+
slotId: 'product-page-details-2',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
appDefinitionId: 'a0c68605-c2e7-4c8d-9ea1-767f9770e087',
|
|
167
|
+
widgetId: '6a25b678-53ec-4b37-a190-65fcd1ca1a63',
|
|
168
|
+
slotId: 'product-page-details-2',
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
installation: { autoAdd: true },
|
|
172
|
+
tagName: 'best-seller-badge',
|
|
173
|
+
element: './extensions/site/plugins/best-seller-badge/best-seller-badge.tsx',
|
|
174
|
+
settings: './extensions/site/plugins/best-seller-badge/best-seller-badge.panel.tsx',
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Dashboard Page for Plugin Management
|
|
179
|
+
|
|
180
|
+
For plugins that require back-office management (especially checkout and side cart plugins that may not support auto-add), create a dashboard page.
|
|
181
|
+
|
|
182
|
+
> **Note:** The `placement` option in `addSitePlugin()` is optional. If omitted, the plugin is placed in the first available slot based on the priority order configured in the plugin's installation settings in your app's dashboard.
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
// src/extensions/dashboard/pages/plugin-settings/page.tsx
|
|
186
|
+
import { dashboard } from "@wix/dashboard";
|
|
187
|
+
import { Page, WixDesignSystemProvider, Card, FormField, Input, Button } from "@wix/design-system";
|
|
188
|
+
|
|
189
|
+
export default function PluginSettingsPage() {
|
|
190
|
+
const handleAddToSlot = async () => {
|
|
191
|
+
const pluginId = "your-plugin-id";
|
|
192
|
+
const pluginPlacement = {
|
|
193
|
+
appDefinitionId: "host-app-definition-id",
|
|
194
|
+
widgetId: "host-widget-id",
|
|
195
|
+
slotId: "target-slot-id",
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
await dashboard.addSitePlugin(pluginId, {
|
|
199
|
+
placement: pluginPlacement,
|
|
200
|
+
});
|
|
201
|
+
dashboard.showToast({ message: "Plugin added!", type: "success" });
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
<WixDesignSystemProvider>
|
|
206
|
+
<Page>
|
|
207
|
+
<Page.Header title="Plugin Settings" />
|
|
208
|
+
<Page.Content>
|
|
209
|
+
<Card>
|
|
210
|
+
<Card.Header title="Manage Your Plugin" />
|
|
211
|
+
<Card.Content>
|
|
212
|
+
<Button onClick={handleAddToSlot}>Add Plugin to Slot</Button>
|
|
213
|
+
</Card.Content>
|
|
214
|
+
</Card>
|
|
215
|
+
</Page.Content>
|
|
216
|
+
</Page>
|
|
217
|
+
</WixDesignSystemProvider>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Wix Data API Integration
|
|
223
|
+
|
|
224
|
+
When using Wix Data API in plugins, handle the Wix Editor environment:
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
import { items } from "@wix/data";
|
|
228
|
+
import { window as wixWindow } from "@wix/site-window";
|
|
229
|
+
|
|
230
|
+
class DataPlugin extends HTMLElement {
|
|
231
|
+
static get observedAttributes() {
|
|
232
|
+
return ['collection-id'];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
constructor() {
|
|
236
|
+
super();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
connectedCallback() {
|
|
240
|
+
this.render();
|
|
241
|
+
this.loadData();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
attributeChangedCallback() {
|
|
245
|
+
this.loadData();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
render() {
|
|
249
|
+
this.innerHTML = `
|
|
250
|
+
<div style="padding: 16px; border: 1px solid #ccc; border-radius: 8px;">
|
|
251
|
+
<p>Loading...</p>
|
|
252
|
+
</div>
|
|
253
|
+
`;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
async loadData() {
|
|
257
|
+
const collectionId = this.getAttribute('collection-id');
|
|
258
|
+
if (!collectionId) return;
|
|
259
|
+
|
|
260
|
+
try {
|
|
261
|
+
const viewMode = await wixWindow.viewMode();
|
|
262
|
+
|
|
263
|
+
if (viewMode === 'Editor') {
|
|
264
|
+
this.innerHTML = `
|
|
265
|
+
<div style="padding: 20px; border: 2px dashed #ccc;">
|
|
266
|
+
<p>Plugin will display data on the live site</p>
|
|
267
|
+
<p>Collection: ${collectionId}</p>
|
|
268
|
+
</div>
|
|
269
|
+
`;
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const results = await items.query(collectionId).limit(10).find();
|
|
274
|
+
this.innerHTML = `
|
|
275
|
+
<div style="padding: 16px;">
|
|
276
|
+
${results.items.map(item => `<div>${item.title}</div>`).join('')}
|
|
277
|
+
</div>
|
|
278
|
+
`;
|
|
279
|
+
} catch (error) {
|
|
280
|
+
console.error('Failed to load data:', error);
|
|
281
|
+
this.innerHTML = `<div style="color: red;">Error loading data</div>`;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export default DataPlugin;
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Example Use Cases
|
|
290
|
+
|
|
291
|
+
### Booking Confirmation Message Plugin
|
|
292
|
+
|
|
293
|
+
**Request:** "Create a plugin for booking pages that shows a custom confirmation message"
|
|
294
|
+
|
|
295
|
+
**Output:**
|
|
296
|
+
|
|
297
|
+
- Plugin with configurable title, message, and styling
|
|
298
|
+
- Settings panel with text inputs and color pickers
|
|
299
|
+
- Responsive layout that fits the booking page slot
|
|
300
|
+
|
|
301
|
+
### Product Reviews Summary Plugin
|
|
302
|
+
|
|
303
|
+
**Request:** "Create a plugin that displays a reviews summary on product pages"
|
|
304
|
+
|
|
305
|
+
**Output:**
|
|
306
|
+
|
|
307
|
+
- Plugin showing star rating and review count
|
|
308
|
+
- Configurable display options (show count, show average)
|
|
309
|
+
- Settings panel for styling customization
|
|
310
|
+
- Integration with slot on product page
|
|
311
|
+
- Include placements for both old and new Wix Stores product page versions
|