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.addItems("order_123", {
items: [
{
variant_id: "variant_123",
quantity: 1,
},
],
})
.then(({ draft_order_preview }) => {
console.log(draft_order_preview)
})Add an item 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.addItems("order_123", {
items: [
{
variant_id: "variant_123",
quantity: 1,
},
],
})
.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 items to add to a draft order.
The items to add to the draft order.
Show child attributes
The item's quantity.
The ID of the variant to add to the draft order.
The item's title.
The item's unit price.
The original price of the item before a promotion or sale.
A note viewed only by admin users about the item.
Whether the item can be purchased if it's out of stock.
The item's metadata, can hold custom key-value pairs.
OK