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.updateShippingMethod("order_123", "action_123", {
shipping_option_id: "shipping_option_123",
})
.then(({ draft_order_preview }) => {
console.log(draft_order_preview)
})Update a new shipping method that was added to a draft order edit using the ID of the method’s SHIPPING_ADD action.
Every shipping method has an actions property, whose value is an array of actions. You can check the action’s name using its action property, and use the value of the id property.
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.updateShippingMethod("order_123", "action_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 ID of the shipping method's SHIPPING_ADD action.
The updates to make on a changed shipping method.
The ID of the associated shipping option.
The custom amount of the 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