Loading...
Loading...
Compare original and translation side by side
src/backend/service-plugins/<service-type>/<plugin-name>/plugin.tsprovideHandlers()extensions.tssrc/extensions.tsnpx tsc --noEmitnpx wix buildsrc/backend/service-plugins/<service-type>/<plugin-name>/plugin.tsprovideHandlers()extensions.tssrc/extensions.tsnpx tsc --noEmitnpx wix build| SPI Type | Reference |
|---|---|
| Additional Fees | ADDITIONAL-FEES.md |
| Discount Triggers | DISCOUNT-TRIGGERS.md |
| Gift Cards | GIFT-CARDS.md |
| Shipping Rates | SHIPPING-RATES.md |
| Tax Calculation | TAX-CALCULATION.md |
| Validations | VALIDATIONS.md |
| SPI类型 | 参考文档 |
|---|---|
| 附加费用 | ADDITIONAL-FEES.md |
| 折扣触发器 | DISCOUNT-TRIGGERS.md |
| 礼品卡 | GIFT-CARDS.md |
| 配送费率 | SHIPPING-RATES.md |
| 税费计算 | TAX-CALCULATION.md |
| 验证 | VALIDATIONS.md |
src/backend/service-plugins/
└── {service-type}/
└── {plugin-name}/
├── plugin.ts # Handler logic with provideHandlers()
└── extensions.ts # Builder configuration (id, name, source)src/backend/service-plugins/
└── {service-type}/
└── {plugin-name}/
├── plugin.ts # 包含provideHandlers()的处理逻辑
└── extensions.ts # 构建器配置(ID、名称、源文件路径)| File | Purpose |
|---|---|
| Contains the service plugin handler logic with |
| Contains the service plugin builder configuration with id (GUID), name, description, and source path |
| 文件 | 用途 |
|---|---|
| 包含服务插件的处理逻辑和 |
| 包含服务插件的构建器配置,包括ID(GUID)、名称、描述和源文件路径 |
plugin.ts@wix/ecom/service-pluginsprovideHandlers()requestmetadataimport { shippingRates } from "@wix/ecom/service-plugins";
shippingRates.provideHandlers({
getShippingRates: async (payload) => {
const { request, metadata } = payload;
// Implement custom logic based on request data
// - request contains cart items, shipping address, etc.
// - metadata contains currency, locale, etc.
return {
shippingRates: [
{
code: "custom-shipping",
title: "Custom Shipping",
logistics: {
deliveryTime: "3-5 business days",
},
cost: {
price: "9.99",
currency: metadata.currency || "USD",
},
},
],
};
},
});plugin.ts@wix/ecom/service-pluginsprovideHandlers()requestmetadataimport { shippingRates } from "@wix/ecom/service-plugins";
shippingRates.provideHandlers({
getShippingRates: async (payload) => {
const { request, metadata } = payload;
// 根据请求数据实现自定义逻辑
// - request包含购物车商品、配送地址等信息
// - metadata包含货币、区域设置等信息
return {
shippingRates: [
{
code: "custom-shipping",
title: "Custom Shipping",
logistics: {
deliveryTime: "3-5 business days",
},
cost: {
price: "9.99",
currency: metadata.currency || "USD",
},
},
],
};
},
});auth.elevate@wix/essentialsimport { auth } from "@wix/essentials";
import { items } from "@wix/data";
export const myFunction = async () => {
const elevatedFunction = auth.elevate(items.query);
const elevatedResponse = await elevatedFunction("myCollection");
return elevatedResponse;
};import { auth } from "@wix/essentials";
import { cart } from "@wix/ecom";
export const myFunction = async () => {
const elevatedFunction = auth.elevate(cart.getCart);
const elevatedResponse = await elevatedFunction("cart-id");
return elevatedResponse;
};import { auth } from "@wix/essentials";
import { products } from "@wix/stores";
export const myFunction = async () => {
const elevatedFunction = auth.elevate(products.deleteCollection);
const elevatedResponse = await elevatedFunction("collection-id");
return elevatedResponse;
};@wix/essentialsauth.elevateimport { auth } from "@wix/essentials";
import { items } from "@wix/data";
export const myFunction = async () => {
const elevatedFunction = auth.elevate(items.query);
const elevatedResponse = await elevatedFunction("myCollection");
return elevatedResponse;
};import { auth } from "@wix/essentials";
import { cart } from "@wix/ecom";
export const myFunction = async () => {
const elevatedFunction = auth.elevate(cart.getCart);
const elevatedResponse = await elevatedFunction("cart-id");
return elevatedResponse;
};import { auth } from "@wix/essentials";
import { products } from "@wix/stores";
export const myFunction = async () => {
const elevatedFunction = auth.elevate(products.deleteCollection);
const elevatedResponse = await elevatedFunction("collection-id");
return elevatedResponse;
};extensions.tsimport { extensions } from "@wix/astro/builders";
export const ecomshippingratesMyShipping = extensions.ecomShippingRates({
id: "{{GENERATE_UUID}}",
name: "My Shipping Rates",
description: "Calculates custom shipping rates based on order weight",
source: "./backend/service-plugins/ecom-shipping-rates/my-shipping/plugin.ts",
});idrandomUUID(){{GENERATE_UUID}}"a1b2c3d4-e5f6-7890-abcd-ef1234567890"extensions.tsimport { extensions } from "@wix/astro/builders";
export const ecomshippingratesMyShipping = extensions.ecomShippingRates({
id: "{{GENERATE_UUID}}",
name: "My Shipping Rates",
description: "Calculates custom shipping rates based on order weight",
source: "./backend/service-plugins/ecom-shipping-rates/my-shipping/plugin.ts",
});idrandomUUID(){{GENERATE_UUID}}"a1b2c3d4-e5f6-7890-abcd-ef1234567890"| Field | Type | Description |
|---|---|---|
| string | Service plugin ID as a GUID. Must be unique across all extensions in the project. |
| string | The service plugin name (visible in app dashboard when developing an app). |
| string | A short description of what the service plugin does. |
| string | Path to the service plugin handler file that contains the plugin logic. |
| SPI Type | Builder Method |
|---|---|
| Shipping Rates | |
| Additional Fees | |
| Validations | |
| Discount Triggers | |
| Gift Cards | |
| Payment Settings | |
| 字段 | 类型 | 描述 |
|---|---|---|
| 字符串 | 服务插件ID,为GUID。在项目的所有扩展中必须唯一。 |
| 字符串 | 服务插件名称(开发应用时在应用仪表板中可见)。 |
| 字符串 | 服务插件的简短描述。 |
| 字符串 | 包含插件逻辑的服务插件处理文件的路径。 |
src/extensions.ts| SPI类型 | 构建器方法 |
|---|---|
| 配送费率 | |
| 附加费用 | |
| 验证 | |
| 折扣触发器 | |
| 礼品卡 | |
| 支付设置 | |
src/extensions.ts