import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.admin.draftOrder.addShippingMethod("order_123", {
shipping_option_id: "shipping_option_123",
})
.then(({ draft_order_preview }) => {
console.log(draft_order_preview)
})Add a shipping method to a draft order edit.
import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.admin.draftOrder.addShippingMethod("order_123", {
shipping_option_id: "shipping_option_123",
})
.then(({ draft_order_preview }) => {
console.log(draft_order_preview)
})Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
The draft order's ID.
The details of the shipping method to add to a draft order.
The ID of the shipping option that this method is created from.
A custom amount to be charged for this shipping method. If not provided, the shipping option's amount will be used.
The shipping method's description.
A note viewed only by admin users about the shipping method.
The shipping method's metadata, can hold custom key-value pairs.
OK