Setting the file. One moment.
Subchapter 2.78
references/service-plugin/SHIPPING-RATES.mdMarkdown2 KBView on GitHub
The Shipping Rates SPI lets you provide custom shipping options and calculate shipping costs based on order details, destination, weight, or any custom logic. Implement the getShippingRates handler — it returns the available shipping options with their costs.
Before implementing, call ReadFullDocsMethodSchema on the docs URL to get the full request/response types.
This example provides an international shipping option with an additional handling fee charge.
import { shippingRates } from "@wix/ecom/service-plugins";
import { ChargeType } from "@wix/auto_sdk_ecom_shipping-rates";
shippingRates.provideHandlers({
getShippingRates: async (payload) => {
const { request, metadata } = payload;
// Use the `request` and `metadata` received from Wix and
// apply custom logic.
return {
// Return your response exactly as documented to integrate with Wix.
// Return value example:
shippingRates: [
{
code: "usps-international",
title: "USPS - International",
logistics: {
deliveryTime: "2-5 days",
},
cost: {
price: "15",
currency: metadata.currency || "ILS",
additionalCharges: [
{
price: "10",
type: ChargeType.HANDLING_FEE,
details: "Handling fee of $5 applied for fragile items.",
},
],
},
},
],
};
},
});ECOM_SHIPPING_RATES is singular — only one component of this type is allowed per app. Do not scaffold or include two Shipping Rates service plugins in the same app.
metadata.currency to get the site’s currencycode identifieradditionalCharges array for itemized extra costs like handling fees